diff options
Diffstat (limited to '.config/nvim/lua/plugins/lspkind.lua')
| -rw-r--r-- | .config/nvim/lua/plugins/lspkind.lua | 83 |
1 files changed, 83 insertions, 0 deletions
diff --git a/.config/nvim/lua/plugins/lspkind.lua b/.config/nvim/lua/plugins/lspkind.lua new file mode 100644 index 0000000..2a5165f --- /dev/null +++ b/.config/nvim/lua/plugins/lspkind.lua @@ -0,0 +1,83 @@ +return { + { + 'onsails/lspkind.nvim', + config = function() + require('lspkind').setup({ + mode = 'text', + preset = 'default', + }) + end + }, + { + "hrsh7th/nvim-cmp", + dependencies = { + "onsails/lspkind.nvim", + "hrsh7th/cmp-nvim-lsp", + "hrsh7th/cmp-buffer", + "hrsh7th/cmp-path", + "L3MON4D3/LuaSnip", + }, + event = "InsertEnter", + config = function() + vim.api.nvim_set_hl(0, "CmpNormal", { bg = "#32302f" }) + vim.api.nvim_set_hl(0, "PmenuSel", { bg = "#504945" }) + local cmp = require('cmp') + local lspkind = require('lspkind') + + cmp.setup({ + snippet = { + expand = function(args) + require('luasnip').lsp_expand(args.body) + end, + }, + formatting = { + format = lspkind.cmp_format({ + mode = 'text', + maxwidth = { + menu = 50, + abbr = 50, + }, + ellipsis_char = '...', + show_labelDetails = true, + before = function(entry, vim_item) + -- Add source name to menu + vim_item.menu = ({ + nvim_lsp = "[LSP]", + luasnip = "[LuaSnip]", + buffer = "[Buffer]", + path = "[Path]", + })[entry.source.name] + return vim_item + end + }) + }, + mapping = cmp.mapping.preset.insert({ + ['<C-j>'] = cmp.mapping.select_next_item(cmp_select), + ['<C-k>'] = cmp.mapping.select_prev_item(cmp_select), + ['<C-b>'] = cmp.mapping.scroll_docs(-4), + ['<C-f>'] = cmp.mapping.scroll_docs(4), + ['<C-Space>'] = cmp.mapping.complete(), + ['<C-e>'] = cmp.mapping.abort(), + ['<CR>'] = cmp.mapping.confirm({ select = true }), + }), + sources = cmp.config.sources({ + { name = 'nvim_lsp' }, + { name = 'luasnip' }, + }, { + { name = 'buffer' }, + { name = 'path' }, + }), + window = { + completion = { + border = 'none', + winhighlight = "Normal:CmpNormal,FloatBorder:CmpNormal,CursorLine:PmenuSel,Search:None", + }, + documentation = { + border = 'none', + winhighlight = "Normal:CmpNormal,FloatBorder:CmpNormal,CursorLine:PmenuSel,Search:None", + }, + }, + }) + end, + }, +} |
