refactor(config): nest view settings under view key (#103)
Problem: View-related config fields (`default_view`, `eol_format`, `category_order`, `folding`) are scattered as top-level siblings alongside unrelated fields like `data_path` and `date_syntax`. Solution: Group them under a `view` table with per-view sub-tables: `view.default`, `view.eol_format`, `view.category.order`, `view.category.folding`, and `view.queue` (empty, ready for #100). Update all call sites, tests, and vimdoc.
This commit is contained in:
parent
91cce0a82e
commit
a43f769383
5 changed files with 82 additions and 73 deletions
113
doc/pending.txt
113
doc/pending.txt
|
|
@ -589,14 +589,20 @@ Configuration is done via `vim.g.pending`. Set this before the plugin
|
|||
loads: >lua
|
||||
vim.g.pending = {
|
||||
data_path = vim.fn.stdpath('data') .. '/pending/tasks.json',
|
||||
default_view = 'category',
|
||||
default_category = 'Todo',
|
||||
date_format = '%b %d',
|
||||
date_syntax = 'due',
|
||||
recur_syntax = 'rec',
|
||||
someday_date = '9999-12-30',
|
||||
folding = true,
|
||||
category_order = {},
|
||||
view = {
|
||||
default = 'category',
|
||||
eol_format = '%c %r %d',
|
||||
category = {
|
||||
order = {},
|
||||
folding = true,
|
||||
},
|
||||
queue = {},
|
||||
},
|
||||
keymaps = {
|
||||
close = 'q',
|
||||
toggle = '<CR>',
|
||||
|
|
@ -634,10 +640,6 @@ Fields: ~
|
|||
See |pending-store-resolution| for how the active
|
||||
store is chosen at runtime.
|
||||
|
||||
{default_view} ('category'|'priority', default: 'category')
|
||||
The view to use when the buffer is opened for the
|
||||
first time in a session.
|
||||
|
||||
{default_category} (string, default: 'Todo')
|
||||
Category assigned to new tasks when no `cat:` token
|
||||
is present and no `Category: ` prefix is used with
|
||||
|
|
@ -648,32 +650,6 @@ Fields: ~
|
|||
virtual text in the buffer. Examples: `'%Y-%m-%d'`
|
||||
for ISO dates, `'%d %b'` for day-first.
|
||||
|
||||
{eol_format} (string, default: '%c %r %d')
|
||||
Format string controlling the order, content, and
|
||||
separators of end-of-line virtual text on task lines.
|
||||
Three specifiers are available:
|
||||
|
||||
`%c` category icon + name (`PendingHeader`)
|
||||
`%r` recurrence icon + pattern (`PendingRecur`)
|
||||
`%d` due icon + date (`PendingDue` / `PendingOverdue`)
|
||||
|
||||
Literal text between specifiers is rendered with the
|
||||
`Normal` highlight group and acts as a separator.
|
||||
When a specifier's data is absent (e.g. `%d` on a
|
||||
task with no due date), the specifier and any
|
||||
surrounding literal text up to the next specifier
|
||||
are omitted — missing fields never leave gaps.
|
||||
|
||||
`%c` only renders in priority view (where
|
||||
`show_category` is true). In category view it is
|
||||
always omitted regardless of the format string.
|
||||
|
||||
Examples: >lua
|
||||
vim.g.pending = { eol_format = '%d %r' }
|
||||
vim.g.pending = { eol_format = '%d | %r' }
|
||||
vim.g.pending = { eol_format = '%c %d %r' }
|
||||
<
|
||||
|
||||
{input_date_formats} (string[], default: {}) *pending-input-formats*
|
||||
List of strftime-like format strings tried in order
|
||||
when parsing a `due:` token that does not match the
|
||||
|
|
@ -705,38 +681,57 @@ Fields: ~
|
|||
The date that `later` and `someday` resolve to. This
|
||||
acts as a "no date" sentinel for GTD-style workflows.
|
||||
|
||||
{category_order} (string[], default: {})
|
||||
Ordered list of category names. In category view,
|
||||
categories that appear in this list are shown in the
|
||||
given order. Categories not in the list are appended
|
||||
after the ordered ones in their natural order.
|
||||
{view} (table) *pending.ViewConfig*
|
||||
View rendering configuration. Groups all settings
|
||||
that affect how the buffer displays tasks.
|
||||
|
||||
{folding} (boolean|table, default: true) *pending.FoldingConfig*
|
||||
Controls category-level folds in category view. When
|
||||
`true`, folds are enabled with the default foldtext
|
||||
`'%c (%n tasks)'`. When `false`, folds are disabled
|
||||
entirely. When a table, folds are enabled and the
|
||||
table may contain:
|
||||
{default} ('category'|'priority', default: 'category')
|
||||
The view to use when the buffer is opened
|
||||
for the first time in a session.
|
||||
|
||||
{foldtext} (string|false, default: '%c (%n tasks)')
|
||||
Custom foldtext format string. Set to
|
||||
`false` to use Vim's built-in
|
||||
foldtext. Two specifiers are
|
||||
available:
|
||||
`%c` category name
|
||||
`%n` number of tasks in the fold
|
||||
The category icon is prepended
|
||||
automatically. When `false`, the
|
||||
default Vim foldtext is used.
|
||||
{eol_format} (string, default: '%c %r %d')
|
||||
Format string for end-of-line virtual text.
|
||||
Specifiers:
|
||||
`%c` category icon + name (`PendingHeader`)
|
||||
`%r` recurrence icon + pattern (`PendingRecur`)
|
||||
`%d` due icon + date (`PendingDue`/`PendingOverdue`)
|
||||
Literal text between specifiers acts as a
|
||||
separator. Absent fields and surrounding
|
||||
literals are collapsed automatically. `%c`
|
||||
only renders in priority view.
|
||||
|
||||
Folds only apply to category view; priority view
|
||||
is always fold-free regardless of this setting.
|
||||
{category} (table) *pending.CategoryViewConfig*
|
||||
Category view settings.
|
||||
|
||||
{order} (string[], default: {})
|
||||
Ordered list of category names. Categories
|
||||
in this list appear in the given order;
|
||||
others are appended after.
|
||||
|
||||
{folding} (boolean|table, default: true)
|
||||
*pending.FoldingConfig*
|
||||
Controls category-level folds. `true`
|
||||
enables with default foldtext `'%c (%n
|
||||
tasks)'`. `false` disables entirely. A
|
||||
table may contain:
|
||||
{foldtext} (string|false) Format string
|
||||
with `%c` (category) and `%n` (count).
|
||||
`false` uses Vim's built-in foldtext.
|
||||
Folds only apply to category view.
|
||||
|
||||
{queue} (table) *pending.QueueViewConfig*
|
||||
Queue (priority) view settings.
|
||||
|
||||
Examples: >lua
|
||||
vim.g.pending = { folding = true }
|
||||
vim.g.pending = { folding = false }
|
||||
vim.g.pending = {
|
||||
folding = { foldtext = '%c (%n tasks)' },
|
||||
view = {
|
||||
default = 'priority',
|
||||
eol_format = '%d | %r',
|
||||
category = {
|
||||
order = { 'Work', 'Personal' },
|
||||
folding = { foldtext = '%c: %n items' },
|
||||
},
|
||||
},
|
||||
}
|
||||
<
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue