Skip to content

Commit 5cb99f2

Browse files
committed
nvim cpm
1 parent 412f876 commit 5cb99f2

File tree

1 file changed

+41
-32
lines changed

1 file changed

+41
-32
lines changed

config/nvim/lua/plugins/cmp.lua

Lines changed: 41 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -52,35 +52,41 @@ return {
5252
end,
5353
},
5454

55+
sorting = {
56+
priority_weight = 10.0,
57+
comparators = {
58+
cmp.config.compare.score, -- based on : score = score + ((#sources - (source_index - 1)) * sorting.priority_weight)
59+
cmp.config.compare.locality,
60+
cmp.config.compare.recently_used,
61+
cmp.config.compare.offset,
62+
cmp.config.compare.order,
63+
-- cmp.config.compare.kind,
64+
-- compare.exact,
65+
-- compare.scopes, -- what?
66+
-- compare.sort_text,
67+
-- compare.length, -- useless
68+
-- compare.score_offset, -- not good at all
69+
},
70+
},
71+
5572
formatting = {
5673
fields = { 'kind', 'abbr' },
5774
-- fields = { 'kind', 'abbr', 'menu' },
58-
expandable_indicator = true,
59-
format = function(entry, vim_item)
60-
if vim.tbl_contains({ 'path' }, entry.source.name) then
61-
local icon, hl_group = require('nvim-web-devicons').get_icon(entry:completion_item().label)
62-
if icon then
63-
vim_item.kind = icon
64-
vim_item.kind_hl_group = hl_group
65-
return vim_item
66-
end
67-
end
68-
return require('lspkind').cmp_format {
69-
with_text = false,
70-
-- ellipsis_char = '...',
71-
maxwidth = 30,
72-
maxHeight = 18,
73-
}(entry, vim_item)
74-
end,
75-
-- format = require('lspkind').cmp_format {
76-
-- mode = 'symbol_text',
77-
-- maxwidth = 180,
78-
-- maxHeight = 90,
79-
-- ellipsis_char = '...',
80-
-- symbol_map = {
81-
-- Copilot = '',
82-
-- },
83-
-- },
75+
expandable_indicator = false,
76+
format = require('lspkind').cmp_format {
77+
mode = 'symbol',
78+
preset = 'codicons',
79+
-- mode = 'symbol_text',
80+
maxwidth = {
81+
abbr = 30,
82+
menu = 0,
83+
},
84+
maxHeight = 18,
85+
ellipsis_char = '...',
86+
symbol_map = {
87+
Copilot = '',
88+
},
89+
},
8490
},
8591
experimental = {
8692
ghost_text = true,
@@ -120,12 +126,15 @@ return {
120126
-- For more advanced Luasnip keymaps (e.g. selecting choice nodes, expansion) see:
121127
-- https://github.com/L3MON4D3/LuaSnip?tab=readme-ov-file#keymaps
122128
},
123-
sources = {
124-
{ name = 'nvim_lsp' },
125-
{ name = 'copilot' },
126-
{ name = 'path', max_item_count = 7 }, -- file system paths
127-
{ name = 'buffer', max_item_count = 7 }, -- text within current buffer
128-
{ name = 'luasnip', max_item_count = 7 }, -- snippets
129+
sources = cmp.config.sources {
130+
{ name = 'copilot', priority = 10 },
131+
{ name = 'nvim_lsp', priority = 9 },
132+
{ name = 'buffer', priority = 8, max_item_count = 7 }, -- text within current buffer
133+
{ name = 'luasnip', priority = 7, max_item_count = 7 }, -- snippets
134+
{ name = 'path', priority = 6, max_item_count = 7 }, -- file system paths
135+
{ name = 'spell', keyword_length = 3, priority = 5, keyword_pattern = [[\w\+]] },
136+
{ name = 'nerdfont', priority = 3 },
137+
{ name = 'calc', priority = 3 },
129138
{
130139
name = 'lazydev',
131140
-- set group index to 0 to skip loading LuaLS completions as lazydev recommends it

0 commit comments

Comments
 (0)