From 8767a17b5e6087153494a5cd30e5ae0c5165c9af Mon Sep 17 00:00:00 2001 From: Philippe Richard Date: Sun, 2 Oct 2022 23:48:23 -0400 Subject: feat: move icons to a single icons file (#3115) --- lua/lvim/core/alpha/dashboard.lua | 16 ++++++++------ lua/lvim/core/alpha/startify.lua | 2 +- lua/lvim/core/breadcrumbs.lua | 41 +++--------------------------------- lua/lvim/core/bufferline.lua | 18 ++++++++++------ lua/lvim/core/cmp.lua | 30 ++------------------------ lua/lvim/core/dap.lua | 6 +++--- lua/lvim/core/gitsigns.lua | 10 ++++----- lua/lvim/core/indentlines.lua | 2 +- lua/lvim/core/info.lua | 14 ++++++------ lua/lvim/core/lir.lua | 2 +- lua/lvim/core/lualine/components.lua | 31 ++++++++++++++++++--------- lua/lvim/core/lualine/styles.lua | 10 +++++++-- lua/lvim/core/notify.lua | 10 ++++----- lua/lvim/core/nvimtree.lua | 36 +++++++++++++++---------------- lua/lvim/core/telescope.lua | 4 ++-- lua/lvim/core/which-key.lua | 6 +++--- 16 files changed, 101 insertions(+), 137 deletions(-) (limited to 'lua/lvim/core') diff --git a/lua/lvim/core/alpha/dashboard.lua b/lua/lvim/core/alpha/dashboard.lua index debf88a7..5e73206f 100644 --- a/lua/lvim/core/alpha/dashboard.lua +++ b/lua/lvim/core/alpha/dashboard.lua @@ -113,12 +113,16 @@ function M.get_sections() end buttons = { val = { - button("f", " Find File", "Telescope find_files"), - button("n", " New File", "ene!"), - button("p", " Projects ", "Telescope projects"), - button("r", " Recent files", ":Telescope oldfiles "), - button("t", " Find Text", "Telescope live_grep"), - button("c", " Configuration", "edit " .. require("lvim.config"):get_user_config_path() .. " "), + button("f", lvim.icons.ui.FindFile .. " Find File", "Telescope find_files"), + button("n", lvim.icons.ui.NewFile .. " New File", "ene!"), + button("p", lvim.icons.ui.Project .. " Projects ", "Telescope projects"), + button("r", lvim.icons.ui.History .. " Recent files", ":Telescope oldfiles "), + button("t", lvim.icons.ui.FindText .. " Find Text", "Telescope live_grep"), + button( + "c", + lvim.icons.ui.Gear .. " Configuration", + "edit " .. require("lvim.config"):get_user_config_path() .. " " + ), }, } end diff --git a/lua/lvim/core/alpha/startify.lua b/lua/lvim/core/alpha/startify.lua index 2ea541f5..b1e83d1d 100644 --- a/lua/lvim/core/alpha/startify.lua +++ b/lua/lvim/core/alpha/startify.lua @@ -19,7 +19,7 @@ function M.get_sections() local top_buttons = { entries = { - { "e", " New File", "ene!" }, + { "e", lvim.icons.ui.NewFile .. " New File", "ene!" }, }, val = {}, } diff --git a/lua/lvim/core/breadcrumbs.lua b/lua/lvim/core/breadcrumbs.lua index 23b516db..dd7f5163 100644 --- a/lua/lvim/core/breadcrumbs.lua +++ b/lua/lvim/core/breadcrumbs.lua @@ -7,42 +7,7 @@ M.config = function() active = false, on_config_done = nil, options = { - icons = { - Text = " ", - Method = " ", - Function = " ", - Constructor = " ", - Field = " ", - Variable = " ", - Class = " ", - Interface = " ", - Module = " ", - Property = " ", - Unit = " ", - Value = " ", - Enum = " ", - Keyword = " ", - Snippet = " ", - Color = " ", - File = " ", - Reference = " ", - Folder = " ", - EnumMember = " ", - Constant = " ", - Struct = " ", - Event = " ", - Operator = " ", - TypeParameter = " ", - Array = " ", - Number = " ", - String = " ", - Boolean = "蘒", - Object = " ", - Package = " ", - Namespace = "", - Key = "", - Null = "ﳠ", - }, + icons = lvim.icons.kind, highlight = true, separator = " " .. ">" .. " ", depth_limit = 0, @@ -107,7 +72,7 @@ M.get_filename = function() vim.api.nvim_set_hl(0, hl_group, { fg = file_icon_color }) if f.isempty(file_icon) then - file_icon = "" + file_icon = lvim.icons.kind.File end local navic_text = vim.api.nvim_get_hl_by_name("Normal", true) @@ -165,7 +130,7 @@ M.get_winbar = function() if not f.isempty(value) and f.get_buf_option "mod" then -- TODO: replace with circle - local mod = "%#LspCodeLens#" .. "" .. "%*" + local mod = "%#LspCodeLens#" .. lvim.icons.ui.Circle .. "%*" if gps_added then value = value .. " " .. mod else diff --git a/lua/lvim/core/bufferline.lua b/lua/lvim/core/bufferline.lua index 6ae0d6c6..b8143813 100644 --- a/lua/lvim/core/bufferline.lua +++ b/lua/lvim/core/bufferline.lua @@ -6,7 +6,11 @@ end local function diagnostics_indicator(num, _, diagnostics, _) local result = {} - local symbols = { error = "", warning = "", info = "" } + local symbols = { + error = lvim.icons.diagnostics.Error, + warning = lvim.icons.diagnostics.Warning, + info = lvim.icons.diagnostics.Information, + } if not lvim.use_icons then return "(" .. num .. ")" end @@ -59,14 +63,14 @@ M.config = function() left_mouse_command = "buffer %d", -- can be a string | function, see "Mouse actions" middle_mouse_command = nil, -- can be a string | function, see "Mouse actions" indicator = { - icon = "▎", -- this should be omitted if indicator style is not 'icon' + icon = lvim.icons.ui.BoldLineLeft, -- this should be omitted if indicator style is not 'icon' style = "icon", -- can also be 'underline'|'none', }, - buffer_close_icon = "", - modified_icon = "●", - close_icon = "", - left_trunc_marker = "", - right_trunc_marker = "", + buffer_close_icon = lvim.icons.ui.Close, + modified_icon = lvim.icons.ui.Circle, + close_icon = lvim.icons.ui.BoldClose, + left_trunc_marker = lvim.icons.ui.ArrowCircleLeft, + right_trunc_marker = lvim.icons.ui.ArrowCircleRight, --- name_formatter can be used to change the buffer's label in the bufferline. --- Please note some names can/will break the --- bufferline so use this at your discretion knowing that it has diff --git a/lua/lvim/core/cmp.lua b/lua/lvim/core/cmp.lua index a6362aa7..319bdc64 100644 --- a/lua/lvim/core/cmp.lua +++ b/lua/lvim/core/cmp.lua @@ -141,33 +141,7 @@ M.config = function() formatting = { fields = { "kind", "abbr", "menu" }, max_width = 0, - kind_icons = { - Class = " ", - Color = " ", - Constant = "ﲀ ", - Constructor = " ", - Enum = "練", - EnumMember = " ", - Event = " ", - Field = " ", - File = "", - Folder = " ", - Function = " ", - Interface = "ﰮ ", - Keyword = " ", - Method = " ", - Module = " ", - Operator = "", - Property = " ", - Reference = " ", - Snippet = " ", - Struct = " ", - Text = " ", - TypeParameter = " ", - Unit = "塞", - Value = " ", - Variable = " ", - }, + kind_icons = lvim.icons.kind, source_names = { nvim_lsp = "(LSP)", emoji = "(Emoji)", @@ -189,7 +163,7 @@ M.config = function() format = function(entry, vim_item) local max_width = lvim.builtin.cmp.formatting.max_width if max_width ~= 0 and #vim_item.abbr > max_width then - vim_item.abbr = string.sub(vim_item.abbr, 1, max_width - 1) .. "…" + vim_item.abbr = string.sub(vim_item.abbr, 1, max_width - 1) .. lvim.icons.ui.Ellipsis end if lvim.use_icons then vim_item.kind = lvim.builtin.cmp.formatting.kind_icons[vim_item.kind] diff --git a/lua/lvim/core/dap.lua b/lua/lvim/core/dap.lua index 727e238f..9e629cda 100644 --- a/lua/lvim/core/dap.lua +++ b/lua/lvim/core/dap.lua @@ -5,19 +5,19 @@ M.config = function() active = false, on_config_done = nil, breakpoint = { - text = "", + text = lvim.icons.ui.Bug, texthl = "LspDiagnosticsSignError", linehl = "", numhl = "", }, breakpoint_rejected = { - text = "", + text = lvim.icons.ui.Bug, texthl = "LspDiagnosticsSignHint", linehl = "", numhl = "", }, stopped = { - text = "", + text = lvim.icons.ui.BoldArrowRight, texthl = "LspDiagnosticsSignInformation", linehl = "DiagnosticUnderlineInfo", numhl = "LspDiagnosticsSignInformation", diff --git a/lua/lvim/core/gitsigns.lua b/lua/lvim/core/gitsigns.lua index 0365fc69..43ec7504 100644 --- a/lua/lvim/core/gitsigns.lua +++ b/lua/lvim/core/gitsigns.lua @@ -8,31 +8,31 @@ M.config = function() signs = { add = { hl = "GitSignsAdd", - text = "▎", + text = lvim.icons.ui.BoldLineLeft, numhl = "GitSignsAddNr", linehl = "GitSignsAddLn", }, change = { hl = "GitSignsChange", - text = "▎", + text = lvim.icons.ui.BoldLineLeft, numhl = "GitSignsChangeNr", linehl = "GitSignsChangeLn", }, delete = { hl = "GitSignsDelete", - text = "契", + text = lvim.icons.ui.Triangle, numhl = "GitSignsDeleteNr", linehl = "GitSignsDeleteLn", }, topdelete = { hl = "GitSignsDelete", - text = "契", + text = lvim.icons.ui.Triangle, numhl = "GitSignsDeleteNr", linehl = "GitSignsDeleteLn", }, changedelete = { hl = "GitSignsChange", - text = "▎", + text = lvim.icons.ui.BoldLineLeft, numhl = "GitSignsChangeNr", linehl = "GitSignsChangeLn", }, diff --git a/lua/lvim/core/indentlines.lua b/lua/lvim/core/indentlines.lua index ab316a9b..dc4a72ba 100644 --- a/lua/lvim/core/indentlines.lua +++ b/lua/lvim/core/indentlines.lua @@ -17,7 +17,7 @@ M.config = function() "Trouble", "text", }, - char = "▏", + char = lvim.icons.ui.LineLeft, show_trailing_blankline_indent = false, show_first_indent_level = true, use_treesitter = true, diff --git a/lua/lvim/core/info.lua b/lua/lvim/core/info.lua index da9ddbe6..c413f0f1 100644 --- a/lua/lvim/core/info.lua +++ b/lua/lvim/core/info.lua @@ -25,8 +25,8 @@ local function make_formatters_info(ft) "Formatters info", fmt( "* Active: %s%s", - table.concat(registered_formatters, "  , "), - vim.tbl_count(registered_formatters) > 0 and "  " or "" + table.concat(registered_formatters, " " .. lvim.icons.ui.BoxChecked .. " , "), + vim.tbl_count(registered_formatters) > 0 and " " .. lvim.icons.ui.BoxChecked .. " " or "" ), fmt("* Supported: %s", str_list(supported_formatters)), } @@ -41,8 +41,8 @@ local function make_code_actions_info(ft) "Code actions info", fmt( "* Active: %s%s", - table.concat(registered_actions, "  , "), - vim.tbl_count(registered_actions) > 0 and "  " or "" + table.concat(registered_actions, " " .. lvim.icons.ui.BoxChecked .. " , "), + vim.tbl_count(registered_actions) > 0 and " " .. lvim.icons.ui.BoxChecked .. " " or "" ), } @@ -57,8 +57,8 @@ local function make_linters_info(ft) "Linters info", fmt( "* Active: %s%s", - table.concat(registered_linters, "  , "), - vim.tbl_count(registered_linters) > 0 and "  " or "" + table.concat(registered_linters, " " .. lvim.icons.ui.BoxChecked .. " , "), + vim.tbl_count(registered_linters) > 0 and " " .. lvim.icons.ui.BoxChecked .. " " or "" ), fmt("* Supported: %s", str_list(supported_linters)), } @@ -202,7 +202,7 @@ function M.toggle_popup(ft) vim.fn.matchadd("LvimInfoIdentifier", " " .. ft .. "$") vim.fn.matchadd("string", "true") vim.fn.matchadd("string", "active") - vim.fn.matchadd("string", "") + vim.fn.matchadd("string", lvim.icons.ui.BoxChecked) vim.fn.matchadd("boolean", "inactive") vim.fn.matchadd("error", "false") tbl_set_highlight(require("lvim.lsp.null-ls.formatters").list_registered(ft), "LvimInfoIdentifier") diff --git a/lua/lvim/core/lir.lua b/lua/lvim/core/lir.lua index a47c40b6..af9eb549 100644 --- a/lua/lvim/core/lir.lua +++ b/lua/lvim/core/lir.lua @@ -85,7 +85,7 @@ M.config = function() -- custom folder icon reload("nvim-web-devicons").set_icon { lir_folder_icon = { - icon = "", + icon = lvim.icons.ui.Folder, color = "#42A5F5", name = "LirFolderNode", }, diff --git a/lua/lvim/core/lualine/components.lua b/lua/lvim/core/lualine/components.lua index 5f29d4ef..badece1e 100644 --- a/lua/lvim/core/lualine/components.lua +++ b/lua/lvim/core/lualine/components.lua @@ -21,25 +21,25 @@ vim.api.nvim_set_hl(0, "SLBranchName", { fg = normal_hl.foreground, bg = cursorl vim.api.nvim_set_hl(0, "SLProgress", { fg = "#ECBE7B", bg = statusline_hl.background }) local location_color = nil -local branch = "" -local separator = "│" +local branch = lvim.icons.git.Branch +local separator = lvim.icons.ui.LineMiddle if lvim.colorscheme == "tokyonight" then location_color = "SLBranchName" - branch = "%#SLGitIcon#" .. "" .. "%*" .. "%#SLBranchName#" + branch = "%#SLGitIcon#" .. lvim.icons.git.Branch .. "%*" .. "%#SLBranchName#" local status_ok, tnc = pcall(require, "tokyonight.colors") if status_ok then local tncolors = tnc.setup { transform = true } vim.api.nvim_set_hl(0, "SLSeparator", { fg = cursorline_hl.background, bg = tncolors.black }) - separator = "%#SLSeparator#" .. "│" .. "%*" + separator = "%#SLSeparator#" .. lvim.icons.ui.LineMiddle .. "%*" end end return { mode = { function() - return "  " + return " " .. lvim.icons.ui.Target .. " " end, padding = { left = 0, right = 0 }, color = {}, @@ -58,7 +58,11 @@ return { diff = { "diff", source = diff_source, - symbols = { added = " ", modified = " ", removed = " " }, + symbols = { + added = lvim.icons.git.LineAdded .. " ", + modified = lvim.icons.git.LineModified .. " ", + removed = lvim.icons.git.LineRemoved .. " ", + }, padding = { left = 2, right = 1 }, diff_color = { added = { fg = colors.green }, @@ -73,7 +77,9 @@ return { if vim.bo.filetype == "python" then local venv = os.getenv "CONDA_DEFAULT_ENV" or os.getenv "VIRTUAL_ENV" if venv then - return string.format("  (%s)", utils.env_cleanup(venv)) + local icons = require "nvim-web-devicons" + local py_icon, _ = icons.get_icon ".py" + return string.format(" " .. py_icon .. " (%s)", utils.env_cleanup(venv)) end end return "" @@ -84,12 +90,17 @@ return { diagnostics = { "diagnostics", sources = { "nvim_diagnostic" }, - symbols = { error = " ", warn = " ", info = " ", hint = " " }, + symbols = { + error = lvim.icons.diagnostics.BoldError .. " ", + warn = lvim.icons.diagnostics.BoldWarning .. " ", + info = lvim.icons.diagnostics.BoldInformation .. " ", + hint = lvim.icons.diagnostics.BoldHint .. " ", + }, -- cond = conditions.hide_in_width, }, treesitter = { function() - return "" + return lvim.icons.ui.Tree end, color = function() local buf = vim.api.nvim_get_current_buf() @@ -148,7 +159,7 @@ return { spaces = { function() local shiftwidth = vim.api.nvim_buf_get_option(0, "shiftwidth") - return " " .. shiftwidth + return lvim.icons.ui.Tab .. " " .. shiftwidth end, separator = separator, padding = 1, diff --git a/lua/lvim/core/lualine/styles.lua b/lua/lvim/core/lualine/styles.lua index 0d759c95..8cde37c4 100644 --- a/lua/lvim/core/lualine/styles.lua +++ b/lua/lvim/core/lualine/styles.lua @@ -43,8 +43,14 @@ styles.default = { theme = "auto", globalstatus = true, icons_enabled = lvim.use_icons, - component_separators = { left = "", right = "" }, - section_separators = { left = "", right = "" }, + component_separators = { + left = lvim.icons.ui.DividerRight, + right = lvim.icons.ui.DividerLeft, + }, + section_separators = { + left = lvim.icons.ui.BoldDividerRight, + right = lvim.icons.ui.BoldDividerLeft, + }, disabled_filetypes = {}, }, sections = { diff --git a/lua/lvim/core/notify.lua b/lua/lvim/core/notify.lua index 72133c27..272fdced 100644 --- a/lua/lvim/core/notify.lua +++ b/lua/lvim/core/notify.lua @@ -29,11 +29,11 @@ local defaults = { ---@usage Icons for the different levels icons = { - ERROR = "", - WARN = "", - INFO = "", - DEBUG = "", - TRACE = "✎", + ERROR = lvim.icons.diagnostics.Error, + WARN = lvim.icons.diagnostics.Warning, + INFO = lvim.icons.diagnostics.Information, + DEBUG = lvim.icons.diagnostics.Debug, + TRACE = lvim.icons.diagnostics.Trace, }, }, } diff --git a/lua/lvim/core/nvimtree.lua b/lua/lvim/core/nvimtree.lua index 2d186829..e4b20804 100644 --- a/lua/lvim/core/nvimtree.lua +++ b/lua/lvim/core/nvimtree.lua @@ -20,10 +20,10 @@ function M.config() enable = lvim.use_icons, show_on_dirs = false, icons = { - hint = "", - info = "", - warning = "", - error = "", + hint = lvim.icons.diagnostics.BoldHint, + info = lvim.icons.diagnostics.BoldInformation, + warning = lvim.icons.diagnostics.BoldWarning, + error = lvim.icons.diagnostics.BoldError, }, }, update_focused_file = { @@ -71,23 +71,23 @@ function M.config() folder_arrow = lvim.use_icons, }, glyphs = { - default = "", - symlink = "", + default = lvim.icons.ui.Text, + symlink = lvim.icons.ui.FileSymlink, git = { - unstaged = "", - staged = "S", - unmerged = "", - renamed = "➜", - deleted = "", - untracked = "U", - ignored = "◌", + deleted = lvim.icons.git.FileDeleted, + ignored = lvim.icons.git.FileIgnored, + renamed = lvim.icons.git.FileRenamed, + staged = lvim.icons.git.FileStaged, + unmerged = lvim.icons.git.FileUnmerged, + unstaged = lvim.icons.git.FileUnstaged, + untracked = lvim.icons.git.FileUntracked, }, folder = { - default = "", - open = "", - empty = "", - empty_open = "", - symlink = "", + default = lvim.icons.ui.Folder, + empty = lvim.icons.ui.EmptyFolder, + empty_open = lvim.icons.ui.EmptyFolderOpen, + open = lvim.icons.ui.FolderOpen, + symlink = lvim.icons.ui.FolderSymlink, }, }, }, diff --git a/lua/lvim/core/telescope.lua b/lua/lvim/core/telescope.lua index c1cfd043..6e614dd9 100644 --- a/lua/lvim/core/telescope.lua +++ b/lua/lvim/core/telescope.lua @@ -63,8 +63,8 @@ function M.config() end lvim.builtin.telescope = vim.tbl_extend("force", lvim.builtin.telescope, { defaults = { - prompt_prefix = " ", - selection_caret = " ", + prompt_prefix = lvim.icons.ui.Telescope .. " ", + selection_caret = lvim.icons.ui.Forward .. " ", entry_prefix = " ", initial_mode = "insert", selection_strategy = "reset", diff --git a/lua/lvim/core/which-key.lua b/lua/lvim/core/which-key.lua index 588ecce5..16c9df5e 100644 --- a/lua/lvim/core/which-key.lua +++ b/lua/lvim/core/which-key.lua @@ -22,9 +22,9 @@ M.config = function() spelling = { enabled = true, suggestions = 20 }, -- use which-key for spelling hints }, icons = { - breadcrumb = "»", -- symbol used in the command line area that shows your active key combo - separator = "➜", -- symbol used between a key and it's label - group = "+", -- symbol prepended to a group + breadcrumb = lvim.icons.ui.DoubleChevronRight, -- symbol used in the command line area that shows your active key combo + separator = lvim.icons.ui.BoldArrowRight, -- symbol used between a key and it's label + group = lvim.icons.ui.Plus, -- symbol prepended to a group }, popup_mappings = { scroll_down = "", -- binding to scroll down inside the popup -- cgit v1.2.3