1
0
Fork 0

completion engine

This commit is contained in:
zymon 2024-08-27 14:36:52 +02:00
parent d188262c02
commit 1e2a6dc5d2

62
lua/znvim/plugins/cmp.lua Normal file
View file

@ -0,0 +1,62 @@
return {
{
"https://github.com/hrsh7th/nvim-cmp",
dependencies = {
"https://github.com/hrsh7th/cmp-buffer",
"https://github.com/hrsh7th/cmp-path",
"https://github.com/hrsh7th/cmp-cmdline",
},
event = { "InsertEnter", "CmdlineEnter", "BufReadPost" },
config = function()
local cmp = require("cmp")
cmp.setup({
preselect = cmp.PreselectMode.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(),
["<CR>"] = cmp.mapping.confirm({ select = false }),
["<C-e>"] = cmp.mapping.abort(),
}),
sources = cmp.config.sources({
{
name = "buffer",
option = { keyword_length = 3 },
},
}),
window = {
completion = cmp.config.window.bordered(),
documentation = cmp.config.window.bordered(),
},
formatting = {
fields = { "kind", "abbr", "menu" },
format = function(entry, item)
item.kind = item.kind
item.menu = ({
buffer = "[buf]",
path = "[path]",
cmdline = "[cmd]",
})[entry.source.name] or entry.source.name
return item
end,
},
})
cmp.setup.cmdline('/', {
mapping = cmp.mapping.preset.cmdline(),
sources = {
{ name = 'buffer' }
}
})
cmp.setup.cmdline(':', {
mapping = cmp.mapping.preset.cmdline(),
sources = cmp.config.sources({
{ name = 'path' },
{ name = 'cmdline' }
})
})
end
},
}