refactor: tighten LuaCATS annotations and canonicalize metadata fields (#141)
* refactor: tighten LuaCATS annotations across modules Problem: type annotations repeated inline unions with no aliases, used `table<string, any>` where structured types exist, and had loose `string` where union types should be used. Solution: add `pending.TaskStatus`, `pending.RecurMode`, `pending.TaskExtra`, `pending.ForgeType`, `pending.ForgeState`, `pending.ForgeAuthStatus` aliases and `pending.SyncBackend` interface. Replace inline unions and loose types with the new aliases in `store.lua`, `forge.lua`, `config.lua`, `diff.lua`, `views.lua`, `parse.lua`, `init.lua`, and `oauth.lua`. * refactor: canonicalize internal metadata field names Problem: `pending.Metadata` used shorthand field names (`cat`, `rec`, `rec_mode`) matching user-facing token syntax, coupling internal representation to config. `RecurSpec.from_completion` used a boolean where a `pending.RecurMode` alias exists. `category_syntax` was hardcoded to `'cat'` with no config option. Solution: rename `Metadata` fields to `category`/`recur`/`recur_mode`, add `category_syntax` config option (default `'cat'`), rename `ParsedEntry` fields to match, replace `RecurSpec.from_completion` with `mode: pending.RecurMode`, and restore `[string]` indexer on `pending.ForgeConfig` alongside explicit fields.
This commit is contained in:
parent
46b5d52b60
commit
939251f629
16 changed files with 144 additions and 80 deletions
|
|
@ -605,9 +605,10 @@ Supported tokens: ~
|
|||
`cat:Name` Move the task to the named category on save.
|
||||
`rec:<pattern>` Set a recurrence rule (see |pending-recurrence|).
|
||||
|
||||
The token name for due dates defaults to `due` and is configurable via
|
||||
`date_syntax` in |pending-config|. The token name for recurrence defaults to
|
||||
`rec` and is configurable via `recur_syntax`.
|
||||
The token name for categories defaults to `cat` and is configurable via
|
||||
`category_syntax` in |pending-config|. The token name for due dates defaults
|
||||
to `due` and is configurable via `date_syntax`. The token name for recurrence
|
||||
defaults to `rec` and is configurable via `recur_syntax`.
|
||||
|
||||
Example: >
|
||||
|
||||
|
|
@ -734,6 +735,7 @@ loads: >lua
|
|||
data_path = vim.fn.stdpath('data') .. '/pending/tasks.json',
|
||||
default_category = 'Todo',
|
||||
date_format = '%b %d',
|
||||
category_syntax = 'cat',
|
||||
date_syntax = 'due',
|
||||
recur_syntax = 'rec',
|
||||
someday_date = '9999-12-30',
|
||||
|
|
@ -817,6 +819,12 @@ Fields: ~
|
|||
'%m/%d', -- 03/15 (year inferred)
|
||||
}
|
||||
<
|
||||
{category_syntax} (string, default: 'cat')
|
||||
The token name for inline category metadata. Change
|
||||
this to use a different keyword, for example
|
||||
`'category'` to write `category:Work` instead of
|
||||
`cat:Work`.
|
||||
|
||||
{date_syntax} (string, default: 'due')
|
||||
The token name for inline due-date metadata. Change
|
||||
this to use a different keyword, for example `'by'`
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue