feat(buffer): add configurable category-level folds
Problem: category folds were hardcoded with no config option, no custom foldtext, and no vimdoc coverage. Solution: add `folding` config field (boolean or table with `foldtext` format string). Default foldtext is `%c (%n tasks)` with automatic singular/plural. Gate all fold logic on the config so `folding = false` disables folds entirely. Document the new option in vimdoc.
This commit is contained in:
parent
12b9295c34
commit
03d3ac5851
3 changed files with 84 additions and 6 deletions
|
|
@ -1,3 +1,10 @@
|
|||
---@class pending.FoldingConfig
|
||||
---@field foldtext? string|false
|
||||
|
||||
---@class pending.ResolvedFolding
|
||||
---@field enabled boolean
|
||||
---@field foldtext string|false
|
||||
|
||||
---@class pending.Icons
|
||||
---@field pending string
|
||||
---@field done string
|
||||
|
|
@ -55,6 +62,7 @@
|
|||
---@field drawer_height? integer
|
||||
---@field debug? boolean
|
||||
---@field keymaps pending.Keymaps
|
||||
---@field folding? boolean|pending.FoldingConfig
|
||||
---@field sync? pending.SyncConfig
|
||||
---@field icons pending.Icons
|
||||
|
||||
|
|
@ -70,6 +78,7 @@ local defaults = {
|
|||
date_syntax = 'due',
|
||||
recur_syntax = 'rec',
|
||||
someday_date = '9999-12-30',
|
||||
folding = true,
|
||||
category_order = {},
|
||||
keymaps = {
|
||||
close = 'q',
|
||||
|
|
@ -119,4 +128,15 @@ function M.reset()
|
|||
_resolved = nil
|
||||
end
|
||||
|
||||
---@return pending.ResolvedFolding
|
||||
function M.resolve_folding()
|
||||
local raw = M.get().folding
|
||||
if raw == false then
|
||||
return { enabled = false, foldtext = false }
|
||||
elseif raw == true or raw == nil then
|
||||
return { enabled = true, foldtext = '%c (%n tasks)' }
|
||||
end
|
||||
return { enabled = true, foldtext = raw.foldtext or false }
|
||||
end
|
||||
|
||||
return M
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue