feat(coc): auto-register the language server with coc.nvim
coc users had to hand-maintain a coc-settings.json `languageserver.nuwiki`
entry, which didn't track g:nuwiki_wikis / g:vimwiki_list / the global
shorthand and meant editing JSON per wiki. nuwiki now registers itself
programmatically: on the first .wiki buffer it calls
coc#config('languageserver.nuwiki', {…}) with the s:settings() payload
(same config the vim-lsp path sends). coc reacts to the languageserver
config change (onDidChangeConfiguration → registerClientsByConfig) and
starts the server for the open buffer.
Details:
- Reliable coc detection via :CocConfig (exists('*coc#config') can't be
trusted — it doesn't trigger autoload in Vim 9.2). The coc#config call
is wrapped in try/catch and autoloads coc.vim itself; falls back to the
printed snippet only if coc genuinely isn't there.
- Deferred to User CocNvimInit when coc's node service isn't up yet.
- Opt out with g:nuwiki_no_coc_register (then we just print the snippet).
Dogfooded in start-vim-coc.sh: dropped the manual coc-settings.json
languageserver block; the harness now relies on auto-registration from
g:nuwiki_* (real-user flow). New harness test-coc-register-vim (7 checks,
stubbed coc#config) asserts the injected payload incl. the folded global
shorthand; wired into CI. README coc section rewritten (zero-config).
Rust 573 passed, clippy clean, all harnesses green.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -82,9 +82,9 @@ Neovim) instead of relying on a plugin-manager build hook.
|
||||
Older releases fall back to a `vim.lsp.start` autocmd but aren't
|
||||
officially supported.
|
||||
- **Vim 9+** — needs a third-party LSP client:
|
||||
[`vim-lsp`](https://github.com/prabirshrestha/vim-lsp) (recommended,
|
||||
auto-registered) or [`coc.nvim`](https://github.com/neoclide/coc.nvim)
|
||||
(one-time `coc-settings.json` entry — see [Vim LSP client
|
||||
[`vim-lsp`](https://github.com/prabirshrestha/vim-lsp) or
|
||||
[`coc.nvim`](https://github.com/neoclide/coc.nvim) — both
|
||||
auto-registered, no manual config (see [Vim LSP client
|
||||
setup](#vim-lsp-client-setup)).
|
||||
- **Rust toolchain (1.83+ stable)** — only needed when building the
|
||||
binary from source; pre-built release downloads skip this.
|
||||
@@ -145,10 +145,18 @@ auto-enables it. Your wiki settings (`g:nuwiki_wiki_root`,
|
||||
`g:nuwiki_wikis`, …) are forwarded as the server's initialization
|
||||
options.
|
||||
|
||||
**coc.nvim** — [`coc.nvim`](https://github.com/neoclide/coc.nvim) reads
|
||||
its server list from `coc-settings.json`, which the plugin can't edit
|
||||
on your behalf, so add the entry once yourself (open it with
|
||||
`:CocConfig`):
|
||||
**coc.nvim** — also zero configuration. nuwiki registers itself with
|
||||
[`coc.nvim`](https://github.com/neoclide/coc.nvim) programmatically
|
||||
(`coc#config('languageserver.nuwiki', …)`) when the first `.wiki` buffer
|
||||
loads, forwarding the same wiki settings (`g:nuwiki_wiki_root`,
|
||||
`g:nuwiki_wikis`, your `g:vimwiki_*` config, the global shorthand, …) as
|
||||
the server's initialization options. **No `coc-settings.json`
|
||||
`languageserver` entry needed** — change your wiki config and reload; the
|
||||
new settings are picked up.
|
||||
|
||||
To manage the entry yourself instead, set `let g:nuwiki_no_coc_register = 1`
|
||||
and add it to `coc-settings.json` manually (nuwiki then just prints the
|
||||
snippet on first load):
|
||||
|
||||
```json
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user