forked from dineshsalunke/nvim-config
refactor: add lspkind
This commit is contained in:
parent
8023cda180
commit
4c137ac067
@ -35,14 +35,33 @@ return {
|
||||
dependencies = {
|
||||
"hrsh7th/cmp-nvim-lsp",
|
||||
"hrsh7th/cmp-buffer",
|
||||
"hrsh7th/cmp-nvim-lua",
|
||||
"mtoohey31/cmp-fish",
|
||||
"hrsh7th/cmp-path",
|
||||
"saadparwaiz1/cmp_luasnip",
|
||||
"hrsh7th/cmp-nvim-lsp-signature-help",
|
||||
"onsails/lspkind.nvim",
|
||||
},
|
||||
opts = function()
|
||||
vim.api.nvim_set_hl(0, "CmpGhostText", { link = "Comment", default = true })
|
||||
local cmp = require("cmp")
|
||||
local border_opts = {
|
||||
border = "single",
|
||||
winhighlight = "Normal:Normal,FloatBorder:FloatBorder,CursorLine:Visual,Search:None",
|
||||
}
|
||||
return {
|
||||
formatting = {
|
||||
fields = {
|
||||
"abbr",
|
||||
"kind",
|
||||
"menu",
|
||||
},
|
||||
format = require("lspkind").cmp_format({
|
||||
mode = "symbol",
|
||||
maxwidth = 50,
|
||||
ellipsis_char = "...",
|
||||
}),
|
||||
},
|
||||
completion = {
|
||||
completeopt = "menu,menuone,noinsert",
|
||||
},
|
||||
@ -52,19 +71,23 @@ return {
|
||||
end,
|
||||
},
|
||||
mapping = cmp.mapping.preset.insert({
|
||||
["<C-j>"] = cmp.mapping.select_next_item({ behavior = cmp.SelectBehavior.Insert }),
|
||||
["<C-k>"] = cmp.mapping.select_prev_item({ behavior = cmp.SelectBehavior.Insert }),
|
||||
["<C-j>"] = cmp.mapping.select_next_item({ behavior = cmp.SelectBehavior.Select }),
|
||||
["<C-k>"] = cmp.mapping.select_prev_item({ behavior = cmp.SelectBehavior.Select }),
|
||||
["<C-Space>"] = cmp.mapping.complete(),
|
||||
["<C-e>"] = cmp.mapping.abort(),
|
||||
["<CR>"] = cmp.mapping.confirm({ behavior = cmp.SelectBehavior.Replace, select = true }),
|
||||
}),
|
||||
sources = cmp.config.sources({
|
||||
{ name = "path" },
|
||||
{ name = "nvim_lsp" },
|
||||
{ name = "buffer", keyword_length = 5 },
|
||||
{ name = "luasnip", keyword_length = 3 },
|
||||
{ name = "nvim_lsp_signature_help" },
|
||||
{ name = "luasnip", keyword_length = 3 },
|
||||
{ name = "buffer", keyword_length = 5 },
|
||||
{ name = "path" },
|
||||
}),
|
||||
window = {
|
||||
completion = cmp.config.window.bordered(border_opts),
|
||||
documentation = cmp.config.window.bordered(border_opts),
|
||||
},
|
||||
}
|
||||
end,
|
||||
},
|
||||
|
Loading…
x
Reference in New Issue
Block a user