Ver Fonte

feat(icons): make it possible to disable icons (#2529)

Abouzar Parvan há 3 anos atrás
pai
commit
6a66e39f29

+ 2 - 0
lua/lvim/config/defaults.lua

@@ -10,6 +10,8 @@ return {
   },
   keys = {},
 
+  use_icons = true,
+
   builtin = {},
 
   plugins = {

+ 6 - 3
lua/lvim/core/bufferline.lua

@@ -4,9 +4,12 @@ local function is_ft(b, ft)
   return vim.bo[b].filetype == ft
 end
 
-local function diagnostics_indicator(_, _, diagnostics)
+local function diagnostics_indicator(num, _, diagnostics, _)
   local result = {}
   local symbols = { error = "", warning = "", info = "" }
+  if not lvim.use_icons then
+    return "(" .. num .. ")"
+  end
   for name, count in pairs(diagnostics) do
     if symbols[name] and count > 0 then
       table.insert(result, symbols[name] .. " " .. count)
@@ -112,8 +115,8 @@ M.config = function()
           padding = 1,
         },
       },
-      show_buffer_icons = true, -- disable filetype icons for buffers
-      show_buffer_close_icons = true,
+      show_buffer_icons = lvim.use_icons, -- disable filetype icons for buffers
+      show_buffer_close_icons = lvim.use_icons,
       show_close_icon = false,
       show_tab_indicators = true,
       persist_buffer_sort = true, -- whether or not custom sorted buffers should persist

+ 3 - 1
lua/lvim/core/cmp.lua

@@ -220,7 +220,9 @@ M.config = function()
         if max_width ~= 0 and #vim_item.abbr > max_width then
           vim_item.abbr = string.sub(vim_item.abbr, 1, max_width - 1) .. "…"
         end
-        vim_item.kind = lvim.builtin.cmp.formatting.kind_icons[vim_item.kind]
+        if lvim.use_icons then
+          vim_item.kind = lvim.builtin.cmp.formatting.kind_icons[vim_item.kind]
+        end
         vim_item.menu = lvim.builtin.cmp.formatting.source_names[entry.source.name]
         vim_item.dup = lvim.builtin.cmp.formatting.duplicates[entry.source.name]
           or lvim.builtin.cmp.formatting.duplicates_default

+ 5 - 3
lua/lvim/core/dap.lua

@@ -28,9 +28,11 @@ end
 M.setup = function()
   local dap = require "dap"
 
-  vim.fn.sign_define("DapBreakpoint", lvim.builtin.dap.breakpoint)
-  vim.fn.sign_define("DapBreakpointRejected", lvim.builtin.dap.breakpoint_rejected)
-  vim.fn.sign_define("DapStopped", lvim.builtin.dap.stopped)
+  if lvim.use_icons then
+    vim.fn.sign_define("DapBreakpoint", lvim.builtin.dap.breakpoint)
+    vim.fn.sign_define("DapBreakpointRejected", lvim.builtin.dap.breakpoint_rejected)
+    vim.fn.sign_define("DapStopped", lvim.builtin.dap.stopped)
+  end
 
   dap.defaults.fallback.terminal_win_cmd = "50vsplit new"
 

+ 3 - 3
lua/lvim/core/lualine/styles.lua

@@ -11,7 +11,7 @@ styles.none = {
   style = "none",
   options = {
     theme = "auto",
-    icons_enabled = true,
+    icons_enabled = lvim.use_icons,
     component_separators = { left = "", right = "" },
     section_separators = { left = "", right = "" },
     disabled_filetypes = {},
@@ -40,7 +40,7 @@ styles.default = {
   style = "default",
   options = {
     theme = "auto",
-    icons_enabled = true,
+    icons_enabled = lvim.use_icons,
     component_separators = { left = "", right = "" },
     section_separators = { left = "", right = "" },
     disabled_filetypes = {},
@@ -69,7 +69,7 @@ styles.lvim = {
   style = "lvim",
   options = {
     theme = "auto",
-    icons_enabled = true,
+    icons_enabled = lvim.use_icons,
     component_separators = { left = "", right = "" },
     section_separators = { left = "", right = "" },
     disabled_filetypes = { "alpha", "NvimTree", "Outline" },

+ 9 - 0
lua/lvim/core/notify.lua

@@ -39,6 +39,15 @@ local defaults = {
 }
 
 function M.config()
+  if not lvim.use_icons then
+    defaults.opts.icons = {
+      ERROR = "[ERROR]",
+      WARN = "[WARNING]",
+      INFO = "[INFo]",
+      DEBUG = "[DEBUG]",
+      TRACE = "[TRACE]",
+    }
+  end
   lvim.builtin.notify = vim.tbl_deep_extend("force", defaults, lvim.builtin.notify or {})
 end
 

+ 6 - 5
lua/lvim/core/nvimtree.lua

@@ -2,6 +2,7 @@ local M = {}
 local Log = require "lvim.core.log"
 
 function M.config()
+  local vim_show_icons = lvim.use_icons and 1 or 0
   lvim.builtin.nvimtree = {
     active = true,
     on_config_done = nil,
@@ -30,7 +31,7 @@ function M.config()
       hijack_cursor = false,
       update_cwd = false,
       diagnostics = {
-        enable = true,
+        enable = lvim.use_icons,
         icons = {
           hint = "",
           info = "",
@@ -90,10 +91,10 @@ function M.config()
       },
     },
     show_icons = {
-      git = 1,
-      folders = 1,
-      files = 1,
-      folder_arrows = 1,
+      git = vim_show_icons,
+      folders = vim_show_icons,
+      files = vim_show_icons,
+      folder_arrows = vim_show_icons,
     },
     git_hl = 1,
     root_folder_modifier = ":t",

+ 4 - 2
lua/lvim/lsp/init.lua

@@ -134,8 +134,10 @@ function M.setup()
     return
   end
 
-  for _, sign in ipairs(lvim.lsp.diagnostics.signs.values) do
-    vim.fn.sign_define(sign.name, { texthl = sign.name, text = sign.text, numhl = sign.name })
+  if lvim.use_icons then
+    for _, sign in ipairs(lvim.lsp.diagnostics.signs.values) do
+      vim.fn.sign_define(sign.name, { texthl = sign.name, text = sign.text, numhl = sign.name })
+    end
   end
 
   require("lvim.lsp.handlers").setup()

+ 4 - 1
lua/lvim/plugins.lua

@@ -175,7 +175,10 @@ local core_plugins = {
   },
 
   -- Icons
-  { "kyazdani42/nvim-web-devicons" },
+  {
+    "kyazdani42/nvim-web-devicons",
+    disable = not lvim.use_icons,
+  },
 
   -- Status Line and Bufferline
   {

+ 2 - 0
utils/installer/config.example.lua

@@ -12,6 +12,8 @@ an executable
 lvim.log.level = "warn"
 lvim.format_on_save = true
 lvim.colorscheme = "onedarker"
+-- to disable icons and use a minimalist setup, uncomment the following
+-- lvim.use_icons = false
 
 -- keymappings [view all the defaults by pressing <leader>Lk]
 lvim.leader = "space"

+ 2 - 0
utils/installer/config_win.example.lua

@@ -29,6 +29,8 @@ vim.g.clipboard = {
 lvim.log.level = "warn"
 lvim.format_on_save = true
 lvim.colorscheme = "onedarker"
+-- to disable icons and use a minimalist setup, uncomment the following
+-- lvim.use_icons = false
 
 -- keymappings [view all the defaults by pressing <leader>Lk]
 lvim.leader = "space"