nvim: clean up cmp config
This commit is contained in:
parent
41b8393e6a
commit
3c37004e9d
1 changed files with 30 additions and 69 deletions
|
@ -1,4 +1,4 @@
|
||||||
local M = {
|
return {
|
||||||
"hrsh7th/nvim-cmp",
|
"hrsh7th/nvim-cmp",
|
||||||
dependencies = {
|
dependencies = {
|
||||||
"andersevenrud/cmp-tmux",
|
"andersevenrud/cmp-tmux",
|
||||||
|
@ -9,75 +9,36 @@ local M = {
|
||||||
"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 = {} },
|
||||||
},
|
},
|
||||||
event = "InsertEnter",
|
event = "InsertEnter",
|
||||||
}
|
config = function()
|
||||||
|
|
||||||
function M.config()
|
|
||||||
local cmp = require("cmp")
|
local cmp = require("cmp")
|
||||||
|
|
||||||
local has_words_before = function()
|
|
||||||
local line, col = unpack(vim.api.nvim_win_get_cursor(0))
|
|
||||||
return col ~= 0 and vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:sub(col, col):match("%s") == nil
|
|
||||||
end
|
|
||||||
|
|
||||||
vim.o.completeopt = "menuone,noselect"
|
|
||||||
|
|
||||||
cmp.setup({
|
cmp.setup({
|
||||||
completion = {
|
|
||||||
completeopt = "menu,menuone,noinsert",
|
|
||||||
},
|
|
||||||
|
|
||||||
formatting = {
|
formatting = {
|
||||||
format = require("lspkind").cmp_format(),
|
format = require("lspkind").cmp_format(),
|
||||||
},
|
},
|
||||||
|
|
||||||
window = {
|
window = {
|
||||||
completion = cmp.config.window.bordered({
|
completion = cmp.config.window.bordered(),
|
||||||
winhighlight = "Normal:PMenu,FloatBorder:PMenuBorder,CursorLine:PMenuSel,Search:None",
|
documentation = cmp.config.window.bordered(),
|
||||||
}),
|
|
||||||
documentation = cmp.config.window.bordered({
|
|
||||||
winhighlight = "Normal:PMenu,FloatBorder:PMenu,CursorLine:PMenuSel,Search:None",
|
|
||||||
}),
|
|
||||||
},
|
},
|
||||||
|
mapping = cmp.mapping.preset.insert({
|
||||||
mapping = {
|
["<Up>"] = cmp.mapping.select_prev_item(),
|
||||||
["<Up>"] = cmp.mapping(cmp.mapping.select_prev_item(), { "i", "c" }),
|
["<Down>"] = cmp.mapping.select_next_item(),
|
||||||
["<Down>"] = cmp.mapping(cmp.mapping.select_next_item(), { "i", "c" }),
|
|
||||||
["<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({
|
["<C-e>"] = cmp.mapping.abort(),
|
||||||
i = cmp.mapping.abort(),
|
["<CR>"] = cmp.mapping.confirm({ select = true }),
|
||||||
c = cmp.mapping.close(),
|
["<C-Space>"] = cmp.mapping.complete(),
|
||||||
}),
|
}),
|
||||||
-- ["<CR>"] = cmp.mapping(cmp.mapping.confirm({ select = false }), { "i", "c" }),
|
|
||||||
-- ["<C-Space>"] = cmp.mapping(cmp.mapping.complete(), { "i", "c" }),
|
|
||||||
["<CR>"] = cmp.mapping(cmp.mapping.confirm({ select = true })),
|
|
||||||
["<C-Space>"] = cmp.mapping(cmp.mapping.complete(), {}),
|
|
||||||
},
|
|
||||||
|
|
||||||
-- experimental = {
|
|
||||||
-- ghost_text = {
|
|
||||||
-- hl_group = "LspCodeLens",
|
|
||||||
-- },
|
|
||||||
-- },
|
|
||||||
|
|
||||||
sources = cmp.config.sources({
|
sources = cmp.config.sources({
|
||||||
{ name = "nvim_lsp" },
|
{ name = "nvim_lsp" },
|
||||||
{ name = "nvim_lsp_signature_help" },
|
{ name = "nvim_lsp_signature_help" },
|
||||||
{ name = "buffer" },
|
{ name = "buffer" },
|
||||||
{ name = "copilot" },
|
{ name = "copilot" },
|
||||||
{
|
|
||||||
name = "tmux",
|
|
||||||
priority = 2,
|
|
||||||
option = {
|
|
||||||
all_panes = true,
|
|
||||||
trigger_characters = {},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{ name = "emoji" },
|
{ name = "emoji" },
|
||||||
}),
|
}),
|
||||||
})
|
})
|
||||||
end
|
end,
|
||||||
|
}
|
||||||
return M
|
|
||||||
|
|
Loading…
Reference in a new issue