56 lines
1.8 KiB
Lua
56 lines
1.8 KiB
Lua
require('nvim-autopairs').setup({
|
|
check_ts = true,
|
|
ts_config = {
|
|
lua = {'string'},-- it will not add pair on that treesitter node
|
|
javascript = {'template_string'},
|
|
},
|
|
enable_check_bracket_line = true, -- Don't add pairs if it already have a close pairs in same line
|
|
disable_filetype = { "TelescopePrompt" , "vim" }, --
|
|
enable_afterquote = false, -- add bracket pairs after quote
|
|
enable_moveright = true
|
|
})
|
|
|
|
local Rule = require('nvim-autopairs.rule')
|
|
require('nvim-autopairs').add_rules({
|
|
Rule("%", "%", "lua")
|
|
:with_pair(require('nvim-autopairs.ts-conds').is_ts_node({'string','comment'})),
|
|
Rule("$", "$", "lua")
|
|
:with_pair(require('nvim-autopairs.ts-conds').is_not_ts_node({'function'})),
|
|
Rule(' ', ' ')
|
|
:with_pair(function (opts)
|
|
local pair = opts.line:sub(opts.col - 1, opts.col)
|
|
return vim.tbl_contains({ '()', '[]', '{}' }, pair)
|
|
end),
|
|
Rule('( ', ' )')
|
|
:with_pair(function() return false end)
|
|
:with_move(function(opts)
|
|
return opts.prev_char:match('.%)') ~= nil
|
|
end)
|
|
:use_key(')'),
|
|
Rule('{ ', ' }')
|
|
:with_pair(function() return false end)
|
|
:with_move(function(opts)
|
|
return opts.prev_char:match('.%}') ~= nil
|
|
end)
|
|
:use_key('}'),
|
|
Rule('[ ', ' ]')
|
|
:with_pair(function() return false end)
|
|
:with_move(function(opts)
|
|
return opts.prev_char:match('.%]') ~= nil
|
|
end)
|
|
:use_key(']'),
|
|
Rule('%(.*%)%s*%=>$', ' { }', { 'typescript', 'typescriptreact', 'javascript' })
|
|
:use_regex(true)
|
|
:set_end_pair_length(2),
|
|
})
|
|
|
|
require("cmp").setup({
|
|
map_complete = true, -- it will auto insert `(` (map_char) after select function or method item
|
|
auto_select = true, -- automatically select the first item
|
|
insert = false, -- use insert confirm behavior instead of replace
|
|
map_char = { -- modifies the function or method delimiter by filetypes
|
|
all = '(',
|
|
tex = '{'
|
|
}
|
|
})
|