dotfiles/.config/nvim/lua/plugins/cmp.lua

55 lines
1.3 KiB
Lua
Raw Normal View History

2022-10-21 06:15:28 -04:00
local ok,cmp = pcall(require,"cmp")
if not ok then
2023-03-12 16:09:11 -04:00
vim.notify("Failed to load cmp\n\n")
return
2022-10-21 06:15:28 -04:00
end
2023-03-12 16:09:11 -04:00
cmp.setup {
mapping = {
["<Tab>"] = cmp.mapping.select_next_item(),
["<C-N>"] = cmp.mapping.select_next_item(),
["<S-Tab>"] = cmp.mapping.select_prev_item(),
["<C-P>"] = cmp.mapping.select_prev_item(),
["<C-Space>"] = cmp.mapping.complete(),
["<CR>"] = cmp.mapping.confirm({select = false}),
},
completion = {
autocomplete = true,
completeopt = "menu,menuone,noinsert",
winhighlight = "Normal:Pmenu,FloatBorder:Pmenu,Search:None",
},
snippet = {
expand = function(args)
require('luasnip').lsp_expand(args.body)
end,
},
window = {
completion = cmp.config.window.bordered(),
documentation = cmp.config.window.bordered()
},
formatting = {
fields = { "kind", "abbr", "menu" },
format = function(entry, vim_item)
local kind = require("lspkind").cmp_format({mode = "symbol_text", maxwidth = 50})(entry, vim_item)
local strings = vim.split(kind.kind, "%s",{trimempty = true})
kind.kind = " " .. strings[1] .. " "
kind.menu = " (" .. strings[2] .. ")"
return kind
end
},
sources = {
{ name = "nvim_lsp" },
{ name = "luasnip" },
{ name = "emoji" },
{ name = "calc" },
},
2022-10-21 06:15:28 -04:00
}