nvim: cmp tweaks

This commit is contained in:
Daniel Lundin 2023-05-09 22:19:50 +02:00
parent 712769d7cd
commit 9d6880a733

View file

@ -1,44 +1,47 @@
return { return {
"hrsh7th/nvim-cmp", "hrsh7th/nvim-cmp",
dependencies = { dependencies = {
"andersevenrud/cmp-tmux", "andersevenrud/cmp-tmux",
"hrsh7th/cmp-nvim-lsp", "hrsh7th/cmp-nvim-lsp",
"hrsh7th/cmp-buffer", "hrsh7th/cmp-buffer",
"hrsh7th/cmp-emoji", "hrsh7th/cmp-emoji",
"hrsh7th/cmp-path", "hrsh7th/cmp-path",
"hrsh7th/cmp-cmdline", "hrsh7th/cmp-cmdline",
"hrsh7th/cmp-nvim-lsp-signature-help", "hrsh7th/cmp-nvim-lsp-signature-help",
"onsails/lspkind-nvim", "onsails/lspkind-nvim",
{ "zbirenbaum/copilot-cmp", opts = {} }, { "zbirenbaum/copilot-cmp", opts = {} },
}, },
event = "InsertEnter", event = "InsertEnter",
config = function() config = function()
local cmp = require("cmp") local cmp = require("cmp")
cmp.setup({ cmp.setup({
formatting = { formatting = {
format = require("lspkind").cmp_format(), format = require("lspkind").cmp_format(),
}, },
window = { window = {
completion = cmp.config.window.bordered(), completion = cmp.config.window.bordered(),
documentation = cmp.config.window.bordered(), documentation = cmp.config.window.bordered(),
}, },
mapping = cmp.mapping.preset.insert({ mapping = cmp.mapping.preset.insert({
["<Up>"] = cmp.mapping.select_prev_item(), ["<Up>"] = cmp.mapping.select_prev_item(),
["<Down>"] = cmp.mapping.select_next_item(), ["<Down>"] = cmp.mapping.select_next_item(),
["<C-d>"] = cmp.mapping.scroll_docs(-2), ["<C-d>"] = cmp.mapping.scroll_docs(-2),
["<C-u>"] = cmp.mapping.scroll_docs(2), ["<C-u>"] = cmp.mapping.scroll_docs(2),
["<C-e>"] = cmp.mapping.abort(), ["<C-e>"] = cmp.mapping.abort(),
["<CR>"] = cmp.mapping.confirm({ select = true }), ["<CR>"] = cmp.mapping.confirm({ select = false }),
["<C-Space>"] = cmp.mapping.complete(), ["<Tab>"] = cmp.mapping.confirm({ select = true }),
}), ["<C-Space>"] = cmp.mapping.complete(),
sources = cmp.config.sources({ }),
{ name = "nvim_lsp" },
{ name = "nvim_lsp_signature_help" },
{ name = "buffer" }, sources = cmp.config.sources({
{ name = "copilot" }, { name = "nvim_lsp", priority = 3 },
{ name = "emoji" }, { name = "nvim_lsp_signature_help", priority = 10 },
}), { name = "buffer", keyword_length = 3 },
}) { name = "copilot" },
end, { name = "emoji" },
}),
})
end,
} }