cmp and autopairs

This commit is contained in:
2026-05-29 14:52:27 +02:00
parent 67f0d9f78c
commit 5eb695beaa
7 changed files with 123 additions and 125 deletions
+25 -2
View File
@@ -1,3 +1,26 @@
local npairs = require('nvim-autopairs')
local M = {}
npairs.setup({})
M = {
disable_filetype = {
"TelescopePrompt",
"spectre_panel",
"snacks_picker_input",
},
disable_in_macro = true,
disable_in_visualblock = false,
disable_in_replace_mode = true,
ignored_next_char = [=[[%w%%%'%[%"%.%`%$]]=],
enable_moveright = true,
enable_afterquote = true,
enable_check_bracket_line = true,
enable_bracket_in_quote = true,
enable_abbr = false,
break_undo = true,
check_ts = false,
map_cr = true,
map_bs = true,
map_c_h = false,
map_c_w = false,
}
return M
-40
View File
@@ -1,40 +0,0 @@
local cmp_kinds = {
Text = '',
Method = '',
Function = '',
Constructor = '',
Field = '',
Variable = '',
Class = '',
Interface = '',
Module = '',
Property = '',
Unit = '',
Value = '',
Enum = '',
Keyword = '',
Snippet = '',
Color = '',
File = '',
Reference = '',
Folder = '',
EnumMember = '',
Constant = '',
Struct = '',
Event = '',
Operator = '',
TypeParameter = '',
}
local cmp = require('cmp')
cmp.setup({
preselect = 'None',
formatting = {
fields = { 'kind', 'abbr' },
format = function(_, vim_item)
vim_item.kind = cmp_kinds[vim_item.kind] or ''
return vim_item
end,
}
})
+18 -3
View File
@@ -1,6 +1,7 @@
local cmp = require "cmp"
local cmp_lsp = require "cmp_nvim_lsp"
local cmp_kinds = require("assets.icons").icons.kinds
local cmp_autopairs = require "nvim-autopairs.completion.cmp"
local function flatten_to_array(t)
local res = {}
@@ -133,9 +134,22 @@ cmp.setup {
["<C-f>"] = cmp.mapping.scroll_docs(4),
["<C-Space>"] = cmp.mapping.complete(),
["<C-e>"] = cmp.mapping.close(),
["<CR>"] = cmp.mapping.confirm {
behavior = cmp.ConfirmBehavior.Insert,
select = true,
["<CR>"] = cmp.mapping {
i = function(fallback)
if cmp.visible() and cmp.get_active_entry() then
cmp.confirm {
behavior = cmp.ConfirmBehavior.Replace,
select = false,
}
else
fallback()
end
end,
s = cmp.mapping.confirm { select = true },
c = cmp.mapping.confirm {
behavior = cmp.ConfirmBehavior.Replace,
select = true,
},
},
["<Tab>"] = cmp.mapping(function(fallback)
if cmp.visible() then
@@ -165,6 +179,7 @@ cmp.setup {
{ name = "nvim_lua" },
},
}
cmp.event:on("confirm_done", cmp_autopairs.on_confirm_done())
vim.diagnostic.config {
virtual_text = false,