Procházet zdrojové kódy

fix: statusline and breadcrumbs hls reload with config reload (#3376)

Christian Chiarulli před 2 roky
rodič
revize
6ea5341a84

+ 22 - 0
lua/lvim/core/autocmds.lua

@@ -99,6 +99,28 @@ function M.load_defaults()
         end,
       },
     },
+    {
+      "ColorScheme",
+      {
+        group = "_lvim_colorscheme",
+        callback = function()
+          if lvim.builtin.breadcrumbs.active then
+            require("lvim.core.breadcrumbs").get_winbar()
+          end
+          local statusline_hl = vim.api.nvim_get_hl_by_name("StatusLine", true)
+          local cursorline_hl = vim.api.nvim_get_hl_by_name("CursorLine", true)
+          local normal_hl = vim.api.nvim_get_hl_by_name("Normal", true)
+          vim.api.nvim_set_hl(0, "CmpItemKindCopilot", { fg = "#6CC644" })
+          vim.api.nvim_set_hl(0, "CmpItemKindTabnine", { fg = "#CA42F0" })
+          vim.api.nvim_set_hl(0, "CmpItemKindCrate", { fg = "#F64D00" })
+          vim.api.nvim_set_hl(0, "CmpItemKindEmoji", { fg = "#FDE030" })
+          vim.api.nvim_set_hl(0, "SLCopilot", { fg = "#6CC644", bg = statusline_hl.background })
+          vim.api.nvim_set_hl(0, "SLGitIcon", { fg = "#E8AB53", bg = cursorline_hl.background })
+          vim.api.nvim_set_hl(0, "SLBranchName", { fg = normal_hl.foreground, bg = cursorline_hl.background })
+          vim.api.nvim_set_hl(0, "SLSeparator", { fg = cursorline_hl.background, bg = statusline_hl.background })
+        end,
+      },
+    },
   }
 
   M.define_autocmds(definitions)

+ 0 - 5
lua/lvim/core/cmp.lua

@@ -172,20 +172,16 @@ M.config = function()
         if lvim.use_icons then
           vim_item.kind = lvim.builtin.cmp.formatting.kind_icons[vim_item.kind]
 
-          -- TODO: not sure why I can't put this anywhere else
-          vim.api.nvim_set_hl(0, "CmpItemKindCopilot", { fg = "#6CC644" })
           if entry.source.name == "copilot" then
             vim_item.kind = lvim.icons.git.Octoface
             vim_item.kind_hl_group = "CmpItemKindCopilot"
           end
 
-          vim.api.nvim_set_hl(0, "CmpItemKindTabnine", { fg = "#CA42F0" })
           if entry.source.name == "cmp_tabnine" then
             vim_item.kind = lvim.icons.misc.Robot
             vim_item.kind_hl_group = "CmpItemKindTabnine"
           end
 
-          vim.api.nvim_set_hl(0, "CmpItemKindCrate", { fg = "#F64D00" })
           if entry.source.name == "crates" then
             vim_item.kind = lvim.icons.misc.Package
             vim_item.kind_hl_group = "CmpItemKindCrate"
@@ -196,7 +192,6 @@ M.config = function()
             vim_item.kind_hl_group = "CmpItemKindConstant"
           end
 
-          vim.api.nvim_set_hl(0, "CmpItemKindEmoji", { fg = "#FDE030" })
           if entry.source.name == "emoji" then
             vim_item.kind = lvim.icons.misc.Smiley
             vim_item.kind_hl_group = "CmpItemKindEmoji"

+ 0 - 7
lua/lvim/core/lualine/components.lua

@@ -12,14 +12,7 @@ local function diff_source()
   end
 end
 
-local statusline_hl = vim.api.nvim_get_hl_by_name("StatusLine", true)
 local cursorline_hl = vim.api.nvim_get_hl_by_name("CursorLine", true)
-local normal_hl = vim.api.nvim_get_hl_by_name("Normal", true)
-
-vim.api.nvim_set_hl(0, "SLCopilot", { fg = "#6CC644", bg = statusline_hl.background })
-vim.api.nvim_set_hl(0, "SLGitIcon", { fg = "#E8AB53", bg = cursorline_hl.background })
-vim.api.nvim_set_hl(0, "SLBranchName", { fg = normal_hl.foreground, bg = cursorline_hl.background })
-vim.api.nvim_set_hl(0, "SLProgress", { fg = "#ECBE7B", bg = statusline_hl.background })
 
 local location_color = nil
 local branch = lvim.icons.git.Branch