diff --git a/doc/pending.txt b/doc/pending.txt index 56a87d5..5543516 100644 --- a/doc/pending.txt +++ b/doc/pending.txt @@ -244,6 +244,7 @@ Default buffer-local keys: ~ `` Toggle complete / uncomplete (`toggle`) `!` Toggle the priority flag (`priority`) `D` Prompt for a due date (`date`) + `F` Prompt for filter predicates (`filter`) `` Switch between category / queue view (`view`) `U` Undo the last `:w` save (`undo`) `o` Insert a new task line below (`open_line`) @@ -309,6 +310,10 @@ All motions support count: `3]]` jumps three headers forward. `]]` and (pending-undo) Undo the last `:w` save. + *(pending-filter)* +(pending-filter) + Prompt for filter predicates via |vim.ui.input|. + *(pending-open-line)* (pending-open-line) Insert a correctly-formatted blank task line below the cursor. @@ -385,7 +390,8 @@ Hidden tasks are preserved in the store and reappear when the filter is cleared. Filter state is session-local — it does not persist across Neovim restarts. -Set a filter with |:Pending-filter| or by editing the `FILTER:` line: >vim +Set a filter with |:Pending-filter|, the `F` buffer key, or by editing the +`FILTER:` line: >vim :Pending filter cat:Work overdue < @@ -567,6 +573,7 @@ loads: >lua priority = '!', date = 'D', undo = 'U', + filter = 'F', open_line = 'o', open_line_above = 'O', a_task = 'at', diff --git a/lua/pending/config.lua b/lua/pending/config.lua index d8df30e..153c71f 100644 --- a/lua/pending/config.lua +++ b/lua/pending/config.lua @@ -21,6 +21,7 @@ ---@field priority? string|false ---@field date? string|false ---@field undo? string|false +---@field filter? string|false ---@field open_line? string|false ---@field open_line_above? string|false ---@field a_task? string|false @@ -67,6 +68,7 @@ local defaults = { priority = '!', date = 'D', undo = 'U', + filter = 'F', open_line = 'o', open_line_above = 'O', a_task = 'at', diff --git a/lua/pending/init.lua b/lua/pending/init.lua index bb17617..12b6a7e 100644 --- a/lua/pending/init.lua +++ b/lua/pending/init.lua @@ -243,6 +243,13 @@ function M._setup_buf_mappings(bufnr) undo = function() M.undo_write() end, + filter = function() + vim.ui.input({ prompt = 'Filter: ' }, function(input) + if input then + M.filter(input) + end + end) + end, open_line = function() buffer.open_line(false) end, diff --git a/plugin/pending.lua b/plugin/pending.lua index 0350b73..f533dcf 100644 --- a/plugin/pending.lua +++ b/plugin/pending.lua @@ -258,6 +258,14 @@ vim.keymap.set('n', '(pending-undo)', function() require('pending').undo_write() end) +vim.keymap.set('n', '(pending-filter)', function() + vim.ui.input({ prompt = 'Filter: ' }, function(input) + if input then + require('pending').filter(input) + end + end) +end) + vim.keymap.set('n', '(pending-open-line)', function() require('pending.buffer').open_line(false) end)