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 <noreply@anthropic.com>
This commit is contained in:
@@ -187,6 +187,17 @@ impl Backend {
|
||||
id_or_default.and_then(|id| self.wiki(id))
|
||||
}
|
||||
|
||||
/// Parse `text` as vimwiki, honouring the checkbox palette
|
||||
/// (`listsyms`) of the wiki owning `uri`. Falls back to the default
|
||||
/// palette when no wiki matches.
|
||||
fn parse_for_uri(&self, uri: &Url, text: &str) -> nuwiki_core::ast::DocumentNode {
|
||||
let syms = self
|
||||
.wiki_for_uri(uri)
|
||||
.map(|w| nuwiki_core::listsyms::ListSyms::new(&w.config.listsyms))
|
||||
.unwrap_or_default();
|
||||
nuwiki_core::syntax::vimwiki::VimwikiSyntax::new().parse_with_listsyms(text, &syms)
|
||||
}
|
||||
|
||||
/// Snapshot of every registered wiki — held by value so callers can
|
||||
/// drop the lock before awaiting or building responses.
|
||||
pub(crate) fn wikis_snapshot(&self) -> Vec<Wiki> {
|
||||
@@ -304,11 +315,10 @@ impl Backend {
|
||||
.to_file_path()
|
||||
.map_err(|_| io::Error::new(io::ErrorKind::InvalidInput, "non-file URI"))?;
|
||||
let text = tokio::fs::read_to_string(&path).await?;
|
||||
let plugin = self
|
||||
.registry
|
||||
.get("vimwiki")
|
||||
.ok_or_else(|| io::Error::new(io::ErrorKind::Other, "vimwiki syntax plugin missing"))?;
|
||||
let ast = plugin.parse(&text);
|
||||
if self.registry.get("vimwiki").is_none() {
|
||||
return Err(io::Error::other("vimwiki syntax plugin missing"));
|
||||
}
|
||||
let ast = self.parse_for_uri(uri, &text);
|
||||
Ok(DocSnapshot {
|
||||
text,
|
||||
ast,
|
||||
@@ -319,16 +329,13 @@ impl Backend {
|
||||
async fn update_document(&self, uri: Url, text: String, version: i32) {
|
||||
// We always treat unknown buffers as vimwiki — if/when
|
||||
// multi-syntax dispatch lands the pick should follow the URI's ext.
|
||||
let plugin = match self.registry.get("vimwiki") {
|
||||
Some(p) => p,
|
||||
None => {
|
||||
self.client
|
||||
.log_message(MessageType::ERROR, "vimwiki plugin missing")
|
||||
.await;
|
||||
return;
|
||||
}
|
||||
};
|
||||
let ast = plugin.parse(&text);
|
||||
if self.registry.get("vimwiki").is_none() {
|
||||
self.client
|
||||
.log_message(MessageType::ERROR, "vimwiki plugin missing")
|
||||
.await;
|
||||
return;
|
||||
}
|
||||
let ast = self.parse_for_uri(&uri, &text);
|
||||
let utf8 = self.use_utf8.load(Ordering::Relaxed);
|
||||
|
||||
// Compute diagnostics + update the matching wiki's index. All locks
|
||||
|
||||
Reference in New Issue
Block a user