42 lines
1.2 KiB
Lua
42 lines
1.2 KiB
Lua
return {
|
|
"hrsh7th/nvim-cmp",
|
|
event = "InsertEnter",
|
|
dependencies = {
|
|
"hrsh7th/cmp-nvim-lsp",
|
|
"hrsh7th/cmp-buffer",
|
|
"hrsh7th/cmp-path",
|
|
"L3MON4D3/LuaSnip",
|
|
"zbirenbaum/copilot-cmp", -- Copilot completion source
|
|
},
|
|
opts = function()
|
|
local cmp = require("cmp")
|
|
local luasnip = require("luasnip")
|
|
|
|
return {
|
|
snippet = {
|
|
expand = function(args)
|
|
luasnip.lsp_expand(args.body)
|
|
end,
|
|
},
|
|
mapping = cmp.mapping.preset.insert({
|
|
["<C-Space>"] = cmp.mapping.complete(),
|
|
["<CR>"] = cmp.mapping.confirm({ select = true }), -- Auto-select first item
|
|
["<C-n>"] = cmp.mapping.select_next_item(),
|
|
["<C-p>"] = cmp.mapping.select_prev_item(),
|
|
["<C-e>"] = cmp.mapping.abort(),
|
|
}),
|
|
sources = cmp.config.sources({
|
|
{ name = "copilot", group_index = 2 }, -- Copilot suggestions (priority 1)
|
|
{ name = "nvim_lsp", group_index = 2 },
|
|
{ name = "path", group_index = 2 },
|
|
{ name = "buffer", group_index = 2 },
|
|
}),
|
|
completion = { completeopt = "menu,menuone,noinsert" }, -- Auto-select first item
|
|
}
|
|
end,
|
|
config = function(_, opts)
|
|
require("cmp").setup(opts)
|
|
end,
|
|
}
|
|
|