mirror of
https://github.com/ilyakooo0/nvim-autopairs.git
synced 2024-09-11 07:15:44 +03:00
fix single quote
This commit is contained in:
parent
faa01b0f73
commit
dc4dcd9d5f
@ -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
|
||||
|
@ -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" ,
|
||||
|
Loading…
Reference in New Issue
Block a user