* 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.
* fix(textobj): escape Lua pattern hyphen, fix test expectations
Problem: inner_task_range used unescaped '-' in Lua patterns, which
acts as a lazy quantifier instead of matching a literal hyphen. The
metadata-stripping logic also tokenized the full line including the
prefix, so the rebuilt string could never be found after the prefix.
All test column expectations were off by one.
Solution: escape hyphens with %-, rewrite metadata stripping to
tokenize only the description portion after the prefix, and correct
all test assertions to match actual rendered column positions.
* feat(textobj): add debug mode, rename priority view buffer
Problem: the ]] motion reportedly lands one line past the header in
some environments, and ]t/[t may not override Neovim defaults. No
way to diagnose these at runtime. Also, pending://priority is a poor
buffer name for the flat ranked view.
Solution: add a debug config option (vim.g.pending = { debug = true })
that logs meta state, cursor positions, and mapping registration to
:messages at DEBUG level. Rename the buffer from pending://priority to
pending://queue. Internal view identifier stays 'priority'.
* docs: text objects, motions, debug mode, queue view rename
Problem: vimdoc had no documentation for the new text objects, motions,
debug config, or the pending://queue buffer rename.
Solution: add text object and motion tables to the mappings section,
document all eight <Plug> mappings, add debug field to the config
reference, update config example with new keymap defaults, rename
priority view references to queue throughout the vimdoc.
* fix(textobj): use correct config variable, raise log level
Problem: motion keymaps (]], [[, ]t, [t) were never set because
`config.get().debug` referenced an undefined `config` variable,
crashing _setup_buf_mappings before the motion loop. Debug logging
also used vim.log.levels.DEBUG which is filtered by default.
Solution: replace `config` with `cfg` (already in scope) and raise
both debug notify calls from DEBUG to INFO.
* ci: formt
88 lines
2.4 KiB
Lua
88 lines
2.4 KiB
Lua
if vim.g.loaded_pending then
|
|
return
|
|
end
|
|
vim.g.loaded_pending = true
|
|
|
|
vim.api.nvim_create_user_command('Pending', function(opts)
|
|
require('pending').command(opts.args)
|
|
end, {
|
|
bar = true,
|
|
nargs = '*',
|
|
complete = function(arg_lead, cmd_line)
|
|
local subcmds = { 'add', 'sync', 'archive', 'due', 'undo' }
|
|
if not cmd_line:match('^Pending%s+%S') then
|
|
return vim.tbl_filter(function(s)
|
|
return s:find(arg_lead, 1, true) == 1
|
|
end, subcmds)
|
|
end
|
|
return {}
|
|
end,
|
|
})
|
|
|
|
vim.keymap.set('n', '<Plug>(pending-open)', function()
|
|
require('pending').open()
|
|
end)
|
|
|
|
vim.keymap.set('n', '<Plug>(pending-close)', function()
|
|
require('pending.buffer').close()
|
|
end)
|
|
|
|
vim.keymap.set('n', '<Plug>(pending-toggle)', function()
|
|
require('pending').toggle_complete()
|
|
end)
|
|
|
|
vim.keymap.set('n', '<Plug>(pending-view)', function()
|
|
require('pending.buffer').toggle_view()
|
|
end)
|
|
|
|
vim.keymap.set('n', '<Plug>(pending-priority)', function()
|
|
require('pending').toggle_priority()
|
|
end)
|
|
|
|
vim.keymap.set('n', '<Plug>(pending-date)', function()
|
|
require('pending').prompt_date()
|
|
end)
|
|
|
|
vim.keymap.set('n', '<Plug>(pending-undo)', function()
|
|
require('pending').undo_write()
|
|
end)
|
|
|
|
vim.keymap.set('n', '<Plug>(pending-open-line)', function()
|
|
require('pending.buffer').open_line(false)
|
|
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)
|