refactor(completions): Make nvim-cmp's config more idiomatic
This commit is contained in:
parent
40504db0aa
commit
a19f0efee5
|
@ -11,31 +11,35 @@ return {
|
||||||
"L3MON4D3/LuaSnip",
|
"L3MON4D3/LuaSnip",
|
||||||
"saadparwaiz1/cmp_luasnip",
|
"saadparwaiz1/cmp_luasnip",
|
||||||
},
|
},
|
||||||
config = function()
|
opts = function()
|
||||||
local cmp = require("cmp")
|
local cmp = require("cmp")
|
||||||
|
|
||||||
cmp.setup({
|
return {
|
||||||
|
window = {
|
||||||
|
completion = cmp.config.window.bordered(),
|
||||||
|
},
|
||||||
snippet = {
|
snippet = {
|
||||||
expand = function(args)
|
expand = function(args)
|
||||||
require("luasnip").lsp_expand(args.body)
|
require("luasnip").lsp_expand(args.body)
|
||||||
end,
|
end,
|
||||||
},
|
},
|
||||||
window = {
|
sources = {
|
||||||
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({
|
|
||||||
{ name = "nvim_lsp", priority = 2 },
|
{ name = "nvim_lsp", priority = 2 },
|
||||||
{ name = "luasnip", priority = 1 },
|
{ name = "luasnip", priority = 1 },
|
||||||
{ name = "buffer" },
|
{ 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 },
|
||||||
|
},
|
||||||
|
config = function(_, opts)
|
||||||
|
local cmp = require("cmp")
|
||||||
|
|
||||||
|
cmp.setup(opts)
|
||||||
|
|
||||||
vim.api.nvim_create_autocmd("BufRead", {
|
vim.api.nvim_create_autocmd("BufRead", {
|
||||||
group = vim.api.nvim_create_augroup("CmpSourceCargo", { clear = true }),
|
group = vim.api.nvim_create_augroup("CmpSourceCargo", { clear = true }),
|
||||||
|
|
Loading…
Reference in a new issue