Skip to content

Commit

Permalink
Merge branch 'master' into bot/vimdoc/master
Browse files Browse the repository at this point in the history
  • Loading branch information
windwp authored Sep 18, 2024
2 parents 7f6b134 + ffc139f commit fbb98a4
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
1 change: 1 addition & 0 deletions doc/nvim-autopairs.txt
Original file line number Diff line number Diff line change
Expand Up @@ -436,6 +436,7 @@ FASTWRAP ~
before_key = 'h',
after_key = 'l',
cursor_pos_before = true,
avoid_move_to_end = true, -- stay for direct end_key use
keys = 'qwertyuiopzxcvbnmasdfghjkl',
manual_position = true,
highlight = 'Search',
Expand Down
3 changes: 2 additions & 1 deletion lua/nvim-autopairs/completion/cmp.lua
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ M.filetypes = {
purescript = false,
sh = false,
bash = false,
nix = false
nix = false,
helm = false
}

M.on_confirm_done = function(opts)
Expand Down
17 changes: 16 additions & 1 deletion lua/nvim-autopairs/fastwrap.lua
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ local default_config = {
chars = { '{', '[', '(', '"', "'" },
pattern = [=[[%'%"%>%]%)%}%,%`]]=],
end_key = '$',
avoid_move_to_end = true, -- choose your move behaviour for non-alphabetical end_keys'
before_key = 'h',
after_key = 'l',
cursor_pos_before = true,
Expand Down Expand Up @@ -57,7 +58,7 @@ M.show = function(line)
if end_pair == '' then
return
end
local list_pos = {}
local list_pos = {} --holds target locations
local index = 1
local str_length = #line
local offset = -1
Expand Down Expand Up @@ -90,6 +91,7 @@ M.show = function(line)
)
end
end
log.debug(list_pos)

local end_col, end_pos
if config.manual_position then
Expand Down Expand Up @@ -118,7 +120,16 @@ M.show = function(line)
-- get the first char
local char = #list_pos == 1 and config.end_key or M.getchar_handler()
vim.api.nvim_buf_clear_namespace(0, M.ns_fast_wrap, row, row + 1)

for _, pos in pairs(list_pos) do
-- handle end_key specially
if char == config.end_key and char == pos.key then
vim.print("Run to end!")
-- M.highlight_wrap({pos = pos.pos, key = config.end_key}, row, col, #line, whitespace_line)
local move_end_key = (not config.avoid_move_to_end and char == string.upper(config.end_key))
M.move_bracket(line, pos.col+1, end_pair, move_end_key)
break
end
local hl_mark = {
{ pos = pos.pos - 1, key = config.before_key },
{ pos = pos.pos + 1, key = config.after_key },
Expand Down Expand Up @@ -189,6 +200,10 @@ M.highlight_wrap = function(tbl_pos, row, col, end_col, whitespace_line)
if config.use_virt_lines then
local virt_lines = {}
local start = 0
local left_col = vim.fn.winsaveview().leftcol
if left_col > 0 then
vim.fn.winrestview({ leftcol = 0 })
end
for _, pos in ipairs(tbl_pos) do
virt_lines[#virt_lines + 1] = { whitespace_line:sub(start + 1, pos.pos - 1), 'Normal' }
virt_lines[#virt_lines + 1] = { pos.key, config.highlight }
Expand Down

0 comments on commit fbb98a4

Please sign in to comment.