feat(lsp): wire diary/auto_toc/links_space_char/list_margin; drop client-side keys

Consume several per-wiki config keys that the server deserialized but
ignored, and remove keys whose effect is purely client-side:

- diagnostics: re-publish open-doc diagnostics on
  didChangeConfiguration so a link_severity change takes effect
  immediately; fix the single-key unwrap in apply_change so a minimal
  `{ diagnostic: {...} }` payload isn't mistaken for a namespace wrapper.
- auto_toc: rebuild an existing TOC section on save (new
  ops::toc_rebuild_edit, no-op when the page has no TOC).
- diary index: honour diary_header, diary_sort and diary_caption_level
  when rendering the diary index body.
- links_space_char: apply on rename so spaces in the link target and
  the on-disk path become the configured glyph (default " " = verbatim).
- list_margin: thread the per-wiki value into render_page_html.
- remove nested_syntaxes, maxhi and diary_start_week_day from the server
  config: nested-syntax and heading highlighting are client-side, and
  the weekly diary is ISO-week based so a custom week start has no clean
  server-side meaning.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
2026-05-30 23:12:08 -03:00
parent 0741c349db
commit c63ec679ae
11 changed files with 383 additions and 77 deletions
+52 -6
View File
@@ -504,8 +504,33 @@ impl LanguageServer for Backend {
// is out of scope here; for now we just accept the new
// values so later commands see the right diagnostic settings etc.
// Multi-wiki support revisits this with proper rebuild semantics.
let mut cfg = self.config.write().expect("config lock poisoned");
cfg.apply_change(&params.settings);
{
let mut cfg = self.config.write().expect("config lock poisoned");
cfg.apply_change(&params.settings);
}
// A severity change (e.g. diagnostic.link_severity) only affects
// already-published diagnostics once we re-run link-health checks for
// open docs — otherwise the editor keeps showing the old severity until
// the next edit. Refresh every wiki's open docs against the new config.
let wiki_ids: Vec<crate::wiki::WikiId> = self
.wikis
.read()
.expect("wikis lock poisoned")
.iter()
.map(|w| w.id)
.collect();
for wiki_id in wiki_ids {
refresh_open_diagnostics_for_wiki(
wiki_id,
Arc::clone(&self.documents),
Arc::clone(&self.wikis),
Arc::clone(&self.config),
self.client.clone(),
Arc::clone(&self.use_utf8),
)
.await;
}
}
async fn shutdown(&self) -> LspResult<()> {
@@ -575,15 +600,36 @@ impl LanguageServer for Backend {
}
async fn did_save(&self, params: DidSaveTextDocumentParams) {
// When `auto_export` is set on the resolved wiki, run
// the equivalent of `nuwiki.export.currentToHtml` after the file
// hits disk. Best-effort — failures are logged but do not bubble
// to the client. Skips pages with the `%nohtml` directive.
let uri = params.text_document.uri.clone();
let wiki = match self.wiki_for_uri(&uri) {
Some(w) => w,
None => return,
};
// When `auto_toc` is set, rebuild an existing `= Contents =` section
// on save and push the change back to the buffer via
// `workspace/applyEdit`. Only rebuilds a TOC that's already there —
// it never inserts one into a page that didn't have it.
if wiki.config.auto_toc {
let edit = {
self.documents.get(&uri).and_then(|doc| {
commands::ops::toc_rebuild_edit(
&doc.text,
&doc.ast,
&uri,
self.use_utf8.load(Ordering::Relaxed),
)
})
};
if let Some(edit) = edit {
let _ = self.client.apply_edit(edit).await;
}
}
// When `auto_export` is set on the resolved wiki, run
// the equivalent of `nuwiki.export.currentToHtml` after the file
// hits disk. Best-effort — failures are logged but do not bubble
// to the client. Skips pages with the `%nohtml` directive.
if !wiki.config.html.auto_export {
return;
}