.dotfiles/.config/nvim/lua/nvwynd/plugins/completion.lua

65 lines
1.5 KiB
Lua

return {
{
"hrsh7th/nvim-cmp",
lazy = false,
priority = 100,
dependencies = {
"onsails/lspkind.nvim",
"hrsh7th/cmp-nvim-lsp",
"hrsh7th/cmp-path",
"hrsh7th/cmp-buffer",
"L3MON4D3/LuaSnip",
"saadparwaiz1/cmp_luasnip",
},
config = function()
vim.opt.completeopt = { "menu", "menuone", "noselect" }
-- some nice cmp icons
local lspkind = require("lspkind")
lspkind.init({})
local cmp = require("cmp")
cmp.setup({
mapping = cmp.mapping.preset.insert({
-- `Enter` key to confirm completion
["<CR>"] = cmp.mapping.confirm({ select = false }),
-- `Esc` key to close the menu
["<ESC>"] = cmp.mapping.abort(),
-- Ctrl+Space to trigger completion menu
["<C-Space>"] = cmp.mapping.complete(),
-- Scroll up and down in the completion documentation
-- ["<S-q>"] = cmp.mapping.scroll_docs(-4),
-- ["<S-a>"] = cmp.mapping.scroll_docs(4),
}),
sources = cmp.config.sources({
{
name = "nvim_lsp",
entry_filter = function(entry, ctx)
-- 1 is the Text entry from LSP specs
-- https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#completionItemKind
if entry:get_kind() == 1 then
return false
end
return true
end,
},
{ name = "path" },
-- { name = "buffer" },
}),
snippet = {
expand = function(args)
require("luasnip").lsp_expand(args.body)
end,
},
formatting = {
format = lspkind.cmp_format({}),
},
})
end,
},
}