config.nvim/lua/custom/plugins/cmp.lua

42 lines
1 KiB
Lua
Raw Permalink Normal View History

2024-11-11 22:17:41 -05:00
return {
"hrsh7th/nvim-cmp",
dependencies = {
"hrsh7th/cmp-nvim-lsp",
"hrsh7th/cmp-buffer",
"hrsh7th/cmp-path",
"L3MON4D3/LuaSnip",
"saadparwaiz1/cmp_luasnip",
},
lazy = false,
config = function()
vim.opt.completeopt = { "menu", "menuone", "noselect" }
vim.opt.shortmess:append("c")
local cmp = require("cmp")
cmp.setup({
preselect = cmp.PreselectMode.Item,
sources = {
{ name = "nvim_lsp" },
{ name = "luasnip" },
{ name = "path" },
{ name = "buffer" },
},
mapping = {
["<C-n>"] = cmp.mapping.select_next_item({ behavior = cmp.SelectBehavior.Insert }),
["<C-p>"] = cmp.mapping.select_prev_item({ behavior = cmp.SelectBehavior.Insert }),
["<C-y>"] = cmp.mapping.confirm({
behavior = cmp.SelectBehavior.Insert,
select = true,
}),
["<Tab>"] = nil,
["<S-Tab>"] = nil,
["<CR>"] = nil,
},
2024-11-12 18:32:00 -05:00
snippet = { expand = function(args) vim.snippet.expand(args.body) end },
2024-11-11 22:17:41 -05:00
})
end,
}