phase 9: editor glue — plugin, LSP wiring, install, health, docs
CI / cargo fmt --check (push) Successful in 30s
CI / cargo clippy (push) Successful in 1m23s
CI / cargo test (push) Successful in 1m29s

P5 + P6 resolved (SPEC §11): Neovim 0.11+ and Vim 9.1+.

Universal Vim entry:
- plugin/nuwiki.vim dispatches Vim vs Neovim. Neovim path waits for
  the user's `require('nuwiki').setup()` call; Vim path starts the
  LSP client on `FileType vimwiki` and exposes `:NuwikiInstall`.
- ftdetect/nuwiki.vim associates `*.wiki` with the `vimwiki` filetype.
- ftplugin/nuwiki.vim sets commentstring + comments + formatoptions +
  suffixesadd + iskeyword, with a clean `b:undo_ftplugin`.
- syntax/nuwiki.vim ships default `@vimwiki*` highlight links for the
  semantic-token legend (with `level1..6` + `centered` modifiers),
  plus a minimal regex fallback so static highlighting works before
  the LSP attaches.

Lua glue (Neovim 0.11+):
- init.lua exposes setup() / install() / health() — wiring only per
  SPEC §6.2.
- config.lua holds the §7.5 schema (wiki_root / file_extension /
  syntax / log_level) and a tbl_deep_extend apply().
- lsp.lua registers via `vim.lsp.config{} + vim.lsp.enable` on 0.11+;
  falls back to a FileType autocmd calling `vim.lsp.start` on older
  builds. Root dir walks up for `.git` / `.nuwiki`, then uses
  wiki_root.
- install.lua does target-triple detection (Linux gnu/musl x x86_64/
  aarch64, macOS arm/x86, Windows), curl+tar download from the
  release URL, cp/chmod into bin/, with a cargo fallback. Honours
  `g:nuwiki_build_from_source`.
- health.lua implements `:checkhealth nuwiki` per §7.6.

VimL glue (Vim 9.1+):
- autoload/nuwiki/lsp.vim follows §7.4 preference order:
  vim-lsp (calls `lsp#register_server`) → coc.nvim (prints the
  coc-settings.json snippet) → error.
- scripts/download_bin.vim mirrors the Lua installer for Dein /
  vim-plug build hooks — same target triples, same download →
  fallback → cargo build chain.

Help: doc/nuwiki.txt with tags for install (lazy.nvim / vim-plug /
Dein), config options, health, LSP feature list, `:NuwikiInstall`.

Rust workspace unchanged this phase; 172 tests still green locally.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-05-11 00:38:09 +00:00
parent 4d461d2425
commit ee61d40872
14 changed files with 736 additions and 30 deletions
+89 -2
View File
@@ -1,2 +1,89 @@
" syntax/nuwiki.vim — static fallback syntax highlighting (no LSP required).
" Implementation deferred to Phase 9 (Editor Glue).
" syntax/nuwiki.vim — default highlight groups for nuwiki.
"
" Two responsibilities:
" 1. Default `@vimwiki*` highlight groups for the LSP semantic tokens
" (SPEC §11 P7). Loaded eagerly so the very first hover/highlight
" cycle after server startup already has colours.
" 2. A small regex-based fallback so static highlighting works on
" buffers where the LSP isn't running yet.
if exists('b:current_syntax')
finish
endif
" ===== Semantic-token defaults (Neovim's TS-style @group names) =====
" Headings — level modifiers map to progressively softer accents.
highlight default link @vimwikiHeading Title
highlight default link @vimwikiHeading.level1 Title
highlight default link @vimwikiHeading.level2 Function
highlight default link @vimwikiHeading.level3 Identifier
highlight default link @vimwikiHeading.level4 Type
highlight default link @vimwikiHeading.level5 Constant
highlight default link @vimwikiHeading.level6 PreProc
highlight default link @vimwikiHeading.centered Title
" Inline text styling.
highlight default link @vimwikiBold markdownBold
highlight default link @vimwikiItalic markdownItalic
highlight default link @vimwikiBoldItalic markdownBoldItalic
highlight default link @vimwikiStrikethrough Comment
highlight default link @vimwikiSuperscript Number
highlight default link @vimwikiSubscript Number
" Code + math.
highlight default link @vimwikiCode String
highlight default link @vimwikiCodeBlock String
highlight default link @vimwikiMath Number
highlight default link @vimwikiMathBlock Number
" Links + transclusions.
highlight default link @vimwikiWikilink Underlined
highlight default link @vimwikiExternalLink Underlined
highlight default link @vimwikiUrl Underlined
highlight default link @vimwikiTransclusion Identifier
" Misc.
highlight default link @vimwikiKeyword Todo
highlight default link @vimwikiColor Constant
highlight default link @vimwikiComment Comment
highlight default link @vimwikiDefinitionTerm Statement
" ===== Static fallback (no LSP required) =====
syntax case match
syntax match nuwikiHeading /^\s*=\{1,6}\s.\{-}\s=\{1,6}\s*$/
syntax match nuwikiHorizontal /^-\{4,}\s*$/
syntax match nuwikiCommentLine /^%%.*$/
syntax region nuwikiCommentBlock start=/^%%+/ end=/+%%/ keepend
syntax region nuwikiPreformatted start=/^{{{/ end=/^}}}/ keepend
syntax region nuwikiMathBlock start=/^{{\$/ end=/^}}\$/ keepend
syntax match nuwikiPlaceholder /^%\(title\|nohtml\|template\|date\)\>.*$/
syntax match nuwikiBold /\*[^*]\+\*/
syntax match nuwikiItalic /\<_[^_]\+_\>/
syntax match nuwikiCode /`[^`]\+`/
syntax match nuwikiMathInline /\$[^$]\+\$/
syntax match nuwikiKeyword /\<\(TODO\|DONE\|STARTED\|FIXME\|FIXED\|XXX\)\>/
syntax region nuwikiWikilink start=/\[\[/ end=/\]\]/ keepend
syntax region nuwikiTransclusion start=/{{[^{]/ end=/}}/ keepend
syntax match nuwikiUrl /\<\(https\?\|ftp\|mailto\|file\):\/\?\/\?\S\+/
highlight default link nuwikiHeading Title
highlight default link nuwikiHorizontal Comment
highlight default link nuwikiCommentLine Comment
highlight default link nuwikiCommentBlock Comment
highlight default link nuwikiPreformatted String
highlight default link nuwikiMathBlock Number
highlight default link nuwikiPlaceholder PreProc
highlight default link nuwikiBold Bold
highlight default link nuwikiItalic Italic
highlight default link nuwikiCode String
highlight default link nuwikiMathInline Number
highlight default link nuwikiKeyword Todo
highlight default link nuwikiWikilink Underlined
highlight default link nuwikiTransclusion Identifier
highlight default link nuwikiUrl Underlined
let b:current_syntax = 'vimwiki'