feat(client): conceal colour spans down to their coloured text
A :VimwikiColorize'd word showed the literal `<span style="color:NAME">TEXT</span>` markup. Now the tags are concealed and TEXT is painted in NAME, so the buffer shows just the coloured word — matching the HTML export. New autoload/nuwiki/colors.vim: nuwiki#colors#refresh() scans the buffer and, per distinct colour, defines a syntax region that conceals the `<span …>` / `</span>` tags (concealends) and highlights the body with the span's actual colour (guifg always; ctermfg for named colours). Idempotent (clears the group before redefining) and tracked in b:nuwiki_color_seen. Refresh is driven from three places so it's both correct and immediate: - syntax/vimwiki.vim: initial pass + re-establish after :colorscheme reload (resets the per-buffer cache since :syntax clear drops the regions); - ftplugin TextChanged/InsertLeave autocmd for spans that arrive via paste/ undo/external edits; - colorize() itself calls refresh() right after wrapping, so a freshly colorized word conceals instantly (TextChanged doesn't fire reliably mid command / in headless ex-mode). The LSP @vimwikiColor token no longer links to Constant, so in Neovim it doesn't override the real per-span colour on the concealed text. Pure syntax + :highlight — works identically in Vim, coc.nvim, and Neovim, no LSP needed. Tests: colorize.conceal_hides_tags_shows_text (both harnesses) and colorize.command_conceals_immediately (vim). Sample wiki's colorize section notes the conceal. nvim 269, vim 259+18, config-parity green. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
+10
-1
@@ -54,9 +54,12 @@ if has('nvim')
|
||||
|
||||
" Misc.
|
||||
highlight default link @vimwikiKeyword Todo
|
||||
highlight default link @vimwikiColor Constant
|
||||
highlight default link @vimwikiComment Comment
|
||||
highlight default link @vimwikiDefinitionTerm Statement
|
||||
" NOTE: no default for @vimwikiColor. Colour spans are coloured client-side
|
||||
" in their *actual* colour by nuwiki#colors#refresh() (conceal + per-colour
|
||||
" highlight); linking the LSP token to a fixed group here would override that
|
||||
" real colour on the concealed text in Neovim.
|
||||
endif
|
||||
|
||||
" ===== Static fallback (no LSP required) =====
|
||||
@@ -205,4 +208,10 @@ endfunction
|
||||
|
||||
call s:nuwiki_setup_nested()
|
||||
|
||||
" Conceal `:VimwikiColorize` spans (`<span style="color:…">…</span>`) down to
|
||||
" their coloured text. Reset the per-buffer cache first so a syntax reload
|
||||
" (e.g. on :colorscheme) re-establishes the regions cleared by `:syntax clear`.
|
||||
let b:nuwiki_color_seen = {}
|
||||
call nuwiki#colors#refresh()
|
||||
|
||||
let b:current_syntax = 'vimwiki'
|
||||
|
||||
Reference in New Issue
Block a user