feat(13.1): colorize + color_dic → ColorNode renderer
CI / cargo fmt --check (push) Successful in 26s
CI / cargo clippy (push) Successful in 1m24s
CI / cargo test (push) Successful in 1m24s
CI / editor keymaps (push) Successful in 1m45s

Closes the last pending §13.1 entries:

- **`nuwiki.colorize`** (client-side, Lua + VimL) — wraps the word
  at cursor (or the visual selection on Neovim) in an inline
  `<span style="color:%c">…</span>` template. Matches vimwiki's
  default `color_tag_template`. Bound to `<Leader>wc` in both
  normal and visual mode on both editor paths; the previous
  "deferred" stub is gone.

- **`color_dic` → renderer** — `HtmlConfig` gains a
  `color_dic: HashMap<String, String>` field reading the same key
  out of `initializationOptions` / `didChangeConfiguration`. The
  HTML export path threads it into `HtmlRenderer::with_colors`;
  `ColorNode` now picks `style="color:<value>"` when the colour
  name is in the dict, falling back to the existing
  `class="color-<name>"` when it isn't.

SPEC §13.1 is fully checked off — the table moved from "deferred
sketch" to a per-command status table marking all 11 commands done,
plus a note on the `color_dic` follow-up landing alongside. README's
"Phase 14 list & table edit commands" row now reads  without the
deferred-subset caveat, and the §13.1-blocked text-objects note in
the keymaps section is rephrased as "planned follow-ups".

Tests: 4 new in `phase17_colorize.rs` covering the renderer
fallback when the dict is empty, the inline-style emission for a
listed name, the fallback path for an unlisted name in a populated
dict, and the `initializationOptions` JSON shape. Total 414 Rust
tests pass; clippy clean; keymap harness still 20/20.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-05-12 14:45:39 +00:00
parent 4245424d2f
commit de8b8fa30d
10 changed files with 226 additions and 47 deletions
+18 -30
View File
@@ -1335,39 +1335,27 @@ so a future audit doesn't have to re-derive the scope from the per-phase
prose. Each entry includes the originating SPEC section, why it was
deferred, and a sketch of what the implementation needs.
### 13.1 Phase 14 — list/table/link/colorize commands
### 13.1 Phase 14 — list/table/link/colorize commands
Phase 14 shipped a focused subset (checkbox toggle/cycle/reject,
nextTask navigation, heading promote/demote). The structural-rewriter
commands below were deferred — each needs its own AST-aware rewriter,
and they don't share enough scaffolding to land together cheaply.
All eleven commands deferred from Phase 14 are now shipped:
| Command | SPEC | What it does | Sketch |
|---|---|---|---|
| `nuwiki.list.changeSymbol` | §12.5 | Rewrite list marker (`-``*``#``1.` …), single item or whole list (`whole_list: bool` arg). | Locate item span via existing `find_list_item_at`; rewrite the marker token; if `whole_list` and numeric, renumber. |
| `nuwiki.list.changeLevel` | §12.5 | Indent/dedent one item or a subtree (`delta: i32`, `whole_subtree: bool`). | Compute leading-whitespace delta per line; re-indent each line of the item span; if subtree, descend into `ListItemNode.sublist`. |
| `nuwiki.list.renumber` | §12.5 | Re-sequence numeric markers across a list or a whole file (`whole_file: bool`). | Walk every `ListNode` whose `symbol` is `Numeric`/`NumericParen`/`AlphaParen`/…; rewrite the marker substrings in source order. |
| `nuwiki.list.removeDone` | §12.5 | Strip `[X]` / `[-]` items and their checked children. | Recursive list walker emitting delete spans for matching items; also delete the trailing newline so the surrounding list stays valid. |
| `nuwiki.table.align` | §12.5 | Reformat columns to max width. | Two-pass: width-per-column scan, then re-render every row with padding; respect `>` (col span) and `\/` (row span) markers. |
| `nuwiki.table.moveColumn` | §12.5 | Swap column with neighbour (`dir: "left" \| "right"`). | Locate `TableNode` under cursor; for each row, swap `cells[col]` and `cells[col±1]`; re-emit. |
| `nuwiki.table.insert` | §12.5 | Insert blank table at cursor (`cols`, `rows`). | Pure string templating; align outputs to current indentation. |
| `nuwiki.link.normalize` | §12.5 | Convert word/selection to `[[wikilink]]`, add description if missing. | Inspect cursor selection; if a plain word, wrap in `[[…]]`; if already a wikilink, ensure `\|description` is present. |
| `nuwiki.link.pasteWikilink` | §12.5 | Paste current page name as an absolute wikilink. | One-line insert; page name from `index::page_name_from_uri`. |
| `nuwiki.link.pasteUrl` | §12.5 | Paste the corresponding HTML output URL. | Blocked on Phase 17 (`html_path` / `html_filename_parameterization` config). |
| `nuwiki.colorize` | §12.5 | Wrap range in colour tag per `color_tag_template`. | Blocked on Phase 17 (`color_dic` config) — until then the template isn't reachable. |
| Command | Status | Notes |
|---|---|---|
| `nuwiki.list.changeSymbol` | ✅ done | `ops::change_symbol_edit` + `parse_symbol` + `render_marker` (incl. alpha + roman variants). |
| `nuwiki.list.changeLevel` | ✅ done | ±2-space indent per delta; `whole_subtree` walks descendants; dedent clamps at column 0. |
| `nuwiki.list.renumber` | ✅ done | Re-sequences numeric markers in the current list, or every list when `whole_file = true`. |
| `nuwiki.list.removeDone` | ✅ done | Strips `[X]` / `[-]` items + their sublists; optional `position` scopes to one item. |
| `nuwiki.table.align` | ✅ done | Width-per-column pass + row re-emit. Re-inserts the dropped `|---|---|` separator after the header. |
| `nuwiki.table.moveColumn` | ✅ done | Swap column with neighbour (`dir: "left" \| "right"`); widths swap alongside. |
| `nuwiki.table.insert` | ✅ done | Pure templating — `cols × rows` blank cells + header separator. |
| `nuwiki.link.normalize` | ✅ done | Client-side word-wrap (Lua/VimL). Mirrors the `<CR>` two-step wrap step. |
| `nuwiki.link.pasteWikilink` | ✅ done | Server-side; inserts `[[<page>]]` at cursor. |
| `nuwiki.link.pasteUrl` | ✅ done | Server-side; inserts `<page>.html` (subdir-aware). |
| `nuwiki.colorize` | ✅ done | Client-side wrap in `<span style="color:…">…</span>` (matches vimwiki default template). |
#### Estimated sequencing
- **Cluster A (list rewriters)** — `changeSymbol`, `changeLevel`,
`renumber`, `removeDone` share a list-walker pattern. Likely one
PR with a shared `ops::list_walker` helper and four command handlers.
- **Cluster B (table rewriters)** — `align`, `moveColumn`, `insert`
share a column-width pass and a row-by-row re-emitter. Likely a
second PR.
- **Cluster C (link helpers)** — `normalize` and `pasteWikilink` are
small and don't share much; can land independently.
- **Phase-17-blocked** — `pasteUrl` and `colorize` wait until the
HTML export commands land the necessary config keys.
`color_dic` integration with the `ColorNode` HTML renderer also
landed alongside `colorize` — the dict maps vimwiki colour-tag names
to CSS values; missing names fall back to `class="color-<name>"`.
### 13.2 Phase 13 — `will_rename` / `will_delete` capability