Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions .config/nvim/lua/nvim.lua
Original file line number Diff line number Diff line change
Expand Up @@ -516,6 +516,17 @@ function M.delete_mostly_inner_surround()
return
end

-- TODO: Workaround. For some reason 'B' ('**foo**') cannot be deleted by vim-operator-surround
-- See also: .vim/autoload/vimrc.vim - same workaround in Vimscript
if obj_key == 'B' then
-- Delete content between * (which leaves ** on each side)
vim.cmd('normal! d' .. vim.api.nvim_replace_termcodes('<Plug>(textobj-between-i)*', true, false, true))
-- Replace the remaining **** with the deleted content
vim.cmd([[s/\*\*\*\*/{@"}/]])
print('**deleted**')
return
end

M.run_with_virtual_keymaps('va' .. obj_key .. '<Plug>(operator-surround-delete)')
vim.call('repeat#set', 'va' .. obj_key .. '\\<Plug>(operator-surround-delete)')
end
Expand All @@ -535,6 +546,7 @@ function M.replace_mostly_inner_surround()
return
end

-- Use the original pattern that works for most delimiters
M.run_with_virtual_keymaps('va' .. obj_key_from .. '<Plug>(operator-surround-replace)' .. obj_key_to)
vim.call('repeat#set', 'va' .. obj_key_from .. '\\<Plug>(operator-surround-replace)' .. obj_key_to)
end
Expand Down