fix(priority): support <C-a>/<C-x> in all visual modes
Problem: `<C-a>` and `<C-x>` only worked in normal mode for single-task priority adjustment. In visual mode (`v`, `V`, `<C-v>`), they fell through to Vim's native number increment. Only `g<C-a>`/`g<C-x>` were mapped for visual batch priority. Solution: add `priority_up` and `priority_down` to the visual actions table so `<C-a>`/`<C-x>` call the batch function in all visual modes. Add corresponding `x`-mode `<Plug>` mappings. Document that both mappings work in normal and visual mode.
This commit is contained in:
parent
b2456580b5
commit
34242d3b98
3 changed files with 40 additions and 6 deletions
|
|
@ -352,8 +352,10 @@ Default buffer-local keys: ~
|
|||
`gz` Undo the last `:w` save (`undo`)
|
||||
`o` Insert a new task line below (`open_line`)
|
||||
`O` Insert a new task line above (`open_line_above`)
|
||||
`<C-a>` Increment priority (clamped at `max_priority`) (`priority_up`)
|
||||
`<C-x>` Decrement priority (clamped at 0) (`priority_down`)
|
||||
`<C-a>` Increment priority — normal: single task, visual: all
|
||||
selected tasks (`priority_up`)
|
||||
`<C-x>` Decrement priority — normal: single task, visual: all
|
||||
selected tasks (`priority_down`)
|
||||
`g<C-a>` Increment priority for visual selection (`priority_up_visual`)
|
||||
`g<C-x>` Decrement priority for visual selection (`priority_down_visual`)
|
||||
`J` Move task down within its category (`move_down`)
|
||||
|
|
@ -472,13 +474,29 @@ old keys to `false`: >lua
|
|||
|
||||
*<Plug>(pending-priority-up)*
|
||||
<Plug>(pending-priority-up)
|
||||
Increment the priority level for the task under the cursor, clamped
|
||||
at `max_priority`. Default key: `<C-a>`.
|
||||
Normal mode: increment the priority level for the task under the
|
||||
cursor, clamped at `max_priority`.
|
||||
Visual mode: increment priority for all tasks in the selection.
|
||||
Works in charwise (`v`), linewise (`V`), and blockwise (`<C-v>`)
|
||||
visual modes. Default key: `<C-a>`.
|
||||
|
||||
*<Plug>(pending-priority-down)*
|
||||
<Plug>(pending-priority-down)
|
||||
Decrement the priority level for the task under the cursor, clamped
|
||||
at 0. Default key: `<C-x>`.
|
||||
Normal mode: decrement the priority level for the task under the
|
||||
cursor, clamped at 0.
|
||||
Visual mode: decrement priority for all tasks in the selection.
|
||||
Works in charwise (`v`), linewise (`V`), and blockwise (`<C-v>`)
|
||||
visual modes. Default key: `<C-x>`.
|
||||
|
||||
*<Plug>(pending-priority-up-visual)*
|
||||
<Plug>(pending-priority-up-visual)
|
||||
Increment priority for all tasks in the visual selection. Alias for
|
||||
`<Plug>(pending-priority-up)` in visual mode. Default key: `g<C-a>`.
|
||||
|
||||
*<Plug>(pending-priority-down-visual)*
|
||||
<Plug>(pending-priority-down-visual)
|
||||
Decrement priority for all tasks in the visual selection. Alias for
|
||||
`<Plug>(pending-priority-down)` in visual mode. Default key: `g<C-x>`.
|
||||
|
||||
*<Plug>(pending-open-line)*
|
||||
<Plug>(pending-open-line)
|
||||
|
|
|
|||
|
|
@ -404,6 +404,12 @@ function M._setup_buf_mappings(bufnr)
|
|||
|
||||
---@type table<string, fun()>
|
||||
local visual_actions = {
|
||||
priority_up = function()
|
||||
M.increment_priority_visual()
|
||||
end,
|
||||
priority_down = function()
|
||||
M.decrement_priority_visual()
|
||||
end,
|
||||
priority_up_visual = function()
|
||||
M.increment_priority_visual()
|
||||
end,
|
||||
|
|
|
|||
|
|
@ -402,6 +402,16 @@ vim.keymap.set('n', '<Plug>(pending-priority-down)', function()
|
|||
require('pending').decrement_priority()
|
||||
end)
|
||||
|
||||
vim.keymap.set('x', '<Plug>(pending-priority-up)', function()
|
||||
vim.api.nvim_feedkeys(vim.api.nvim_replace_termcodes('<Esc>', true, false, true), 'nx', false)
|
||||
require('pending').increment_priority_visual()
|
||||
end)
|
||||
|
||||
vim.keymap.set('x', '<Plug>(pending-priority-down)', function()
|
||||
vim.api.nvim_feedkeys(vim.api.nvim_replace_termcodes('<Esc>', true, false, true), 'nx', false)
|
||||
require('pending').decrement_priority_visual()
|
||||
end)
|
||||
|
||||
vim.keymap.set('x', '<Plug>(pending-priority-up-visual)', function()
|
||||
vim.api.nvim_feedkeys(vim.api.nvim_replace_termcodes('<Esc>', true, false, true), 'nx', false)
|
||||
require('pending').increment_priority_visual()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue