feat(config): P3 config batch — group 2 (create_link, dir_link, auto_header)
- create_link (default true): server resolve_target_uri now only synthesises a missing-page URI when create_link is set; when off, following a link to a non-existent page returns no location (no-op). - dir_link: a [[dir/]] link now resolves to <dir>/<dir_link><ext> when dir_link is set, else opens the directory itself. Uses the already-parsed LinkTarget.is_directory. - auto_header (default off): new wiki pages get a `= Stem =` header derived from the filename, skipping the wiki index + diary index. Client-side BufNewFile autocmd in both clients (init.lua + plugin/nuwiki.vim), with auto_header handlers in both command layers (trailing-slash-robust root matching). Tests: cmd.auto_header_inserts + cmd.auto_header_skips_diary_index (nvim) / cmd.auto_header_skips_index (vim). Full rust suite + both harnesses green (Neovim 307, Vim 301/18/21). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -269,7 +269,29 @@ impl Backend {
|
||||
}
|
||||
}
|
||||
let path = target.path.as_deref()?;
|
||||
return synthesise_page_uri(&source_wiki.config, path);
|
||||
// vimwiki `dir_link`: a `[[dir/]]` link opens `<dir>/<dir_link>`
|
||||
// (e.g. `index` → `dir/index.wiki`); empty → the directory itself.
|
||||
if target.is_directory {
|
||||
let dl = source_wiki.config.dir_link.trim();
|
||||
if dl.is_empty() {
|
||||
let mut p = source_wiki.config.root.clone();
|
||||
for seg in path.split('/').filter(|s| !s.is_empty()) {
|
||||
p.push(seg);
|
||||
}
|
||||
return Url::from_file_path(p).ok();
|
||||
}
|
||||
let joined = format!("{}/{dl}", path.trim_end_matches('/'));
|
||||
return synthesise_page_uri(&source_wiki.config, &joined);
|
||||
}
|
||||
// vimwiki `create_link`: when off, only follow to a page that
|
||||
// already exists on disk — never synthesise a new one.
|
||||
let uri = synthesise_page_uri(&source_wiki.config, path)?;
|
||||
if !source_wiki.config.create_link
|
||||
&& !uri.to_file_path().map(|p| p.exists()).unwrap_or(false)
|
||||
{
|
||||
return None;
|
||||
}
|
||||
return Some(uri);
|
||||
}
|
||||
// No wiki registered (no `initializationOptions`, no
|
||||
// workspace folder). Fall back to the source buffer's
|
||||
|
||||
Reference in New Issue
Block a user