diff --git a/neovim/lua/icons.lua b/neovim/lua/icons.lua new file mode 100644 index 0000000..b5fd004 --- /dev/null +++ b/neovim/lua/icons.lua @@ -0,0 +1,70 @@ +local M = {} + +function M.init() + if vim.env["TERM_NERD_FONT"] == "1" then + M.nerd_font = true + else + M.nerd_font = false + end + + -- Diagnostics signs + if vim.env["TERM"] == "xterm-kitty" then + -- Don't use double width emoji for Kitty + M.diagnostic_signs = { + Error = "đŸ”Ĩ", + Warn = "⚠", + Hint = "🤔", + Info = "i", + Pencil = "✎", + } + else + M.diagnostic_signs = { + Error = "đŸ”Ĩ", + Warn = "⚠ī¸", + Hint = "🤔", + Info = "➞", + Pencil = "✏ī¸", + } + end + + -- Debug icons + M.debug_icons = { + breakpoint = "🛑", + conditional_breakpoint = "🔍", + log_point = "📝", + current = "👉", + breakpoint_rejected = "đŸšĢ", + } + + -- Debug control icons + if vim.env["TERM"] == "xterm-kitty" then + -- Don't use double width emoji for Kitty + M.debug_control_icons = { + disconnect = "⏏", + pause = "⏸", + play = "â–ļ", + run_last = "⏎", + step_back = "◀", + step_into = "â¤ĩ", + step_out = "⤴", + step_over = "⏭", + terminate = "⏚", + } + else + M.debug_control_icons = { + disconnect = "⏏ī¸", + pause = "⏸ī¸", + play = "â–ļī¸", + run_last = "⏎ī¸", + step_back = "◀ī¸", + step_into = "â¤ĩī¸", + step_out = "⤴ī¸", + step_over = "⏭ī¸", + terminate = "⏚ī¸", + } + end +end + +M.init() + +return M diff --git a/neovim/lua/lazy_plugins.lua b/neovim/lua/lazy_plugins.lua index 786f1c5..c7766ec 100644 --- a/neovim/lua/lazy_plugins.lua +++ b/neovim/lua/lazy_plugins.lua @@ -66,6 +66,9 @@ return { opts = { -- Ignore warnings about config. Turn these on when switching major versions notify = false, + icons = { + mappings = require("icons").nerd_font, + }, }, version = utils.map_version_rule({ [">=0.9.4"] = "3.x.x", @@ -247,24 +250,26 @@ return { -- dap_mapping("r", dap.repl.open, { desc = "Open REPL" }) -- dap_mapping("R", dap.repl.run_last, { desc = "Run last" }) + local icons = require("icons") + -- Set dap signs vim.fn.sign_define( "DapBreakpoint", - { text = utils.debug_icons.breakpoint, texthl = "", linehl = "", numhl = "" } + { text = icons.debug_icons.breakpoint, texthl = "", linehl = "", numhl = "" } ) vim.fn.sign_define( "DapLogPoint", - { text = utils.debug_icons.log_point, texthl = "", linehl = "", numhl = "" } + { text = icons.debug_icons.log_point, texthl = "", linehl = "", numhl = "" } ) vim.fn.sign_define( "DapBreakpointCondition", - { text = utils.debug_icons.conditional_breakpoint, texthl = "", linehl = "", numhl = "" } + { text = icons.debug_icons.conditional_breakpoint, texthl = "", linehl = "", numhl = "" } ) - vim.fn.sign_define("DapStopped", { text = utils.debug_icons.current, texthl = "", linehl = "", numhl = "" }) + vim.fn.sign_define("DapStopped", { text = icons.debug_icons.current, texthl = "", linehl = "", numhl = "" }) vim.fn.sign_define( "DapBreakpointRejected", - { text = utils.debug_icons.breakpoint_rejected, texthl = "", linehl = "", numhl = "" } + { text = icons.debug_icons.breakpoint_rejected, texthl = "", linehl = "", numhl = "" } ) end, lazy = true, @@ -284,7 +289,7 @@ return { current_frame = ">", }, controls = { - icons = utils.debug_control_icons, + icons = require("icons").debug_control_icons, }, }) local dap, dapui = require("dap"), require("dapui") diff --git a/neovim/lua/plugins/lsp.lua b/neovim/lua/plugins/lsp.lua index 68ab37b..5ed0718 100644 --- a/neovim/lua/plugins/lsp.lua +++ b/neovim/lua/plugins/lsp.lua @@ -21,7 +21,7 @@ function M.config_lsp_ui() end -- Diagnostics signs - for type, icon in pairs(utils.diagnostic_signs) do + for type, icon in pairs(require("icons").diagnostic_signs) do local hl = "DiagnosticSign" .. type vim.fn.sign_define(hl, { text = icon, texthl = hl, numhl = hl }) end @@ -30,7 +30,7 @@ function M.config_lsp_ui() trouble.setup({ fold_open = "â–ŧ", fold_closed = "â–ļ", - icons = false, + icons = require("icons").nerd_font, use_diagnostic_signs = true, }) end) diff --git a/neovim/lua/plugins/lualine.lua b/neovim/lua/plugins/lualine.lua index f92ba49..e5164ff 100644 --- a/neovim/lua/plugins/lualine.lua +++ b/neovim/lua/plugins/lualine.lua @@ -58,8 +58,9 @@ function M.config_lualine(theme_name) -- navic local code_loc = {} utils.try_require("nvim-navic", function(navic) - navic.setup({ - icons = { + local opts = {} + if not require("icons").nerd_font then + opts.icons = { Array = "𝐴 ", Boolean = "đĩ ", Class = "ℂ ", @@ -86,15 +87,17 @@ function M.config_lualine(theme_name) Struct = "𝑆 ", TypeParameter = "𝑇𝑃 ", Variable = "𝑉 ", - }, - }) + } + end + + navic.setup(opts) code_loc = { "navic" } end) require("lualine").setup({ options = { theme = theme_name, - icons_enabled = false, + icons_enabled = require("icons").nerd_font, component_separators = { left = "|", right = "|" }, section_separators = { left = "", right = "" }, }, diff --git a/neovim/lua/plugins/notify.lua b/neovim/lua/plugins/notify.lua index b701ae4..9a4398b 100644 --- a/neovim/lua/plugins/notify.lua +++ b/neovim/lua/plugins/notify.lua @@ -1,14 +1,14 @@ local utils = require("utils") - local notify = require("notify") +local icons = require("icons") notify.setup({ icons = { - ERROR = utils.diagnostic_signs.Error, - WARN = utils.diagnostic_signs.Warn, - DEBUG = utils.diagnostic_signs.Hint, - TRACE = utils.diagnostic_signs.Pencil, - INFO = utils.diagnostic_signs.Info, + ERROR = icons.diagnostic_signs.Error, + WARN = icons.diagnostic_signs.Warn, + DEBUG = icons.diagnostic_signs.Hint, + TRACE = icons.diagnostic_signs.Pencil, + INFO = icons.diagnostic_signs.Info, }, }) diff --git a/neovim/lua/plugins/todo.lua b/neovim/lua/plugins/todo.lua index 4f3a045..40cf040 100644 --- a/neovim/lua/plugins/todo.lua +++ b/neovim/lua/plugins/todo.lua @@ -1,4 +1,4 @@ -local utils = require("utils") +local icons = require("icons") require("todo-comments").setup({ signs = false, @@ -7,7 +7,7 @@ require("todo-comments").setup({ icon = "🩹", }, TODO = { - icon = utils.diagnostic_signs.Pencil, + icon = icons.diagnostic_signs.Pencil, }, HACK = { icon = "🙈", @@ -19,7 +19,7 @@ require("todo-comments").setup({ icon = "📓", }, WARNING = { - icon = utils.diagnostic_signs.Warn, + icon = icons.diagnostic_signs.Warn, }, }, }) diff --git a/neovim/lua/utils.lua b/neovim/lua/utils.lua index 72d2749..3c30084 100644 --- a/neovim/lua/utils.lua +++ b/neovim/lua/utils.lua @@ -178,58 +178,4 @@ function M.curry_keymap(mode, prefix, default_opts) end end --- Diagnostics signs -M.diagnostic_signs = { - Error = "đŸ”Ĩ", - Warn = "⚠ī¸", - Hint = "🤔", - Info = "➞", - Pencil = "✏ī¸", -} - --- Don't use emoji for Kitty -if vim.env["TERM"] == "xterm-kitty" then - M.diagnostic_signs = { - Error = "đŸ”Ĩ", - Warn = "⚠", - Hint = "🤔", - Info = "i", - Pencil = "✎", - } -end - -M.debug_icons = { - breakpoint = "🛑", - conditional_breakpoint = "🔍", - log_point = "📝", - current = "👉", - breakpoint_rejected = "đŸšĢ", -} - -M.debug_control_icons = { - disconnect = "⏏ī¸", - pause = "⏸ī¸", - play = "â–ļī¸", - run_last = "⏎ī¸", - step_back = "◀ī¸", - step_into = "â¤ĩī¸", - step_out = "⤴ī¸", - step_over = "⏭ī¸", - terminate = "⏚ī¸", -} - -if vim.env["TERM"] == "xterm-kitty" then - M.debug_control_icons = { - disconnect = "⏏", - pause = "⏸", - play = "â–ļ", - run_last = "⏎", - step_back = "◀", - step_into = "â¤ĩ", - step_out = "⤴", - step_over = "⏭", - terminate = "⏚", - } -end - return M