mirror of
https://github.com/ilyakooo0/nvim-autopairs.git
synced 2024-09-11 07:15:44 +03:00
fix endwise indent and disable auto ts_node
This commit is contained in:
parent
e1f6c993ba
commit
ce2514a9b6
@ -37,7 +37,7 @@ M.init = function()
|
||||
end
|
||||
|
||||
M.setup = function(opt)
|
||||
M.config = vim.tbl_extend('force', default, opt or {})
|
||||
M.config = vim.tbl_deep_extend('force', default, opt or {})
|
||||
M.config.rules = basic_rule.setup(M.config)
|
||||
|
||||
if M.config.check_ts then
|
||||
@ -124,9 +124,6 @@ M.on_attach = function(bufnr)
|
||||
|
||||
if M.state.buf_ts[bufnr] == true then
|
||||
M.state.ts_node = M.config.ts_config[vim.bo.filetype]
|
||||
if M.state.ts_node == nil then
|
||||
M.state.ts_node = {'string', 'comment'}
|
||||
end
|
||||
else
|
||||
M.state.ts_node = nil
|
||||
end
|
||||
@ -365,8 +362,8 @@ M.autopairs_cr = function(bufnr)
|
||||
log.debug('do endwise')
|
||||
return utils.esc(
|
||||
rule.end_pair
|
||||
.. utils.repeat_key(utils.key.left, 3)
|
||||
.. "<cr><esc><<O"
|
||||
.. utils.repeat_key(utils.key.left, #rule.end_pair)
|
||||
.. "<cr><esc>O"
|
||||
)
|
||||
end
|
||||
if
|
||||
|
@ -25,17 +25,26 @@ conds.is_endwise_node = function(nodes)
|
||||
if last == nil then
|
||||
return true
|
||||
end
|
||||
log.debug('last:' .. last)
|
||||
-- log.debug('last:' .. last)
|
||||
-- if match then we need tocheck parent node
|
||||
local _,_, linenr_target = target:range()
|
||||
local _,_, linenr_parent = target:parent():range()
|
||||
-- some time treesiter is group 2 node then we need check that
|
||||
local begin_target,_, end_target = target:range()
|
||||
local begin_parent,_, end_parent = target:parent():range()
|
||||
-- log.debug(target:range())
|
||||
-- log.debug(ts_utils.get_node_text(target))
|
||||
-- log.debug(target:parent():range())
|
||||
-- log.debug(ts_utils.get_node_text(target:parent()))
|
||||
if linenr_parent - linenr_target == 1 then
|
||||
if
|
||||
(
|
||||
begin_target ~= begin_parent
|
||||
and end_target == end_parent
|
||||
)
|
||||
or
|
||||
(end_parent - end_target == 1)
|
||||
then
|
||||
return true
|
||||
end
|
||||
-- return true
|
||||
else
|
||||
end
|
||||
return false
|
||||
|
@ -1,8 +1,7 @@
|
||||
|
||||
local function abc()
|
||||
local data1, data2
|
||||
local function wind()
|
||||
|
||||
|
||||
if fdasf then
|
||||
|
||||
|
||||
|
||||
@ -21,4 +20,4 @@ if fdasf then
|
||||
|
||||
|
||||
end
|
||||
return abc
|
||||
|
||||
|
@ -21,7 +21,7 @@ local data = {
|
||||
after = [[end ]]
|
||||
},
|
||||
{
|
||||
only = true,
|
||||
-- only = true;
|
||||
name = "add newline have endwise" ,
|
||||
filepath = './tests/endwise/init.lua',
|
||||
filetype = "lua",
|
||||
|
@ -67,7 +67,6 @@ local data = {
|
||||
after = [[ [[ abcde %|% ]]
|
||||
},
|
||||
{
|
||||
only = true,
|
||||
name = "ts_conds is_ts_node failed",
|
||||
filepath = './tests/endwise/init.lua',
|
||||
linenr = 5,
|
||||
|
Loading…
Reference in New Issue
Block a user