From 3a33d53c22550feec82e30710c02bb69295a0a4d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gabriel=20Fr=C3=B3es=20Franco?= Date: Sat, 30 May 2026 23:32:15 -0300 Subject: [PATCH] feat(lsp): drive checkbox commands from the wiki listsyms palette Parse editor and export documents with each wiki's configured listsyms, and make toggle/cycle/reject plus parent-propagation walk the real palette glyphs instead of the hardcoded ' .oOX'. Falls back to the default palette when no wiki matches the URI. Co-Authored-By: Claude Opus 4.7 --- crates/nuwiki-lsp/src/commands.rs | 183 ++++++----- crates/nuwiki-lsp/src/config.rs | 7 +- crates/nuwiki-lsp/src/lib.rs | 37 ++- .../nuwiki-lsp/tests/commands_checkboxes.rs | 291 ++++++++++++++---- 4 files changed, 363 insertions(+), 155 deletions(-) diff --git a/crates/nuwiki-lsp/src/commands.rs b/crates/nuwiki-lsp/src/commands.rs index e3335b4..d45dd27 100644 --- a/crates/nuwiki-lsp/src/commands.rs +++ b/crates/nuwiki-lsp/src/commands.rs @@ -238,7 +238,7 @@ fn file_delete(args: Vec) -> Result, String> { fn list_checkbox( backend: &Backend, args: Vec, - mutate: fn(&str) -> Option<&'static str>, + mutate: fn(&nuwiki_core::listsyms::ListSyms, &str) -> Option, ) -> Result, String> { let p = parse_pos(args)?; let doc = match backend.documents.get(&p.uri) { @@ -247,12 +247,14 @@ fn list_checkbox( }; let utf8 = backend.use_utf8.load(Ordering::Relaxed); let (line, col) = nav::lsp_to_byte_pos(p.position, &doc.text, utf8); - let propagate = backend - .wiki_for_uri(&p.uri) - .map(|w| w.config.listsyms_propagate) - .unwrap_or(true); + let wiki = backend.wiki_for_uri(&p.uri); + let syms = wiki + .as_ref() + .map(|w| nuwiki_core::listsyms::ListSyms::new(&w.config.listsyms)) + .unwrap_or_default(); + let propagate = wiki.map(|w| w.config.listsyms_propagate).unwrap_or(true); Ok(ops::checkbox_edit( - &doc.text, &doc.ast, &p.uri, line, col, utf8, mutate, propagate, + &doc.text, &doc.ast, &p.uri, line, col, utf8, &syms, mutate, propagate, )) } @@ -1139,9 +1141,9 @@ fn export_all(backend: &Backend, args: Vec, force: bool) -> Result