feat(file-token): add file: inline metadata token with gf navigation
Problem: there was no way to link a task to a specific location in a source file, or to quickly jump from a task to the relevant code. Solution: add a file:<path>:<line> inline token that stores a relative file reference in task._extra.file. Virtual text renders basename:line in a new PendingFile highlight group. A buffer-local gf mapping (configurable via keymaps.goto_file) opens the file at the given line. M.add_here() lets users attach the current cursor position to any task via vim.ui.select(). M.edit() gains -file support to clear the reference. <Plug>(pending-goto-file) and <Plug>(pending-add-here) are exposed for custom mappings.
This commit is contained in:
parent
3da23c924a
commit
7835dc4687
9 changed files with 257 additions and 9 deletions
|
|
@ -12,6 +12,7 @@ local store = require('pending.store')
|
|||
---@field due? string
|
||||
---@field rec? string
|
||||
---@field rec_mode? string
|
||||
---@field file? string
|
||||
---@field lnum integer
|
||||
|
||||
---@class pending.diff
|
||||
|
|
@ -52,6 +53,7 @@ function M.parse_buffer(lines)
|
|||
due = metadata.due,
|
||||
rec = metadata.rec,
|
||||
rec_mode = metadata.rec_mode,
|
||||
file = metadata.file,
|
||||
lnum = i,
|
||||
})
|
||||
end
|
||||
|
|
@ -65,8 +67,9 @@ function M.parse_buffer(lines)
|
|||
end
|
||||
|
||||
---@param lines string[]
|
||||
---@param hidden_ids? table<integer, boolean>
|
||||
---@return nil
|
||||
function M.apply(lines)
|
||||
function M.apply(lines, hidden_ids)
|
||||
local parsed = M.parse_buffer(lines)
|
||||
local now = timestamp()
|
||||
local data = store.data()
|
||||
|
|
@ -127,6 +130,19 @@ function M.apply(lines)
|
|||
task.recur_mode = entry.rec_mode
|
||||
changed = true
|
||||
end
|
||||
local old_file = (task._extra and task._extra.file) or nil
|
||||
if entry.file ~= old_file then
|
||||
task._extra = task._extra or {}
|
||||
if entry.file then
|
||||
task._extra.file = entry.file
|
||||
else
|
||||
task._extra.file = nil
|
||||
if next(task._extra) == nil then
|
||||
task._extra = nil
|
||||
end
|
||||
end
|
||||
changed = true
|
||||
end
|
||||
if entry.status and task.status ~= entry.status then
|
||||
task.status = entry.status
|
||||
if entry.status == 'done' then
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue