refactor: add lspkind

This commit is contained in:
Dinesh Salunke 2023-06-26 23:23:11 +05:30
parent 8023cda180
commit 4c137ac067

View File

@ -35,14 +35,33 @@ return {
dependencies = { dependencies = {
"hrsh7th/cmp-nvim-lsp", "hrsh7th/cmp-nvim-lsp",
"hrsh7th/cmp-buffer", "hrsh7th/cmp-buffer",
"hrsh7th/cmp-nvim-lua",
"mtoohey31/cmp-fish",
"hrsh7th/cmp-path", "hrsh7th/cmp-path",
"saadparwaiz1/cmp_luasnip", "saadparwaiz1/cmp_luasnip",
"hrsh7th/cmp-nvim-lsp-signature-help", "hrsh7th/cmp-nvim-lsp-signature-help",
"onsails/lspkind.nvim",
}, },
opts = function() opts = function()
vim.api.nvim_set_hl(0, "CmpGhostText", { link = "Comment", default = true }) vim.api.nvim_set_hl(0, "CmpGhostText", { link = "Comment", default = true })
local cmp = require("cmp") local cmp = require("cmp")
local border_opts = {
border = "single",
winhighlight = "Normal:Normal,FloatBorder:FloatBorder,CursorLine:Visual,Search:None",
}
return { return {
formatting = {
fields = {
"abbr",
"kind",
"menu",
},
format = require("lspkind").cmp_format({
mode = "symbol",
maxwidth = 50,
ellipsis_char = "...",
}),
},
completion = { completion = {
completeopt = "menu,menuone,noinsert", completeopt = "menu,menuone,noinsert",
}, },
@ -52,19 +71,23 @@ return {
end, end,
}, },
mapping = cmp.mapping.preset.insert({ mapping = cmp.mapping.preset.insert({
["<C-j>"] = cmp.mapping.select_next_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.Insert }), ["<C-k>"] = cmp.mapping.select_prev_item({ behavior = cmp.SelectBehavior.Select }),
["<C-Space>"] = cmp.mapping.complete(), ["<C-Space>"] = cmp.mapping.complete(),
["<C-e>"] = cmp.mapping.abort(), ["<C-e>"] = cmp.mapping.abort(),
["<CR>"] = cmp.mapping.confirm({ behavior = cmp.SelectBehavior.Replace, select = true }), ["<CR>"] = cmp.mapping.confirm({ behavior = cmp.SelectBehavior.Replace, select = true }),
}), }),
sources = cmp.config.sources({ sources = cmp.config.sources({
{ name = "path" },
{ name = "nvim_lsp" }, { name = "nvim_lsp" },
{ name = "buffer", keyword_length = 5 },
{ name = "luasnip", keyword_length = 3 },
{ name = "nvim_lsp_signature_help" }, { 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, end,
}, },