This commit is contained in:
grechkagk-thinkpad 2026-02-01 16:42:22 +08:00
commit 36c66e33e6
17 changed files with 348 additions and 0 deletions

44
lua/plugins/cmp.lua Normal file
View file

@ -0,0 +1,44 @@
return {
"hrsh7th/nvim-cmp",
event = "InsertEnter",
dependencies = {
"hrsh7th/cmp-nvim-lsp",
"hrsh7th/cmp-buffer",
"hrsh7th/cmp-path",
},
config = function()
local cmp = require("cmp")
cmp.setup({
completion = {
completeopt = "menu,menuone,noinsert",
},
preselect = cmp.PreselectMode.Item,
mapping = cmp.mapping.preset.insert({
["<C-b>"] = cmp.mapping.scroll_docs(-4),
["<C-f>"] = cmp.mapping.scroll_docs(4),
["<C-n>"] = cmp.mapping.select_next_item(),
["<C-p>"] = cmp.mapping.select_prev_item(),
["<C-Space>"] = cmp.mapping.complete(),
["<CR>"] = cmp.mapping.confirm({ select = true }),
}),
sources = cmp.config.sources({
{ name = "nvim_lsp" },
{ name = "path" },
}, {
{ name = "buffer" },
}),
formatting = {
fields = { "kind", "abbr", "menu" },
},
})
end,
}