refactor(completions): Make nvim-cmp's config more idiomatic
This commit is contained in:
parent
40504db0aa
commit
b0b0ed3359
|
@ -11,31 +11,33 @@ return {
|
|||
"L3MON4D3/LuaSnip",
|
||||
"saadparwaiz1/cmp_luasnip",
|
||||
},
|
||||
config = function()
|
||||
opts = function()
|
||||
local cmp = require("cmp")
|
||||
|
||||
cmp.setup({
|
||||
return {
|
||||
window = {
|
||||
completion = cmp.config.window.bordered(),
|
||||
},
|
||||
snippet = {
|
||||
expand = function(args)
|
||||
require("luasnip").lsp_expand(args.body)
|
||||
end,
|
||||
},
|
||||
window = {
|
||||
completion = cmp.config.window.bordered(),
|
||||
-- documentation = cmp.config.window.bordered(),
|
||||
},
|
||||
mapping = cmp.mapping.preset.insert({
|
||||
["<C-b>"] = cmp.mapping.scroll_docs(-4),
|
||||
["<C-f>"] = cmp.mapping.scroll_docs(4),
|
||||
["<C-e>"] = cmp.mapping.abort(),
|
||||
["<CR>"] = cmp.mapping.confirm({ select = false }),
|
||||
}),
|
||||
sources = cmp.config.sources({
|
||||
sources = {
|
||||
{ name = "nvim_lsp", priority = 2 },
|
||||
{ name = "luasnip", priority = 1 },
|
||||
{ name = "buffer" },
|
||||
}),
|
||||
})
|
||||
},
|
||||
}
|
||||
end,
|
||||
keys = {
|
||||
{ "<C-b>", function() require("cmp").mapping.scroll_docs(-4) end },
|
||||
{ "<C-f>", function() require("cmp").mapping.scroll_docs(4) end },
|
||||
{ "<C-e>", function() require("cmp").mapping.abort() end },
|
||||
{ "<CR>", function() require("cmp").mapping.confirm({ select = false }) end },
|
||||
},
|
||||
init = function()
|
||||
local cmp = require("cmp")
|
||||
|
||||
vim.api.nvim_create_autocmd("BufRead", {
|
||||
group = vim.api.nvim_create_augroup("CmpSourceCargo", { clear = true }),
|
||||
|
|
Loading…
Reference in a new issue