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
+49
View File
@@ -243,6 +243,7 @@ fn render_page_html_substitutes_title_content_and_extras() {
DiaryDate::from_ymd(2026, 5, 11).unwrap(),
&c.html,
None,
-1,
extras,
)
.unwrap();
@@ -262,6 +263,7 @@ fn render_page_html_uses_metadata_date_when_set() {
DiaryDate::from_ymd(2026, 5, 11).unwrap(),
&c.html,
None,
-1,
HashMap::new(),
)
.unwrap();
@@ -279,6 +281,7 @@ fn render_page_html_root_path_for_nested_pages() {
DiaryDate::today_utc(),
&c.html,
None,
-1,
HashMap::new(),
)
.unwrap();
@@ -298,6 +301,7 @@ fn render_page_html_extra_var_overrides_default() {
DiaryDate::today_utc(),
&c.html,
None,
-1,
extras,
)
.unwrap();
@@ -320,6 +324,7 @@ fn render_page_html_substitutes_vimwiki_percent_template() {
DiaryDate::from_ymd(2026, 5, 11).unwrap(),
&c.html,
None,
-1,
HashMap::new(),
)
.unwrap();
@@ -346,6 +351,7 @@ fn render_page_html_strips_wiki_extension_from_links() {
DiaryDate::today_utc(),
&c.html,
Some(".wiki"),
-1,
HashMap::new(),
)
.unwrap();
@@ -355,6 +361,49 @@ fn render_page_html_strips_wiki_extension_from_links() {
assert!(html.contains("href=\"posts/index.html\""), "plain: {html}");
}
#[test]
fn render_page_html_list_margin_only_styles_top_level_list() {
// `list_margin >= 0` forces a `margin-left:<n>em` on the outermost
// list; nested lists and the default of `-1` stay unstyled.
let ast = parse("- a\n - b\n");
let c = cfg("/tmp/x");
let styled = export::render_page_html(
&ast,
Some("{{content}}".into()),
"index",
DiaryDate::today_utc(),
&c.html,
None,
2,
HashMap::new(),
)
.unwrap();
assert!(
styled.contains("<ul style=\"margin-left:2em\">"),
"top-level margin: {styled}"
);
// Exactly one styled list — the nested `<ul>` is plain.
assert_eq!(
styled.matches("margin-left").count(),
1,
"only top: {styled}"
);
let plain = export::render_page_html(
&ast,
Some("{{content}}".into()),
"index",
DiaryDate::today_utc(),
&c.html,
None,
-1,
HashMap::new(),
)
.unwrap();
assert!(!plain.contains("margin-left"), "default unstyled: {plain}");
}
// ===== fallback_template + DEFAULT_CSS =====
#[test]