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
|
|
@ -136,6 +136,10 @@ local function apply_extmarks(bufnr, line_meta)
|
|||
if m.due then
|
||||
table.insert(virt_parts, { m.due, due_hl })
|
||||
end
|
||||
if m.file then
|
||||
local display = m.file:match('([^/]+:%d+)$') or m.file
|
||||
table.insert(virt_parts, { display, 'PendingFile' })
|
||||
end
|
||||
if #virt_parts > 0 then
|
||||
for p = 1, #virt_parts - 1 do
|
||||
virt_parts[p][1] = virt_parts[p][1] .. ' '
|
||||
|
|
@ -170,6 +174,7 @@ local function setup_highlights()
|
|||
vim.api.nvim_set_hl(0, 'PendingDone', { link = 'Comment', default = true })
|
||||
vim.api.nvim_set_hl(0, 'PendingPriority', { link = 'DiagnosticWarn', default = true })
|
||||
vim.api.nvim_set_hl(0, 'PendingRecur', { link = 'DiagnosticInfo', default = true })
|
||||
vim.api.nvim_set_hl(0, 'PendingFile', { link = 'Directory', default = true })
|
||||
end
|
||||
|
||||
local function snapshot_folds(bufnr)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue