fix single quote

This commit is contained in:
windwp 2021-01-18 08:25:36 +07:00
parent faa01b0f73
commit dc4dcd9d5f
2 changed files with 19 additions and 7 deletions

View File

@ -108,12 +108,6 @@ MPairs.check_add = function(char)
local next_char = line:sub(next_col, next_col)
local prev_char = line:sub(next_col- 1, next_col -1)
-- when on end line col not work with autocomplete method so we need to skip it
if next_col == string.len(line) + 1 then
-- need to update completion nvim for check
return 1
end
-- move right when have quote on end line or in quote
-- situtaion |" => "|
if (next_char == "'" or next_char == '"') and next_char == char then
@ -126,13 +120,19 @@ MPairs.check_add = function(char)
return 2
end
end
-- don' t add single quote if prev char is word
--
-- a| => not add
if char == "'" and prev_char:match("%w")then
return 0
end
-- when on end line col not work with autocomplete method so we need to skip it
if next_col == string.len(line) + 1 then
-- need to update completion nvim for check
return 1
end
-- situtaion |( => not add
if next_char == char then
return 0

View File

@ -16,6 +16,12 @@ function helpers.insert(text)
end
local data = {
{
name = "add normal bracket" ,
key = [[{]],
before = [[aaaa| ]],
after = [[aaaa{|} ]]
},
{
name = "add normal bracket" ,
key = [[(]],
@ -33,6 +39,12 @@ local data = {
key = [[']],
before = [[aa| aa]],
after = [[aa'| aa]]
},
{
name = "don't add single quote on end line",
key = [[<right>']],
before = [[c aa|]],
after = [[c aa'|]]
},
{
name = "don't add quote after alphabet char" ,