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

This commit is contained in:
Abouzar Parvan 2022-04-28 19:00:39 +04:30 committed by GitHub
parent dd65e28565
commit 6a66e39f29
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 46 additions and 18 deletions

View file

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

View file

@ -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

View file

@ -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

View file

@ -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"

View file

@ -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" },

View file

@ -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

View file

@ -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",

View file

@ -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()

View file

@ -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
{

View file

@ -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"

View file

@ -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"