Compare commits
2 commits
cfcaaca28b
...
53db05e6b2
| Author | SHA1 | Date | |
|---|---|---|---|
| 53db05e6b2 | |||
| ec1d4c6092 |
5 changed files with 89 additions and 3 deletions
|
|
@ -299,6 +299,8 @@ Default buffer-local keys: ~
|
||||||
`gz` Undo the last `:w` save (`undo`)
|
`gz` Undo the last `:w` save (`undo`)
|
||||||
`o` Insert a new task line below (`open_line`)
|
`o` Insert a new task line below (`open_line`)
|
||||||
`O` Insert a new task line above (`open_line_above`)
|
`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`)
|
||||||
`J` Move task down within its category (`move_down`)
|
`J` Move task down within its category (`move_down`)
|
||||||
`K` Move task up within its category (`move_up`)
|
`K` Move task up within its category (`move_up`)
|
||||||
`zc` Fold the current category section (requires `folding`)
|
`zc` Fold the current category section (requires `folding`)
|
||||||
|
|
@ -413,6 +415,16 @@ old keys to `false`: >lua
|
||||||
Toggle blocked status for the task under the cursor.
|
Toggle blocked status for the task under the cursor.
|
||||||
If the task is already `blocked`, reverts to `pending`.
|
If the task is already `blocked`, reverts to `pending`.
|
||||||
|
|
||||||
|
*<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>`.
|
||||||
|
|
||||||
|
*<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>`.
|
||||||
|
|
||||||
*<Plug>(pending-open-line)*
|
*<Plug>(pending-open-line)*
|
||||||
<Plug>(pending-open-line)
|
<Plug>(pending-open-line)
|
||||||
Insert a correctly-formatted blank task line below the cursor.
|
Insert a correctly-formatted blank task line below the cursor.
|
||||||
|
|
|
||||||
|
|
@ -137,6 +137,8 @@ local defaults = {
|
||||||
move_up = 'K',
|
move_up = 'K',
|
||||||
wip = 'gw',
|
wip = 'gw',
|
||||||
blocked = 'gb',
|
blocked = 'gb',
|
||||||
|
priority_up = '<C-a>',
|
||||||
|
priority_down = '<C-x>',
|
||||||
},
|
},
|
||||||
sync = {},
|
sync = {},
|
||||||
icons = {
|
icons = {
|
||||||
|
|
|
||||||
|
|
@ -363,6 +363,12 @@ function M._setup_buf_mappings(bufnr)
|
||||||
blocked = function()
|
blocked = function()
|
||||||
M.toggle_status('blocked')
|
M.toggle_status('blocked')
|
||||||
end,
|
end,
|
||||||
|
priority_up = function()
|
||||||
|
M.increment_priority()
|
||||||
|
end,
|
||||||
|
priority_down = function()
|
||||||
|
M.decrement_priority()
|
||||||
|
end,
|
||||||
undo = function()
|
undo = function()
|
||||||
M.undo_write()
|
M.undo_write()
|
||||||
end,
|
end,
|
||||||
|
|
@ -646,6 +652,56 @@ function M.toggle_priority()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
---@param delta integer
|
||||||
|
---@return nil
|
||||||
|
local function adjust_priority(delta)
|
||||||
|
local bufnr = buffer.bufnr()
|
||||||
|
if not bufnr then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
if not require_saved() then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
local row = vim.api.nvim_win_get_cursor(0)[1]
|
||||||
|
local meta = buffer.meta()
|
||||||
|
if not meta[row] or meta[row].type ~= 'task' then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
local id = meta[row].id
|
||||||
|
if not id then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
local s = get_store()
|
||||||
|
local task = s:get(id)
|
||||||
|
if not task then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
local max = require('pending.config').get().max_priority or 3
|
||||||
|
local new_priority = math.max(0, math.min(max, task.priority + delta))
|
||||||
|
if new_priority == task.priority then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
s:update(id, { priority = new_priority })
|
||||||
|
_save_and_notify()
|
||||||
|
buffer.render(bufnr)
|
||||||
|
for lnum, m in ipairs(buffer.meta()) do
|
||||||
|
if m.id == id then
|
||||||
|
vim.api.nvim_win_set_cursor(0, { lnum, 0 })
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
---@return nil
|
||||||
|
function M.increment_priority()
|
||||||
|
adjust_priority(1)
|
||||||
|
end
|
||||||
|
|
||||||
|
---@return nil
|
||||||
|
function M.decrement_priority()
|
||||||
|
adjust_priority(-1)
|
||||||
|
end
|
||||||
|
|
||||||
---@return nil
|
---@return nil
|
||||||
function M.prompt_date()
|
function M.prompt_date()
|
||||||
local bufnr = buffer.bufnr()
|
local bufnr = buffer.bufnr()
|
||||||
|
|
@ -1032,7 +1088,13 @@ function M.archive(arg)
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
confirm(
|
confirm(
|
||||||
'Archive ' .. count .. ' task' .. (count == 1 and '' or 's') .. ' completed/deleted more than ' .. days .. 'd ago?',
|
'Archive '
|
||||||
|
.. count
|
||||||
|
.. ' task'
|
||||||
|
.. (count == 1 and '' or 's')
|
||||||
|
.. ' completed/deleted more than '
|
||||||
|
.. days
|
||||||
|
.. 'd ago?',
|
||||||
function()
|
function()
|
||||||
local kept = {}
|
local kept = {}
|
||||||
for _, task in ipairs(tasks) do
|
for _, task in ipairs(tasks) do
|
||||||
|
|
|
||||||
|
|
@ -679,11 +679,13 @@ function M.parse_duration_to_days(s)
|
||||||
end
|
end
|
||||||
n = s:match('^(%d+)w$')
|
n = s:match('^(%d+)w$')
|
||||||
if n then
|
if n then
|
||||||
return tonumber(n) --[[@as integer]] * 7
|
return tonumber(n) --[[@as integer]]
|
||||||
|
* 7
|
||||||
end
|
end
|
||||||
n = s:match('^(%d+)m$')
|
n = s:match('^(%d+)m$')
|
||||||
if n then
|
if n then
|
||||||
return tonumber(n) --[[@as integer]] * 30
|
return tonumber(n) --[[@as integer]]
|
||||||
|
* 30
|
||||||
end
|
end
|
||||||
n = s:match('^(%d+)$')
|
n = s:match('^(%d+)$')
|
||||||
if n then
|
if n then
|
||||||
|
|
|
||||||
|
|
@ -328,6 +328,14 @@ vim.keymap.set('n', '<Plug>(pending-blocked)', function()
|
||||||
require('pending').toggle_status('blocked')
|
require('pending').toggle_status('blocked')
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
vim.keymap.set('n', '<Plug>(pending-priority-up)', function()
|
||||||
|
require('pending').increment_priority()
|
||||||
|
end)
|
||||||
|
|
||||||
|
vim.keymap.set('n', '<Plug>(pending-priority-down)', function()
|
||||||
|
require('pending').decrement_priority()
|
||||||
|
end)
|
||||||
|
|
||||||
vim.keymap.set('n', '<Plug>(pending-filter)', function()
|
vim.keymap.set('n', '<Plug>(pending-filter)', function()
|
||||||
vim.ui.input({ prompt = 'Filter: ' }, function(input)
|
vim.ui.input({ prompt = 'Filter: ' }, function(input)
|
||||||
if input then
|
if input then
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue