fix(diff): preserve due/rec when absent from buffer line (#68)
* fix(diff): preserve due/rec when absent from buffer line Problem: `diff.apply` overwrites `task.due` and `task.recur` with `nil` whenever those fields aren't present as inline tokens in the buffer line. Because metadata is rendered as virtual text (never in the line text), every description edit silently clears due dates and recurrence rules. Solution: Only update `due`, `recur`, and `recur_mode` in the existing- task branch when the parsed entry actually contains them (non-nil). Users can still set/change these inline by typing `due:<date>` or `rec:<rule>`; clearing them requires `:Pending edit <id> -due`. * refactor: remove project-local store discovery Problem: `store.resolve_path()` searched upward for `.pending.json`, silently splitting task data across multiple files depending on CWD. Solution: `resolve_path()` now always returns `config.get().data_path`. Remove `M.init()` and the `:Pending init` command and tab-completion entry. Remove the project-local health message. * refactor: extract log.lua, standardise [pending.nvim]: prefix Problem: Notifications were scattered across files using bare `vim.notify` with inconsistent `pending.nvim: ` prefixes, and the `debug` guard in `textobj.lua` and `init.lua` was duplicated inline. Solution: Add `lua/pending/log.lua` with `info`, `warn`, `error`, and `debug` functions (prefix `[pending.nvim]: `). `log.debug` only fires when `config.debug = true` or the optional `override` param is `true`. Replace all `vim.notify` callsites and remove inline debug guards. * feat(parse): configurable input date formats Problem: `due:` only accepted ISO `YYYY-MM-DD` and built-in keywords; users expecting locale-style dates like `03/15/2026` or `15-Mar-2026` had no way to configure alternative input formats. Solution: Add `input_date_formats` config field (string[]). Each entry is a strftime-like format string supporting `%Y`, `%y`, `%m`, `%d`, `%e`, `%b`, `%B`. Formats are tried in order after built-in keywords fail. When no year specifier is present the current or next year is inferred. Update vimdoc and add 8 parse_spec tests.
This commit is contained in:
parent
b7ce1c05ec
commit
7fb3289b21
16 changed files with 300 additions and 109 deletions
|
|
@ -504,6 +504,11 @@ token, the `D` prompt, and `:Pending add`.
|
|||
`soy` / `eoy` January 1 / December 31 of current year
|
||||
`later` / `someday` Sentinel date (default: `9999-12-30`)
|
||||
|
||||
Custom formats: ~ *pending-dates-custom*
|
||||
Additional input formats can be configured via `input_date_formats` in
|
||||
|pending-config|. They are tried in order after all built-in keywords fail.
|
||||
See |pending-input-formats| for supported specifiers and examples.
|
||||
|
||||
Time suffix: ~ *pending-dates-time*
|
||||
Any named date or absolute date accepts an `@` time suffix. Supported
|
||||
formats: `HH:MM` (24h), `H:MM`, bare hour (`9`, `14`), and am/pm
|
||||
|
|
@ -636,6 +641,23 @@ Fields: ~
|
|||
virtual text in the buffer. Examples: `'%Y-%m-%d'`
|
||||
for ISO dates, `'%d %b'` for day-first.
|
||||
|
||||
{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
|
||||
built-in keywords or ISO `YYYY-MM-DD` format.
|
||||
Specifiers supported: `%Y` (4-digit year), `%y`
|
||||
(2-digit year, 00–69 → 2000s, 70–99 → 1900s), `%m`
|
||||
(numeric month), `%d` / `%e` (day), `%b` / `%B`
|
||||
(abbreviated or full month name, case-insensitive).
|
||||
When no year specifier is present the current year is
|
||||
used, advancing to next year if the date has already
|
||||
passed. Examples: >lua
|
||||
input_date_formats = {
|
||||
'%m/%d/%Y', -- 03/15/2026
|
||||
'%d-%b-%Y', -- 15-Mar-2026
|
||||
'%m/%d', -- 03/15 (year inferred)
|
||||
}
|
||||
<
|
||||
{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