diff options
author | Squibid <me@zacharyscheiman.com> | 2024-03-09 00:24:27 -0500 |
---|---|---|
committer | Squibid <me@zacharyscheiman.com> | 2024-03-09 00:24:27 -0500 |
commit | f320dd6012a38cb38c4670985f2af64cb061d909 (patch) | |
tree | 73cb16b20f5e836ad11bca83606a4f2c9649a78d | |
parent | 805df629dc7fa1a352adc8b7897cf3e1842d5d26 (diff) | |
download | nvim-f320dd6012a38cb38c4670985f2af64cb061d909.tar.gz nvim-f320dd6012a38cb38c4670985f2af64cb061d909.tar.bz2 nvim-f320dd6012a38cb38c4670985f2af64cb061d909.zip |
improve completion config
- show what we are completing from with symbol on left
- improving results ordering
-rw-r--r-- | after/plugin/cmp.lua | 44 |
1 files changed, 33 insertions, 11 deletions
diff --git a/after/plugin/cmp.lua b/after/plugin/cmp.lua index 71cc254..415b318 100644 --- a/after/plugin/cmp.lua +++ b/after/plugin/cmp.lua @@ -15,35 +15,57 @@ local neogen = require('neogen') require("luasnip.loaders.from_vscode").lazy_load() cmp.setup { - snippet = { - expand = function(args) - luasnip.lsp_expand(args.body) - end, - }, - sources = cmp.config.sources({ - { name = 'nvim_lsp', keyword_length = 3 }, + { name = 'nvim_lsp', priority = 999 }, + { name = 'luasnip_choice', priority = 750 }, + { name = 'buffer', max_item_count = 3 }, + { name = 'async_path', max_item_count = 5 }, { name = 'nvim_lua' }, - { name = 'luasnip_choice' }, - { name = 'async_path' }, - { name = 'buffer', keyword_length = 3, max_item_count = 7 }, - { name = 'calc' }, { name = 'neorg' }, + { name = 'calc' }, + { name = 'cmdline' }, }), + window = { completion = { + scrollbar = false, border = { ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ' }, winhighlight = "Normal:WinBarNC,FloatBorder:WinBarNC,Search:WinBarNC", }, documentation = { + max_width = 80, border = { ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ' }, winhighlight = "Normal:WinBarNC,FloatBorder:WinBarNC,Search:WinBarNC", } }, + view = { entries = { name = 'custom', selection_order = 'near_cursor' }, }, + formatting = { + fields = {'menu', 'abbr', 'kind'}, + format = function(entry, item) + local menu_icon = { + nvim_lsp = 'λ', + nvim_lua = 'v', + calc = '+', + luasnip = '%', + buffer = '@', + path = '#', + } + + item.menu = menu_icon[entry.source.name] + return item + end, + }, + + snippet = { + expand = function(args) + luasnip.lsp_expand(args.body) + end, + }, + -- mappings ----------------------------------------------------------------- mapping = cmp.mapping.preset.insert({ ["<Tab>"] = cmp.mapping(function(fallback) |