improve completion config
- show what we are completing from with symbol on left - improving results ordering
This commit is contained in:
@ -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)
|
||||
|
Reference in New Issue
Block a user