From 6963902a2bc73b90892b859097496ff5146564f9 Mon Sep 17 00:00:00 2001 From: zackartz Date: Thu, 18 Apr 2024 15:22:08 -0400 Subject: [PATCH] 414 current 2024-04-18 15:22:07 24.05.20240418.2948912 6.8.6-zen1 nvidiaProduction nvidiaStable nvidiaVulkanBeta --- .../config/lua/plugins/editor/nvim-cmp.lua | 62 +++++++------------ 1 file changed, 23 insertions(+), 39 deletions(-) diff --git a/modules/home-manager/vim/config/lua/plugins/editor/nvim-cmp.lua b/modules/home-manager/vim/config/lua/plugins/editor/nvim-cmp.lua index 7bfb0ae..11fe5f2 100644 --- a/modules/home-manager/vim/config/lua/plugins/editor/nvim-cmp.lua +++ b/modules/home-manager/vim/config/lua/plugins/editor/nvim-cmp.lua @@ -1,31 +1,3 @@ -local lsp_symbols = { - Text = "  (Text) ", - Method = "  (Method)", - Function = "  (Function)", - Constructor = "  (Constructor)", - Field = " ﴲ (Field)", - Variable = "[] (Variable)", - Class = "  (Class)", - Interface = " ﰮ (Interface)", - Module = "  (Module)", - Property = " 襁 (Property)", - Unit = "  (Unit)", - Value = "  (Value)", - Enum = " 練 (Enum)", - Keyword = "  (Keyword)", - Snippet = "  (Snippet)", - Color = "  (Color)", - File = "  (File)", - Reference = "  (Reference)", - Folder = "  (Folder)", - EnumMember = "  (EnumMember)", - Constant = " ﲀ (Constant)", - Struct = " ﳤ (Struct)", - Event = "  (Event)", - Operator = "  (Operator)", - TypeParameter = "  (TypeParameter)", -} - return { { "L3MON4D3/LuaSnip", @@ -129,17 +101,29 @@ return { end, { "i", "s" }), }, formatting = { - format = function(entry, item) - item.kind = lsp_symbols[item.kind] - item.menu = ({ - buffer = "[Buffer]", - nvim_lsp = "[LSP]", - luasnip = "[Snippet]", - neorg = "[Neorg]", - })[entry.source.name] - - return item - end, + format = lspkind_status_ok and lspkind.cmp_format({ + mode = "symbol", + maxwidth = 25, + ellipsis_char = "...", + before = function(entry, vim_item) + if vim_item.kind == "Color" and entry.completion_item.documentation then + local _, _, r, g, b = + string.find(entry.completion_item.documentation, "^rgb%((%d+), (%d+), (%d+)") + if r then + local color = string.format("%02x", r) + .. string.format("%02x", g) + .. string.format("%02x", b) + local group = "Tw_" .. color + if vim.fn.hlID(group) < 1 then + vim.api.nvim_set_hl(0, group, { fg = "#" .. color }) + end + vim_item.kind_hl_group = group + return vim_item + end + end + return vim_item + end, + }), }, } end,