mirror of
https://github.com/pnx/dotfiles
synced 2026-06-18 12:00:02 +02:00
nvim: make cmp more nice
This commit is contained in:
parent
88a7cf21f8
commit
906bcdef24
1 changed files with 19 additions and 11 deletions
|
|
@ -1,3 +1,5 @@
|
||||||
|
local icons = require('config.icons')
|
||||||
|
|
||||||
return {
|
return {
|
||||||
'hrsh7th/nvim-cmp',
|
'hrsh7th/nvim-cmp',
|
||||||
version = false,
|
version = false,
|
||||||
|
|
@ -10,16 +12,24 @@ return {
|
||||||
'onsails/lspkind-nvim',
|
'onsails/lspkind-nvim',
|
||||||
},
|
},
|
||||||
opts = function()
|
opts = function()
|
||||||
|
local lspkind_config = {
|
||||||
|
mode = 'symbol',
|
||||||
|
preset = 'codicons',
|
||||||
|
symbol_map = icons.symbols,
|
||||||
|
maxwidth = 40,
|
||||||
|
ellipsis_char = "...",
|
||||||
|
}
|
||||||
|
|
||||||
local cmp = require('cmp')
|
local cmp = require('cmp')
|
||||||
vim.api.nvim_set_hl(0, "CmpGhostText", { link = "NonText", default = true })
|
vim.api.nvim_set_hl(0, "CmpGhostText", { link = "NonText", default = true })
|
||||||
|
|
||||||
local selectPrev = cmp.mapping.select_prev_item({ behavior = cmp.SelectBehavior.Insert })
|
local selectPrev = cmp.mapping.select_prev_item({ behavior = cmp.SelectBehavior.Insert })
|
||||||
local selectNext = cmp.mapping.select_next_item({ behavior = cmp.SelectBehavior.Insert })
|
local selectNext = cmp.mapping.select_next_item({ behavior = cmp.SelectBehavior.Insert })
|
||||||
|
|
||||||
local border = cmp.config.window.bordered({
|
local borderstyle = {
|
||||||
-- border = {'┌', '─', '┐', '│', '┘', '─', '└', '│'},
|
border = "none",
|
||||||
winhighlight = 'Normal:NormalFloat,FloatBorder:FloatBorder,CursorLine:PmenuSel,Search:None'
|
winhighlight = 'Normal:Pmenu,FloatBorder:FloatBorder,CursorLine:PmenuSel,Search:None',
|
||||||
})
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
completion = {
|
completion = {
|
||||||
|
|
@ -37,8 +47,8 @@ return {
|
||||||
entries = { name = 'custom', selection_order = 'near_cursor' },
|
entries = { name = 'custom', selection_order = 'near_cursor' },
|
||||||
},
|
},
|
||||||
window = {
|
window = {
|
||||||
documentation = border,
|
documentation = borderstyle,
|
||||||
completion = border
|
completion = borderstyle
|
||||||
},
|
},
|
||||||
mapping = {
|
mapping = {
|
||||||
["<Up>"] = selectPrev,
|
["<Up>"] = selectPrev,
|
||||||
|
|
@ -54,7 +64,7 @@ return {
|
||||||
end,
|
end,
|
||||||
},
|
},
|
||||||
formatting = {
|
formatting = {
|
||||||
fields = { "abbr", "menu", "kind" },
|
fields = { "abbr", "kind", "menu" },
|
||||||
format = function(entry, vim_item)
|
format = function(entry, vim_item)
|
||||||
if vim.tbl_contains({ 'path' }, entry.source.name) then
|
if vim.tbl_contains({ 'path' }, entry.source.name) then
|
||||||
local icon, hl_group = require('nvim-web-devicons').get_icon(entry:get_completion_item().label)
|
local icon, hl_group = require('nvim-web-devicons').get_icon(entry:get_completion_item().label)
|
||||||
|
|
@ -65,13 +75,11 @@ return {
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local opts = {
|
return require('lspkind').cmp_format(lspkind_config)(entry, vim_item)
|
||||||
mode = 'symbol',
|
|
||||||
}
|
|
||||||
return require('lspkind').cmp_format(opts)(entry, vim_item)
|
|
||||||
end
|
end
|
||||||
},
|
},
|
||||||
sources = {
|
sources = {
|
||||||
|
{ name = "copilot" },
|
||||||
{ name = 'nvim_lsp' },
|
{ name = 'nvim_lsp' },
|
||||||
{ name = 'buffer' },
|
{ name = 'buffer' },
|
||||||
{ name = 'path' },
|
{ name = 'path' },
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue