diff --git a/doc/pending.txt b/doc/pending.txt index 9ec9b34..58ad4e0 100644 --- a/doc/pending.txt +++ b/doc/pending.txt @@ -842,7 +842,6 @@ Fields: ~ {eol_format} (string, default: '%c %r %d') Format string for end-of-line virtual text. Specifiers: - `%l` forge link label (`PendingForge`) `%c` category icon + name (`PendingHeader`) `%r` recurrence icon + pattern (`PendingRecur`) `%d` due icon + date (`PendingDue`/`PendingOverdue`) @@ -1486,10 +1485,6 @@ inline with a formatted label using overlay extmarks (same technique as checkbox icons). Multiple forge references in one line are each overlaid independently. -The `%l` specifier in `eol_format` is still supported for users who prefer -the link label in EOL virtual text, but it is no longer in the default -format (`'%c %r %d'`). - Format string: ~ *pending-forge-format* Each forge has a configurable `issue_format` string with these placeholders: @@ -1505,6 +1500,7 @@ Configuration: ~ >lua vim.g.pending = { forge = { + auto_close = false, github = { token = nil, icon = '', @@ -1527,6 +1523,11 @@ Configuration: ~ } < +Top-level fields: ~ + {auto_close} (boolean, default: false) When true, tasks linked to + closed/merged remote issues are automatically marked + done on buffer open. + Fields (per forge): ~ {token} (string, optional) API token for authenticated requests. Falls back to CLI: `gh auth token` (GitHub), `glab auth @@ -1551,9 +1552,10 @@ than 5 minutes are re-fetched asynchronously. The buffer renders immediately with cached data and updates extmarks when the fetch completes. State pull: ~ -After fetching, if the remote issue/PR is closed or merged and the local -task is pending/wip/blocked, the task is automatically marked as done. This -is one-way: local status changes do not push back to the forge. +Requires `forge.auto_close = true`. After fetching, if the remote issue/PR +is closed or merged and the local task is pending/wip/blocked, the task is +automatically marked as done. Disabled by default. One-way: local status +changes do not push back to the forge. Highlight groups: ~ |PendingForge| Open issue/PR link label diff --git a/lua/pending/buffer.lua b/lua/pending/buffer.lua index e162f67..8c0433e 100644 --- a/lua/pending/buffer.lua +++ b/lua/pending/buffer.lua @@ -379,7 +379,7 @@ end ---@param winid integer local function set_win_options(winid) vim.wo[winid].conceallevel = 3 - vim.wo[winid].concealcursor = 'nc' + vim.wo[winid].concealcursor = 'nic' vim.wo[winid].winfixheight = true end @@ -446,7 +446,7 @@ end ---@class pending.EolSegment ---@field type 'specifier'|'literal' ----@field key? 'c'|'r'|'d'|'l' +---@field key? 'c'|'r'|'d' ---@field text? string ---@param fmt string @@ -458,7 +458,7 @@ local function parse_eol_format(fmt) while pos <= len do if fmt:sub(pos, pos) == '%' and pos + 1 <= len then local key = fmt:sub(pos + 1, pos + 1) - if key == 'c' or key == 'r' or key == 'd' or key == 'l' then + if key == 'c' or key == 'r' or key == 'd' then table.insert(segments, { type = 'specifier', key = key }) pos = pos + 2 else @@ -485,10 +485,7 @@ local function build_eol_virt(segments, m, icons) for i, seg in ipairs(segments) do if seg.type == 'specifier' then local text, hl - if seg.key == 'l' and m.forge_ref then - local forge = require('pending.forge') - text, hl = forge.format_label(m.forge_ref, m.forge_cache) - elseif seg.key == 'c' and m.show_category and m.category then + if seg.key == 'c' and m.show_category and m.category then text = icons.category .. ' ' .. m.category hl = 'PendingHeader' elseif seg.key == 'r' and m.recur then diff --git a/lua/pending/config.lua b/lua/pending/config.lua index 842dfc0..4c35348 100644 --- a/lua/pending/config.lua +++ b/lua/pending/config.lua @@ -40,6 +40,7 @@ ---@field instances? string[] ---@class pending.ForgeConfig +---@field auto_close? boolean ---@field github? pending.ForgeInstanceConfig ---@field gitlab? pending.ForgeInstanceConfig ---@field codeberg? pending.ForgeInstanceConfig @@ -154,18 +155,19 @@ local defaults = { }, sync = {}, forge = { + auto_close = false, github = { - icon = '', + icon = '', issue_format = '%i %o/%r#%n', instances = {}, }, gitlab = { - icon = '', + icon = '', issue_format = '%i %o/%r#%n', instances = {}, }, codeberg = { - icon = '', + icon = '', issue_format = '%i %o/%r#%n', instances = {}, }, diff --git a/lua/pending/forge.lua b/lua/pending/forge.lua index d2092e4..c7724f8 100644 --- a/lua/pending/forge.lua +++ b/lua/pending/forge.lua @@ -396,8 +396,10 @@ function M.refresh(s) if cache then task._extra._forge_cache = cache any_fetched = true + local forge_cfg = config.get().forge or {} if - (cache.state == 'closed' or cache.state == 'merged') + forge_cfg.auto_close + and (cache.state == 'closed' or cache.state == 'merged') and (task.status == 'pending' or task.status == 'wip' or task.status == 'blocked') then task.status = 'done' diff --git a/lua/pending/views.lua b/lua/pending/views.lua index fd76a49..b1e691e 100644 --- a/lua/pending/views.lua +++ b/lua/pending/views.lua @@ -19,8 +19,6 @@ local parse = require('pending.parse') ---@field show_category? boolean ---@field priority? integer ---@field recur? string ----@field forge_ref? pending.ForgeRef ----@field forge_cache? pending.ForgeCache ---@field forge_spans? pending.ForgeLineMeta[] ---@class pending.views @@ -219,8 +217,6 @@ function M.category_view(tasks) priority = task.priority, overdue = task.status ~= 'done' and task.due ~= nil and parse.is_overdue(task.due) or nil, recur = task.recur, - forge_ref = task._extra and task._extra._forge_ref or nil, - forge_cache = task._extra and task._extra._forge_cache or nil, forge_spans = compute_forge_spans(task, prefix_len), }) end