dot/config/nvim/lua/plugins/cmp.lua

69 lines
1.7 KiB
Lua

return {
"hrsh7th/nvim-cmp",
dependencies = {
"hrsh7th/cmp-buffer",
"hrsh7th/cmp-path",
"hrsh7th/cmp-calc",
"hrsh7th/cmp-vsnip",
"hrsh7th/vim-vsnip",
"hrsh7th/cmp-nvim-lsp",
"hrsh7th/cmp-nvim-lua",
"hrsh7th/cmp-emoji",
"hrsh7th/cmp-nvim-lsp-signature-help",
"onsails/lspkind-nvim",
},
event = "InsertEnter",
opts = function()
local lspkind = require("lspkind")
local cmp = require("cmp")
return {
snippet = {
-- REQUIRED - you must specify a snippet engine
expand = function(args)
vim.fn["vsnip#anonymous"](args.body) -- For `vsnip` users.
end,
},
window = {
completion = {
border = "single",
winhighlight = "Normal:Normal,FloatBorder:Normal,CursorLine:Visual,Search:None",
},
documentation = {
border = "single",
winhighlight = "Normal:Normal,FloatBorder:Normal,CursorLine:Visual,Search:None",
},
},
mapping = cmp.mapping.preset.insert({
["<C-b>"] = cmp.mapping.scroll_docs(-4),
["<C-f>"] = cmp.mapping.scroll_docs(4),
["<C-Space>"] = cmp.mapping.complete(),
["<C-e>"] = cmp.mapping.abort(),
["<CR>"] = cmp.mapping.confirm({ select = true }),
}),
sources = cmp.config.sources({
{ name = "nvim_lsp" },
{ name = "nvim_diagnostic" },
{ name = "buffer" },
{ name = "path" },
{ name = "calc" },
{ name = "nvim_lua" },
{ name = "nvim_lsp_signature_help" },
{ name = "emoji" },
}),
formatting = {
format = lspkind.cmp_format({
mode = "symbol_text",
menu = {
buffer = "[Buffer]",
nvim_lsp = "[LSP]",
luasnip = "[LuaSnip]",
nvim_lua = "[Lua]",
latex_symbols = "[Latex]",
},
}),
},
}
end,
}