fix(buffer): conceal in all modes, forge EOL labels, remove dash prefix (#167)
* fix(buffer): keep conceal active in all modes and add `%l` EOL forge labels Problem: `concealcursor` was missing `i` and `v`, so concealed text (task IDs, forge tokens) leaked in insert and visual modes. Forge labels only rendered for the first span when multiple refs existed. Solution: set `concealcursor = 'nicv'` to keep conceal in all modes. Add `%l` EOL format specifier that renders all forge spans with independent highlights. Update default `eol_format` to include `%l`. * refactor: remove `- ` prefix from task line rendering Problem: task lines rendered as `- [ ] description` with a redundant markdown list marker prefix that added visual noise. Solution: render task lines as `[ ] description` instead. Update all line generation in `views.lua`, parsing patterns in `buffer.lua`, `diff.lua`, `textobj.lua`, syntax rules, and corresponding specs.
This commit is contained in:
parent
1266eaedd8
commit
98e4abffc7
12 changed files with 156 additions and 141 deletions
|
|
@ -183,14 +183,10 @@ local function apply_inline_row(bufnr, row, m, icons)
|
|||
invalidate = true,
|
||||
})
|
||||
if m.forge_spans then
|
||||
local forge = require('pending.forge')
|
||||
for _, span in ipairs(m.forge_spans) do
|
||||
local label_text, hl_group = forge.format_label(span.ref, span.cache)
|
||||
vim.api.nvim_buf_set_extmark(bufnr, ns_inline, row, span.col_start, {
|
||||
end_col = span.col_end,
|
||||
conceal = '',
|
||||
virt_text = { { label_text, hl_group } },
|
||||
virt_text_pos = 'inline',
|
||||
priority = 90,
|
||||
invalidate = true,
|
||||
})
|
||||
|
|
@ -215,7 +211,7 @@ end
|
|||
---@param line string
|
||||
---@return string?
|
||||
local function infer_status(line)
|
||||
local ch = line:match('^/%d+/%- %[(.)%]') or line:match('^%- %[(.)%]')
|
||||
local ch = line:match('^/%d+/%[(.)%]') or line:match('^%[(.)%]')
|
||||
if not ch then
|
||||
return nil
|
||||
end
|
||||
|
|
@ -399,7 +395,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 = 'nicv'
|
||||
vim.wo[winid].winfixheight = true
|
||||
end
|
||||
|
||||
|
|
@ -411,7 +407,7 @@ local function setup_syntax(bufnr)
|
|||
syntax match taskId /^\/\d\+\// conceal
|
||||
syntax match taskHeader /^# .*$/ contains=taskId
|
||||
syntax match taskCheckbox /\[!\]/ contained containedin=taskLine
|
||||
syntax match taskLine /^\/\d\+\/- \[.\] .*$/ contains=taskId,taskCheckbox
|
||||
syntax match taskLine /^\/\d\+\/\[.\] .*$/ contains=taskId,taskCheckbox
|
||||
]])
|
||||
end)
|
||||
end
|
||||
|
|
@ -429,7 +425,7 @@ function M.open_line(above)
|
|||
|
||||
_rendering = true
|
||||
vim.bo[bufnr].modifiable = true
|
||||
vim.api.nvim_buf_set_lines(bufnr, insert_row, insert_row, false, { '- [ ] ' })
|
||||
vim.api.nvim_buf_set_lines(bufnr, insert_row, insert_row, false, { '[ ] ' })
|
||||
_rendering = false
|
||||
|
||||
table.insert(_meta, meta_pos, { type = 'task' })
|
||||
|
|
@ -444,7 +440,7 @@ function M.open_line(above)
|
|||
end
|
||||
end
|
||||
|
||||
vim.api.nvim_win_set_cursor(0, { insert_row + 1, 6 })
|
||||
vim.api.nvim_win_set_cursor(0, { insert_row + 1, 4 })
|
||||
vim.cmd('startinsert!')
|
||||
end
|
||||
|
||||
|
|
@ -478,7 +474,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' then
|
||||
if key == 'c' or key == 'r' or key == 'd' or key == 'l' then
|
||||
table.insert(segments, { type = 'specifier', key = key })
|
||||
pos = pos + 2
|
||||
else
|
||||
|
|
@ -514,8 +510,21 @@ local function build_eol_virt(segments, m, icons)
|
|||
elseif seg.key == 'd' and m.due then
|
||||
text = icons.due .. ' ' .. m.due
|
||||
hl = due_hl
|
||||
elseif seg.key == 'l' and m.forge_spans and #m.forge_spans > 0 then
|
||||
local forge = require('pending.forge')
|
||||
local parts = {}
|
||||
for j, span in ipairs(m.forge_spans) do
|
||||
local lt, lh = forge.format_label(span.ref, span.cache)
|
||||
if j > 1 then
|
||||
table.insert(parts, { text = ' ', hl = 'Normal' })
|
||||
end
|
||||
table.insert(parts, { text = lt, hl = lh })
|
||||
end
|
||||
resolved[i] = { multi = parts, present = true }
|
||||
end
|
||||
if not resolved[i] then
|
||||
resolved[i] = text and { text = text, hl = hl, present = true } or { present = false }
|
||||
end
|
||||
resolved[i] = text and { text = text, hl = hl, present = true } or { present = false }
|
||||
else
|
||||
resolved[i] = { text = seg.text, hl = 'Normal', literal = true }
|
||||
end
|
||||
|
|
@ -533,7 +542,13 @@ local function build_eol_virt(segments, m, icons)
|
|||
table.insert(virt_parts, pending_sep)
|
||||
pending_sep = nil
|
||||
end
|
||||
table.insert(virt_parts, { r.text, r.hl })
|
||||
if r.multi then
|
||||
for _, part in ipairs(r.multi) do
|
||||
table.insert(virt_parts, { part.text, part.hl })
|
||||
end
|
||||
else
|
||||
table.insert(virt_parts, { r.text, r.hl })
|
||||
end
|
||||
else
|
||||
pending_sep = nil
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue