fix html rule

This commit is contained in:
zztrieuzz 2021-10-26 08:42:18 +07:00
parent fdeb794ee7
commit 4f7d7fc2b7
4 changed files with 18 additions and 3 deletions

View File

@ -547,7 +547,7 @@ M.autopairs_cr = function(bufnr)
end
if
utils.is_equal(rule.start_pair, prev_char, rule.is_regex)
and rule.end_pair == next_char
and utils.is_equal(rule.end_pair, next_char, rule.is_regex)
and rule:can_cr({
ts_node = M.state.ts_node,
check_endwise_ts = false,

View File

@ -40,9 +40,10 @@ local function setup(opt)
bracket("(", ")"),
bracket("[", "]"),
bracket("{", "}"),
Rule(">", "<",
Rule(">[%w%s]*$", "^%s*</",
{ 'html', 'typescript', 'typescriptreact', 'javascript' , 'javascriptreact', 'svelte', 'vue', 'xml'})
:only_cr()
:use_regex(true)
}
return rules
end

View File

@ -32,7 +32,7 @@ M.is_close_bracket = function (char)
return char == ")" or char == ']' or char == '}'
end
M.is_equal = function (value,text, is_regex)
M.is_equal = function (value, text, is_regex)
if is_regex and string.match(text, value) then
return true
elseif text == value then

View File

@ -232,6 +232,20 @@ local data = {
before = [[<div>|</div>]],
after = [[</div>]]
},
{
name = "breakline on < html with text" ,
filetype = "html",
key = [[<cr>]],
before = [[<div> ads |</div>]],
after = [[</div>]]
},
{
name = "breakline on < html with space after cursor" ,
filetype = "html",
key = [[<cr>]],
before = [[<div> ads | </div>]],
after = [[ </div>]]
},
{
name = "do not mapping on > html" ,
filetype = "html",