diff --git a/crates/nuwiki-lsp/src/config.rs b/crates/nuwiki-lsp/src/config.rs index 9871c15..a8f1aa1 100644 --- a/crates/nuwiki-lsp/src/config.rs +++ b/crates/nuwiki-lsp/src/config.rs @@ -367,8 +367,21 @@ impl Config { /// Re-apply settings received via `workspace/didChangeConfiguration`. /// On parse failure the existing config is returned unchanged. + /// + /// Accepts both the flat shape (`{ "wikis": [...] }`) produced by the + /// VimL client, **and** the Neovim-style wrapper (`{ "nuwiki": { ... } }`) + /// that `server_settings()` in `lua/nuwiki/lsp.lua` produces. Any other + /// single-key object whose value is an object is also unwrapped so + /// editors that namespace settings by server name continue to work. pub fn apply_change(&mut self, value: &serde_json::Value) { - let raw: InitOptions = match serde_json::from_value(value.clone()) { + // Unwrap { "nuwiki": { ... } } → { ... } so both clients work. + let inner = value + .as_object() + .and_then(|m| if m.len() == 1 { m.values().next() } else { None }) + .filter(|v| v.is_object()) + .unwrap_or(value); + + let raw: InitOptions = match serde_json::from_value(inner.clone()) { Ok(r) => r, Err(_) => return, };