style cmp window

This commit is contained in:
andrzej 2024-05-03 20:01:31 +02:00
parent 857a4f16b7
commit 939e4ae8e8
1 changed files with 36 additions and 0 deletions

View File

@ -37,9 +37,11 @@ return { -- Autocompletion
-- into multiple repos for maintenance purposes. -- into multiple repos for maintenance purposes.
"hrsh7th/cmp-nvim-lsp", "hrsh7th/cmp-nvim-lsp",
"hrsh7th/cmp-path", "hrsh7th/cmp-path",
"onsails/lspkind.nvim",
}, },
config = function() config = function()
-- See `:help cmp` -- See `:help cmp`
local lspkind = require("lspkind")
local cmp = require("cmp") local cmp = require("cmp")
local luasnip = require("luasnip") local luasnip = require("luasnip")
luasnip.config.setup({}) luasnip.config.setup({})
@ -115,6 +117,40 @@ return { -- Autocompletion
{ name = "luasnip" }, { name = "luasnip" },
{ name = "path" }, { name = "path" },
}, },
formatting = {
fields = { "kind", "abbr", "menu" },
expandable_indicator = true,
format = lspkind.cmp_format({
mode = "symbol_text", -- show only symbol annotations
menu = {
buffer = "[Buffer]",
nvim_lsp = "[LSP]",
luasnip = "[LuaSnip]",
nvim_lua = "[Lua]",
latex_symbols = "[Latex]",
},
maxwidth = 50, -- prevent the popup from showing more than provided characters (e.g 50 will not show more than 50 characters)
-- can also be a function to dynamically calculate max width such as
-- maxwidth = function() return math.floor(0.45 * vim.o.columns) end,
ellipsis_char = "...", -- when popup menu exceed maxwidth, the truncated part would show ellipsis_char instead (must define maxwidth first)
show_labelDetails = true, -- show labelDetails in menu. Disabled by default
-- The function below will be called before any actual modifications from lspkind
-- so that you can provide more controls on popup customization. (See [#30](https://github.com/onsails/lspkind-nvim/pull/30))
before = function(entry, vim_item)
return vim_item
end,
}),
},
window = {
completion = cmp.config.window.bordered({
col_offset = -3,
side_padding = 1,
}),
documentation = cmp.config.window.bordered({
winhighlight = "Normal:CursorLine",
}),
},
}) })
end, end,
} }