77 lines
2.9 KiB
Lua
77 lines
2.9 KiB
Lua
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",
|
|
"https://github.com/hrsh7th/cmp-nvim-lsp",
|
|
"https://github.com/hrsh7th/cmp-nvim-lsp-signature-help",
|
|
-- "https://github.com/hrsh7th/cmp-nvim-lua",
|
|
-- "https://github.com/saadparwaiz1/cmp_luasnip",
|
|
},
|
|
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 }, },
|
|
{ name = "path" },
|
|
{ name = "nvim_lsp" },
|
|
{ name = 'nvim_lsp_signature_help' },
|
|
-- { name = "nvim_lua" },
|
|
-- { name = "luasnip" },
|
|
{ name = "lazydev" },
|
|
{ name = "neorg" },
|
|
}),
|
|
-- snippet = {
|
|
-- expand = function(args)
|
|
-- require("luasnip").lsp_expand(args.body)
|
|
-- end,
|
|
-- },
|
|
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]",
|
|
nvim_lsp = "[LSP]",
|
|
-- luasnip = "[snip]",
|
|
})[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
|
|
},
|
|
|
|
}
|