completion engine
This commit is contained in:
parent
d188262c02
commit
1e2a6dc5d2
1 changed files with 62 additions and 0 deletions
62
lua/znvim/plugins/cmp.lua
Normal file
62
lua/znvim/plugins/cmp.lua
Normal 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
|
||||
},
|
||||
|
||||
}
|
Loading…
Reference in a new issue