mirror of
https://github.com/ilyakooo0/nvim-autopairs.git
synced 2024-09-11 15:26:37 +03:00
improves fastwrap on space
This commit is contained in:
parent
f3ebca37d6
commit
06535b1f1a
@ -57,14 +57,23 @@ M.show = function(line)
|
||||
local index = 1
|
||||
local str_length = #line
|
||||
local offset = config.offset
|
||||
local is_end_key = true
|
||||
for i = col + 2, #line, 1 do
|
||||
local char = line:sub(i, i)
|
||||
if string.match(char, config.pattern) then
|
||||
local char2 = line:sub(i - 1, i)
|
||||
if
|
||||
string.match(char, config.pattern)
|
||||
or (char == ' ' and string.match(char2, '%w'))
|
||||
then
|
||||
local key = config.keys:sub(index, index)
|
||||
index = index + 1
|
||||
if utils.is_quote(char) then
|
||||
offset = 0
|
||||
end
|
||||
if i == str_length then
|
||||
is_end_key = false
|
||||
key = config.end_key
|
||||
end
|
||||
table.insert(
|
||||
list_pos,
|
||||
{ col = i + offset, key = key, char = char, pos = i }
|
||||
@ -72,10 +81,12 @@ M.show = function(line)
|
||||
end
|
||||
end
|
||||
|
||||
table.insert(
|
||||
list_pos,
|
||||
{ col = str_length + 1, key = config.end_key, pos = str_length + 1}
|
||||
)
|
||||
if is_end_key then
|
||||
table.insert(
|
||||
list_pos,
|
||||
{ col = str_length + 1, key = config.end_key, pos = str_length + 1 }
|
||||
)
|
||||
end
|
||||
|
||||
M.highlight_wrap(list_pos, row, col, #line)
|
||||
vim.defer_fn(function()
|
||||
|
Loading…
Reference in New Issue
Block a user