feat: text objects and motions for the pending buffer
Problem: the pending buffer has action-button mappings but no Vim grammar. You cannot dat to delete a task, cit to change a description, or ]] to jump to the next category header. Solution: add textobj.lua with at/it (a task / inner task), aC/iC (a category / inner category), ]]/[[ (next/prev header), and ]t/[t (next/prev task). All text objects work in operator-pending and visual modes; motions work in normal, visual, and operator-pending. Mappings are configurable via the keymaps table and exposed as <Plug> mappings.
This commit is contained in:
parent
c57cc0845b
commit
233ff31df1
5 changed files with 661 additions and 0 deletions
|
|
@ -54,3 +54,35 @@ end)
|
|||
vim.keymap.set('n', '<Plug>(pending-open-line-above)', function()
|
||||
require('pending.buffer').open_line(true)
|
||||
end)
|
||||
|
||||
vim.keymap.set({ 'o', 'x' }, '<Plug>(pending-a-task)', function()
|
||||
require('pending.textobj').a_task(vim.v.count1)
|
||||
end)
|
||||
|
||||
vim.keymap.set({ 'o', 'x' }, '<Plug>(pending-i-task)', function()
|
||||
require('pending.textobj').i_task(vim.v.count1)
|
||||
end)
|
||||
|
||||
vim.keymap.set({ 'o', 'x' }, '<Plug>(pending-a-category)', function()
|
||||
require('pending.textobj').a_category(vim.v.count1)
|
||||
end)
|
||||
|
||||
vim.keymap.set({ 'o', 'x' }, '<Plug>(pending-i-category)', function()
|
||||
require('pending.textobj').i_category(vim.v.count1)
|
||||
end)
|
||||
|
||||
vim.keymap.set({ 'n', 'x', 'o' }, '<Plug>(pending-next-header)', function()
|
||||
require('pending.textobj').next_header(vim.v.count1)
|
||||
end)
|
||||
|
||||
vim.keymap.set({ 'n', 'x', 'o' }, '<Plug>(pending-prev-header)', function()
|
||||
require('pending.textobj').prev_header(vim.v.count1)
|
||||
end)
|
||||
|
||||
vim.keymap.set({ 'n', 'x', 'o' }, '<Plug>(pending-next-task)', function()
|
||||
require('pending.textobj').next_task(vim.v.count1)
|
||||
end)
|
||||
|
||||
vim.keymap.set({ 'n', 'x', 'o' }, '<Plug>(pending-prev-task)', function()
|
||||
require('pending.textobj').prev_task(vim.v.count1)
|
||||
end)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue