From a7b8f061958d06eab7ddde101b3cc4ce94f48fee Mon Sep 17 00:00:00 2001 From: PowerUser64 Date: Fri, 19 Aug 2022 01:09:56 -0700 Subject: [PATCH] nvim: rework completion menu -- big change I'm excited about :D --- .config/nvim/lua/blake/lsp.lua | 41 +++++++++++++++------------------- 1 file changed, 18 insertions(+), 23 deletions(-) diff --git a/.config/nvim/lua/blake/lsp.lua b/.config/nvim/lua/blake/lsp.lua index a9cbb82..3cb96e9 100644 --- a/.config/nvim/lua/blake/lsp.lua +++ b/.config/nvim/lua/blake/lsp.lua @@ -150,34 +150,32 @@ M.cmp = function() { name = 'path' }, }, formatting = { + fields = { "abbr", "kind", "menu" }, format = function(entry, vim_item) -- fancy icons and a name of kind - require('lspkind').cmp_format({ - mode = 'symbol', -- show only symbol annotations - maxwidth = 50, -- prevent the popup from showing more than provided characters (e.g 50 will not show more than 50 characters) - - -- The function below will be called before any actual modifications from lspkind - -- so that you can provide more controls on popup customization. (See [#30](https://github.com/onsails/lspkind-nvim/pull/30)) - -- before = function (entry, vim_item) - -- ... - -- return vim_item - -- end - }) + local kind = require("lspkind").cmp_format({ mode = "symbol", maxwidth = 50 })(entry, vim_item) + -- local strings = vim.split(kind.kind, "%s", { trimempty = true }) -- set a name for each source + vim_item.kind = " " .. kind.kind vim_item.menu = ({ - path = "[Path]", - nvim_lua = "[Lua]", - nvim_lsp = "[LSP]", - treesitter = "[TS]", - calc = "[Calc]", - spell = "[Spell]", - cmdline = "[cmdline]", - buffer = "[Buffer]", - })[entry.source.name] + path = "[path]", + emoji = "[emoji]", + nvim_lua = "[lua]", + nvim_lsp = "[lsp]", + treesitter = "[ts]", + calc = "[calc]", + spell = "[spell]", + cmdline = "[cmd]", + buffer = "[buf]", + luasnip = "[snip]", + })[entry.source.name] or "unknown type" return vim_item end, }, window = { + completion = { + winhighlight = "Normal:Pmenu,FloatBorder:Pmenu,Search:None", + }, documentation = { border = { "╭", "─", "╮", "│", "╯", "─", "╰", "│" }, }, @@ -186,7 +184,6 @@ M.cmp = function() ghost_text = true, } } - -- Thanks to iwataka on github for this bit local search_config = { mapping = cmp.mapping.preset.cmdline(), @@ -194,11 +191,9 @@ M.cmp = function() { name = 'buffer' }, } } - -- Use buffer source for `/` and `?` cmp.setup.cmdline('/', search_config) cmp.setup.cmdline('?', search_config) - -- `:` cmdline setup. cmp.setup.cmdline(':', { mapping = cmp.mapping.preset.cmdline(),