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

54 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-05-14 05:06:12 -04:00
cmp.setup({
mapping = cmp.mapping.preset.insert({
2023-03-12 16:09:11 -04:00
["<Tab>"] = cmp.mapping.select_next_item(),
2023-08-27 06:01:33 -04:00
["<C-P>"] = cmp.mapping.select_next_item(),
["<C-N>"] = cmp.mapping.select_prev_item(),
2023-03-12 16:09:11 -04:00
["<S-Tab>"] = cmp.mapping.select_prev_item(),
["<C-Space>"] = cmp.mapping.complete(),
["<CR>"] = cmp.mapping.confirm({select = false}),
2023-05-14 05:06:12 -04:00
}),
2023-03-12 16:09:11 -04:00
completion = {
2023-08-27 06:01:33 -04:00
autocomplete = false,
2023-03-12 16:09:11 -04:00
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" },
},
2023-05-14 05:06:12 -04:00
})