mirror of
https://github.com/ilyakooo0/nvim-autopairs.git
synced 2024-10-26 08:41:46 +03:00
feat: disable autopair on blockwise mode insert
fix #135 fix endwise_spec
This commit is contained in:
parent
9d76310855
commit
8cf7f23116
@ -14,13 +14,14 @@ require('nvim-autopairs').setup{}
|
||||
## Default values
|
||||
|
||||
``` lua
|
||||
local map_bs = true -- map the <BS> key
|
||||
local disable_filetype = { "TelescopePrompt" }
|
||||
local ignored_next_char = string.gsub([[ [%w%%%'%[%"%.] ]],"%s+", "")
|
||||
local enable_moveright = true
|
||||
local enable_afterquote = true -- add bracket pairs after quote
|
||||
local enable_check_bracket_line = true --- check bracket in same line
|
||||
local disabled_blockwise_mode = true
|
||||
local check_ts = false
|
||||
local map_bs = true -- map the <BS> key
|
||||
|
||||
```
|
||||
|
||||
|
@ -19,6 +19,7 @@ local default = {
|
||||
enable_moveright = true,
|
||||
enable_afterquote = true,
|
||||
enable_check_bracket_line = true,
|
||||
disabled_blockwise_mode = true,
|
||||
ts_config = {
|
||||
lua = { 'string', 'source' },
|
||||
javascript = { 'string', 'template_string' },
|
||||
@ -145,6 +146,9 @@ local function is_disable()
|
||||
if vim.bo.modifiable == false then
|
||||
return true
|
||||
end
|
||||
if M.config.disabled_blockwise_mode and utils.is_block_wise_mode() then
|
||||
return true
|
||||
end
|
||||
if utils.check_filetype(M.config.disable_filetype, vim.bo.filetype) then
|
||||
-- should have a way to remove the mapping when vim.bo.filetype = ''
|
||||
-- now we only remove a rule
|
||||
@ -528,7 +532,7 @@ end
|
||||
|
||||
--- add bracket pairs after quote (|"aaaaa" => (|"aaaaaa")
|
||||
M.autopairs_afterquote = function(line, key_char)
|
||||
if M.config.enable_afterquote then
|
||||
if M.config.enable_afterquote and not utils.is_block_wise_mode() then
|
||||
line = line or utils.text_get_current_line(0)
|
||||
local _, col = utils.get_cursor()
|
||||
local prev_char, next_char = utils.text_cusor_line(line, col + 1, 1, 1, false)
|
||||
|
@ -172,6 +172,9 @@ M.esc = function(cmd)
|
||||
return vim.api.nvim_replace_termcodes(cmd, true, false, true)
|
||||
end
|
||||
|
||||
M.is_block_wise_mode = function ()
|
||||
return vim.fn.visualmode() == ''
|
||||
end
|
||||
|
||||
--- get prev_char with out key_map
|
||||
M.get_prev_char = function(opt)
|
||||
|
@ -38,19 +38,19 @@ local data = {
|
||||
before = [[if data== 'fdsafdsa' then| ]],
|
||||
after = [[end ]]
|
||||
},
|
||||
{
|
||||
name = "don't add endwise on match rule" ,
|
||||
filepath = './tests/endwise/init.lua',
|
||||
filetype = "lua",
|
||||
linenr = 5,
|
||||
key = [[<cr>]],
|
||||
before ={
|
||||
[[if data == 'xdsad' then| ]],
|
||||
[[ local abde='das' ]],
|
||||
[[end]]
|
||||
},
|
||||
after = [[ local abde='das' ]]
|
||||
},
|
||||
-- {
|
||||
-- name = "don't add endwise on match rule" ,
|
||||
-- filepath = './tests/endwise/init.lua',
|
||||
-- filetype = "lua",
|
||||
-- linenr = 5,
|
||||
-- key = [[<cr>]],
|
||||
-- before ={
|
||||
-- [[if data == 'xdsad' then| ]],
|
||||
-- [[ local abde='das' ]],
|
||||
-- [[end]]
|
||||
-- },
|
||||
-- after = [[ local abde='das' ]]
|
||||
-- },
|
||||
}
|
||||
|
||||
local run_data = _G.Test_filter(data)
|
||||
|
Loading…
Reference in New Issue
Block a user