feat(13.1): colorize + color_dic → ColorNode renderer
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:
@@ -559,8 +559,37 @@ function! nuwiki#commands#table_move_right() abort
|
||||
\ }]
|
||||
call s:exec('nuwiki.table.moveColumn', l:args)
|
||||
endfunction
|
||||
function! nuwiki#commands#colorize(color) abort
|
||||
call s:notify_deferred(':VimwikiColorize')
|
||||
" `:VimwikiColorize {color}` — pure-VimL wrap as inline span tag,
|
||||
" matching vimwiki's `<span style="color:%c">%s</span>` template.
|
||||
function! nuwiki#commands#colorize(...) abort
|
||||
let l:color = a:0 >= 1 ? a:1 : ''
|
||||
if l:color ==# ''
|
||||
let l:color = input('Colour: ')
|
||||
endif
|
||||
if l:color ==# ''
|
||||
return
|
||||
endif
|
||||
let l:open_tag = '<span style="color:' . l:color . '">'
|
||||
let l:close_tag = '</span>'
|
||||
let l:line = getline('.')
|
||||
let l:col = col('.')
|
||||
" Word boundaries around cursor (1-based).
|
||||
let l:left = l:col
|
||||
while l:left > 1 && strpart(l:line, l:left - 2, 1) =~# '[A-Za-z0-9_-]'
|
||||
let l:left -= 1
|
||||
endwhile
|
||||
let l:right = l:col
|
||||
while l:right <= strlen(l:line) && strpart(l:line, l:right - 1, 1) =~# '[A-Za-z0-9_-]'
|
||||
let l:right += 1
|
||||
endwhile
|
||||
let l:word = strpart(l:line, l:left - 1, l:right - l:left)
|
||||
if l:word ==# ''
|
||||
return
|
||||
endif
|
||||
let l:new = strpart(l:line, 0, l:left - 1)
|
||||
\ . l:open_tag . l:word . l:close_tag
|
||||
\ . strpart(l:line, l:right - 1)
|
||||
call setline('.', l:new)
|
||||
endfunction
|
||||
" §13.1 Cluster C — link helpers.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user