Extract shared launcher logic into development/_common.sh
CI / cargo fmt --check (push) Successful in 27s
CI / cargo clippy (push) Successful in 28s
CI / cargo test (push) Successful in 31s
CI / cargo fmt --check (pull_request) Successful in 16s
CI / cargo clippy (pull_request) Successful in 29s
CI / cargo test (pull_request) Successful in 46s
CI / editor keymaps (push) Successful in 1m38s
CI / editor keymaps (pull_request) Successful in 1m40s
CI / cargo fmt --check (push) Successful in 27s
CI / cargo clippy (push) Successful in 28s
CI / cargo test (push) Successful in 31s
CI / cargo fmt --check (pull_request) Successful in 16s
CI / cargo clippy (pull_request) Successful in 29s
CI / cargo test (pull_request) Successful in 46s
CI / editor keymaps (push) Successful in 1m38s
CI / editor keymaps (pull_request) Successful in 1m40s
start-nvim.sh and start-vim.sh now source a common helper for the paths, log(), ensure_binary(), and the sample-wiki fixture, so the fixture lives in exactly one place instead of being duplicated across both launchers. Each launcher keeps only its editor-specific config generation. start-nvim.sh also gains the NUWIKI_DEV_NO_SEED guard for parity with start-vim.sh. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,276 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
#
|
||||||
|
# development/_common.sh — shared helpers for the start-* dev launchers.
|
||||||
|
#
|
||||||
|
# Sourced by start-nvim.sh and start-vim.sh (not run directly). Owns the
|
||||||
|
# pieces both launchers share so they stay in lockstep — most importantly
|
||||||
|
# the sample-wiki fixture, which previously had to be edited in two
|
||||||
|
# places.
|
||||||
|
#
|
||||||
|
# Exports:
|
||||||
|
# REPO_ROOT / DEV_DIR / WIKI_DIR — common paths
|
||||||
|
# log — prefixed status line
|
||||||
|
# ensure_binary — build + symlink nuwiki-ls
|
||||||
|
# write_sample_wiki DIR — lay down the feature-showcase wiki
|
||||||
|
# seed_wiki — seed WIKI_DIR (respects NUWIKI_DEV_NO_SEED)
|
||||||
|
|
||||||
|
# Resolve paths relative to this file so it works regardless of which
|
||||||
|
# launcher sources it.
|
||||||
|
REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
||||||
|
DEV_DIR="${XDG_CACHE_HOME:-$HOME/.cache}/nuwiki-dev"
|
||||||
|
WIKI_DIR="${NUWIKI_DEV_WIKI:-$DEV_DIR/wiki}"
|
||||||
|
|
||||||
|
log() { printf '\033[1;34m[nuwiki-dev]\033[0m %s\n' "$*"; }
|
||||||
|
|
||||||
|
ensure_binary() {
|
||||||
|
local bin="$REPO_ROOT/bin/nuwiki-ls"
|
||||||
|
local built="$REPO_ROOT/target/release/nuwiki-ls"
|
||||||
|
if [[ "${NUWIKI_DEV_SKIP_BUILD:-0}" == "1" ]]; then
|
||||||
|
if [[ ! -x "$bin" ]]; then
|
||||||
|
log "NUWIKI_DEV_SKIP_BUILD=1 but $bin is missing — building anyway"
|
||||||
|
else
|
||||||
|
log "NUWIKI_DEV_SKIP_BUILD=1 — using existing $bin"
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
log "building nuwiki-ls (release)…"
|
||||||
|
cargo build --release -p nuwiki-ls --manifest-path "$REPO_ROOT/Cargo.toml"
|
||||||
|
mkdir -p "$REPO_ROOT/bin"
|
||||||
|
ln -sf "$built" "$bin"
|
||||||
|
log "binary ready: $bin (built $(date -r "$built" '+%Y-%m-%d %H:%M:%S'))"
|
||||||
|
}
|
||||||
|
|
||||||
|
# write_sample_wiki DIR — lay down a fixture that exercises every vimwiki
|
||||||
|
# feature nuwiki supports: one page per feature group plus a diary.
|
||||||
|
# Heredocs use a quoted delimiter so `$math`, backticks, and backslashes
|
||||||
|
# land verbatim.
|
||||||
|
write_sample_wiki() {
|
||||||
|
local root="$1"
|
||||||
|
mkdir -p "$root" "$root/diary"
|
||||||
|
|
||||||
|
cat > "$root/index.wiki" <<'EOF'
|
||||||
|
= nuwiki sample wiki =
|
||||||
|
|
||||||
|
%% Generated by the start-* dev launchers. A single fixture that exercises
|
||||||
|
%% every vimwiki feature nuwiki supports — open the linked pages and run
|
||||||
|
%% the plugin commands against them.
|
||||||
|
|
||||||
|
One page per feature group:
|
||||||
|
|
||||||
|
- [[Syntax]] — inline formatting, blocks, comments
|
||||||
|
- [[Lists]] — bullets, ordering, checkbox states, nesting
|
||||||
|
- [[Tables]] — alignment and spanning cells
|
||||||
|
- [[Links]] — every wikilink and URL form
|
||||||
|
- [[Notes]] — anchor targets for cross-page links
|
||||||
|
- [[diary/diary]] — the diary index
|
||||||
|
|
||||||
|
=== Heading level 3 ===
|
||||||
|
==== Heading level 4 ====
|
||||||
|
===== Heading level 5 =====
|
||||||
|
====== Heading level 6 ======
|
||||||
|
|
||||||
|
== Commands to try ==
|
||||||
|
|
||||||
|
- :NuwikiTOC
|
||||||
|
- :NuwikiGenerateLinks
|
||||||
|
- :NuwikiCheckLinks
|
||||||
|
- :NuwikiMakeDiaryNote
|
||||||
|
|
||||||
|
:sample:smoke-test:sandbox:
|
||||||
|
EOF
|
||||||
|
|
||||||
|
cat > "$root/Syntax.wiki" <<'EOF'
|
||||||
|
= Syntax showcase =
|
||||||
|
|
||||||
|
Back to [[index]].
|
||||||
|
|
||||||
|
== Inline formatting ==
|
||||||
|
|
||||||
|
*bold*, _italic_, *_bold italic_*, ~~strikethrough~~, `inline code`,
|
||||||
|
super^script^ and sub,,script,,, and inline math $e^{i\pi} + 1 = 0$.
|
||||||
|
|
||||||
|
== Keywords ==
|
||||||
|
|
||||||
|
TODO STARTED FIXME XXX DONE FIXED STOPPED
|
||||||
|
|
||||||
|
== Horizontal rule ==
|
||||||
|
|
||||||
|
----
|
||||||
|
|
||||||
|
== Blockquote ==
|
||||||
|
|
||||||
|
> A quoted line.
|
||||||
|
> A second quoted line.
|
||||||
|
|
||||||
|
== Definition list ==
|
||||||
|
|
||||||
|
Term:: Definition of the term.
|
||||||
|
Another:: Its definition.
|
||||||
|
|
||||||
|
== Code block ==
|
||||||
|
|
||||||
|
{{{python
|
||||||
|
def greet(name):
|
||||||
|
return f"hello {name}"
|
||||||
|
}}}
|
||||||
|
|
||||||
|
== Math block ==
|
||||||
|
|
||||||
|
{{$
|
||||||
|
\sum_{i=1}^{n} i = \frac{n(n+1)}{2}
|
||||||
|
}}$
|
||||||
|
|
||||||
|
== Comments ==
|
||||||
|
|
||||||
|
%% a single-line comment
|
||||||
|
%%+ a multi-line
|
||||||
|
comment block +%%
|
||||||
|
|
||||||
|
== Transclusion ==
|
||||||
|
|
||||||
|
{{file:image.png}}
|
||||||
|
{{image.png|alt text|width=120}}
|
||||||
|
EOF
|
||||||
|
|
||||||
|
cat > "$root/Lists.wiki" <<'EOF'
|
||||||
|
= Lists =
|
||||||
|
|
||||||
|
Back to [[index]].
|
||||||
|
|
||||||
|
== Unordered ==
|
||||||
|
|
||||||
|
- item with dash
|
||||||
|
- second
|
||||||
|
- nested under dash
|
||||||
|
* item with star
|
||||||
|
# item with hash
|
||||||
|
|
||||||
|
== Ordered ==
|
||||||
|
|
||||||
|
1. first
|
||||||
|
2. second
|
||||||
|
1. nested ordered
|
||||||
|
1) paren style
|
||||||
|
a) alpha
|
||||||
|
A) Alpha
|
||||||
|
i) roman
|
||||||
|
I) Roman
|
||||||
|
|
||||||
|
== Checkbox states ==
|
||||||
|
|
||||||
|
- [ ] empty (0%)
|
||||||
|
- [.] started (1-33%)
|
||||||
|
- [o] in progress (34-66%)
|
||||||
|
- [O] nearly done (67-99%)
|
||||||
|
- [X] done (100%)
|
||||||
|
- [-] rejected
|
||||||
|
|
||||||
|
== Nested with checkboxes ==
|
||||||
|
|
||||||
|
- [ ] parent task
|
||||||
|
- [X] done subtask
|
||||||
|
- [ ] pending subtask
|
||||||
|
- [ ] deep subtask
|
||||||
|
EOF
|
||||||
|
|
||||||
|
cat > "$root/Tables.wiki" <<'EOF'
|
||||||
|
= Tables =
|
||||||
|
|
||||||
|
Back to [[index]].
|
||||||
|
|
||||||
|
== Plain ==
|
||||||
|
|
||||||
|
| Name | Role |
|
||||||
|
| Alice | Author |
|
||||||
|
| Bob | Editor |
|
||||||
|
|
||||||
|
== Aligned ==
|
||||||
|
|
||||||
|
| Left | Center | Right |
|
||||||
|
|:-----|:------:|------:|
|
||||||
|
| a | b | c |
|
||||||
|
| d | e | f |
|
||||||
|
|
||||||
|
== Spanning cells ==
|
||||||
|
|
||||||
|
| Header | Span |
|
||||||
|
| cell | > |
|
||||||
|
| rowspan | value |
|
||||||
|
| \/ | value |
|
||||||
|
EOF
|
||||||
|
|
||||||
|
cat > "$root/Links.wiki" <<'EOF'
|
||||||
|
= Links =
|
||||||
|
|
||||||
|
Back to [[index]].
|
||||||
|
|
||||||
|
== Wikilinks ==
|
||||||
|
|
||||||
|
- [[Notes]]
|
||||||
|
- [[Notes|described]]
|
||||||
|
- [[Notes#Section one]]
|
||||||
|
- [[Notes#Section one|anchored + described]]
|
||||||
|
- [[/index]]
|
||||||
|
- [[diary/]]
|
||||||
|
- [[#Wikilinks]]
|
||||||
|
|
||||||
|
== Diary and interwiki ==
|
||||||
|
|
||||||
|
- [[diary:2026-05-30]]
|
||||||
|
- [[wiki1:index]]
|
||||||
|
- [[wn.MyWiki:index]]
|
||||||
|
|
||||||
|
== External and raw URLs ==
|
||||||
|
|
||||||
|
- [[https://example.com]]
|
||||||
|
- [[https://example.com|Example]]
|
||||||
|
- https://example.com
|
||||||
|
- mailto:gffranco@gmail.com
|
||||||
|
- file:///etc/hosts
|
||||||
|
EOF
|
||||||
|
|
||||||
|
cat > "$root/Notes.wiki" <<'EOF'
|
||||||
|
= Notes =
|
||||||
|
|
||||||
|
A page that other pages point at. Back to [[index]].
|
||||||
|
|
||||||
|
== Section one ==
|
||||||
|
|
||||||
|
Anchor target for cross-page links.
|
||||||
|
|
||||||
|
== Section two ==
|
||||||
|
|
||||||
|
Another anchor target.
|
||||||
|
EOF
|
||||||
|
|
||||||
|
cat > "$root/diary/diary.wiki" <<'EOF'
|
||||||
|
= Diary =
|
||||||
|
|
||||||
|
Back to [[/index]].
|
||||||
|
|
||||||
|
- [[2026-05-30]]
|
||||||
|
EOF
|
||||||
|
|
||||||
|
cat > "$root/diary/2026-05-30.wiki" <<'EOF'
|
||||||
|
= 2026-05-30 =
|
||||||
|
|
||||||
|
A diary entry. Back to [[diary]].
|
||||||
|
|
||||||
|
- [X] set up sample wiki
|
||||||
|
- [ ] review every feature page
|
||||||
|
EOF
|
||||||
|
}
|
||||||
|
|
||||||
|
seed_wiki() {
|
||||||
|
if [[ "${NUWIKI_DEV_NO_SEED:-0}" == "1" ]]; then
|
||||||
|
log "NUWIKI_DEV_NO_SEED=1 — skipping wiki seed (using $WIKI_DIR as-is)"
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
mkdir -p "$WIKI_DIR" "$WIKI_DIR/diary"
|
||||||
|
# Seed the whole showcase as a unit; skip when an index already exists
|
||||||
|
# so a re-run never clobbers edits made while testing.
|
||||||
|
if [[ -f "$WIKI_DIR/index.wiki" ]]; then
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
write_sample_wiki "$WIKI_DIR"
|
||||||
|
}
|
||||||
+4
-255
@@ -14,6 +14,7 @@
|
|||||||
# ./development/start-nvim.sh # open the scratch wiki's index
|
# ./development/start-nvim.sh # open the scratch wiki's index
|
||||||
# ./development/start-nvim.sh path/to/note.wiki # open a specific file
|
# ./development/start-nvim.sh path/to/note.wiki # open a specific file
|
||||||
# NUWIKI_DEV_WIKI=/tmp/foo ./development/start-nvim.sh
|
# NUWIKI_DEV_WIKI=/tmp/foo ./development/start-nvim.sh
|
||||||
|
# NUWIKI_DEV_NO_SEED=1 ./development/start-nvim.sh # use WIKI_DIR as-is (no scratch seeding)
|
||||||
# NUWIKI_DEV_SKIP_BUILD=1 ./development/start-nvim.sh # reuse the cached binary
|
# NUWIKI_DEV_SKIP_BUILD=1 ./development/start-nvim.sh # reuse the cached binary
|
||||||
#
|
#
|
||||||
# The release binary is rebuilt on every launch so source changes
|
# The release binary is rebuilt on every launch so source changes
|
||||||
@@ -27,266 +28,14 @@
|
|||||||
|
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
|
|
||||||
REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
# Shared paths + helpers (log, ensure_binary, write_sample_wiki, seed_wiki).
|
||||||
DEV_DIR="${XDG_CACHE_HOME:-$HOME/.cache}/nuwiki-dev"
|
source "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/_common.sh"
|
||||||
WIKI_DIR="${NUWIKI_DEV_WIKI:-$DEV_DIR/wiki}"
|
|
||||||
INIT_FILE="$DEV_DIR/init.lua"
|
INIT_FILE="$DEV_DIR/init.lua"
|
||||||
STATE_DIR="$DEV_DIR/nvim-state"
|
STATE_DIR="$DEV_DIR/nvim-state"
|
||||||
DATA_DIR="$DEV_DIR/nvim-data"
|
DATA_DIR="$DEV_DIR/nvim-data"
|
||||||
CONFIG_DIR="$DEV_DIR/nvim-config"
|
CONFIG_DIR="$DEV_DIR/nvim-config"
|
||||||
|
|
||||||
log() { printf '\033[1;34m[nuwiki-dev]\033[0m %s\n' "$*"; }
|
|
||||||
|
|
||||||
ensure_binary() {
|
|
||||||
local bin="$REPO_ROOT/bin/nuwiki-ls"
|
|
||||||
local built="$REPO_ROOT/target/release/nuwiki-ls"
|
|
||||||
if [[ "${NUWIKI_DEV_SKIP_BUILD:-0}" == "1" ]]; then
|
|
||||||
if [[ ! -x "$bin" ]]; then
|
|
||||||
log "NUWIKI_DEV_SKIP_BUILD=1 but $bin is missing — building anyway"
|
|
||||||
else
|
|
||||||
log "NUWIKI_DEV_SKIP_BUILD=1 — using existing $bin"
|
|
||||||
return
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
log "building nuwiki-ls (release)…"
|
|
||||||
cargo build --release -p nuwiki-ls --manifest-path "$REPO_ROOT/Cargo.toml"
|
|
||||||
mkdir -p "$REPO_ROOT/bin"
|
|
||||||
ln -sf "$built" "$bin"
|
|
||||||
log "binary ready: $bin (built $(date -r "$built" '+%Y-%m-%d %H:%M:%S'))"
|
|
||||||
}
|
|
||||||
|
|
||||||
# write_sample_wiki DIR — lay down a fixture that exercises every vimwiki
|
|
||||||
# feature nuwiki supports: one page per feature group plus a diary. Kept
|
|
||||||
# identical to the copy in start-vim.sh so both launchers showcase the
|
|
||||||
# same surface. Heredocs use a quoted delimiter so `$math`, backticks,
|
|
||||||
# and backslashes land verbatim.
|
|
||||||
write_sample_wiki() {
|
|
||||||
local root="$1"
|
|
||||||
mkdir -p "$root" "$root/diary"
|
|
||||||
|
|
||||||
cat > "$root/index.wiki" <<'EOF'
|
|
||||||
= nuwiki sample wiki =
|
|
||||||
|
|
||||||
%% Generated by the start-* dev launchers. A single fixture that exercises
|
|
||||||
%% every vimwiki feature nuwiki supports — open the linked pages and run
|
|
||||||
%% the plugin commands against them.
|
|
||||||
|
|
||||||
One page per feature group:
|
|
||||||
|
|
||||||
- [[Syntax]] — inline formatting, blocks, comments
|
|
||||||
- [[Lists]] — bullets, ordering, checkbox states, nesting
|
|
||||||
- [[Tables]] — alignment and spanning cells
|
|
||||||
- [[Links]] — every wikilink and URL form
|
|
||||||
- [[Notes]] — anchor targets for cross-page links
|
|
||||||
- [[diary/diary]] — the diary index
|
|
||||||
|
|
||||||
=== Heading level 3 ===
|
|
||||||
==== Heading level 4 ====
|
|
||||||
===== Heading level 5 =====
|
|
||||||
====== Heading level 6 ======
|
|
||||||
|
|
||||||
== Commands to try ==
|
|
||||||
|
|
||||||
- :NuwikiTOC
|
|
||||||
- :NuwikiGenerateLinks
|
|
||||||
- :NuwikiCheckLinks
|
|
||||||
- :NuwikiMakeDiaryNote
|
|
||||||
|
|
||||||
:sample:smoke-test:sandbox:
|
|
||||||
EOF
|
|
||||||
|
|
||||||
cat > "$root/Syntax.wiki" <<'EOF'
|
|
||||||
= Syntax showcase =
|
|
||||||
|
|
||||||
Back to [[index]].
|
|
||||||
|
|
||||||
== Inline formatting ==
|
|
||||||
|
|
||||||
*bold*, _italic_, *_bold italic_*, ~~strikethrough~~, `inline code`,
|
|
||||||
super^script^ and sub,,script,,, and inline math $e^{i\pi} + 1 = 0$.
|
|
||||||
|
|
||||||
== Keywords ==
|
|
||||||
|
|
||||||
TODO STARTED FIXME XXX DONE FIXED STOPPED
|
|
||||||
|
|
||||||
== Horizontal rule ==
|
|
||||||
|
|
||||||
----
|
|
||||||
|
|
||||||
== Blockquote ==
|
|
||||||
|
|
||||||
> A quoted line.
|
|
||||||
> A second quoted line.
|
|
||||||
|
|
||||||
== Definition list ==
|
|
||||||
|
|
||||||
Term:: Definition of the term.
|
|
||||||
Another:: Its definition.
|
|
||||||
|
|
||||||
== Code block ==
|
|
||||||
|
|
||||||
{{{python
|
|
||||||
def greet(name):
|
|
||||||
return f"hello {name}"
|
|
||||||
}}}
|
|
||||||
|
|
||||||
== Math block ==
|
|
||||||
|
|
||||||
{{$
|
|
||||||
\sum_{i=1}^{n} i = \frac{n(n+1)}{2}
|
|
||||||
}}$
|
|
||||||
|
|
||||||
== Comments ==
|
|
||||||
|
|
||||||
%% a single-line comment
|
|
||||||
%%+ a multi-line
|
|
||||||
comment block +%%
|
|
||||||
|
|
||||||
== Transclusion ==
|
|
||||||
|
|
||||||
{{file:image.png}}
|
|
||||||
{{image.png|alt text|width=120}}
|
|
||||||
EOF
|
|
||||||
|
|
||||||
cat > "$root/Lists.wiki" <<'EOF'
|
|
||||||
= Lists =
|
|
||||||
|
|
||||||
Back to [[index]].
|
|
||||||
|
|
||||||
== Unordered ==
|
|
||||||
|
|
||||||
- item with dash
|
|
||||||
- second
|
|
||||||
- nested under dash
|
|
||||||
* item with star
|
|
||||||
# item with hash
|
|
||||||
|
|
||||||
== Ordered ==
|
|
||||||
|
|
||||||
1. first
|
|
||||||
2. second
|
|
||||||
1. nested ordered
|
|
||||||
1) paren style
|
|
||||||
a) alpha
|
|
||||||
A) Alpha
|
|
||||||
i) roman
|
|
||||||
I) Roman
|
|
||||||
|
|
||||||
== Checkbox states ==
|
|
||||||
|
|
||||||
- [ ] empty (0%)
|
|
||||||
- [.] started (1-33%)
|
|
||||||
- [o] in progress (34-66%)
|
|
||||||
- [O] nearly done (67-99%)
|
|
||||||
- [X] done (100%)
|
|
||||||
- [-] rejected
|
|
||||||
|
|
||||||
== Nested with checkboxes ==
|
|
||||||
|
|
||||||
- [ ] parent task
|
|
||||||
- [X] done subtask
|
|
||||||
- [ ] pending subtask
|
|
||||||
- [ ] deep subtask
|
|
||||||
EOF
|
|
||||||
|
|
||||||
cat > "$root/Tables.wiki" <<'EOF'
|
|
||||||
= Tables =
|
|
||||||
|
|
||||||
Back to [[index]].
|
|
||||||
|
|
||||||
== Plain ==
|
|
||||||
|
|
||||||
| Name | Role |
|
|
||||||
| Alice | Author |
|
|
||||||
| Bob | Editor |
|
|
||||||
|
|
||||||
== Aligned ==
|
|
||||||
|
|
||||||
| Left | Center | Right |
|
|
||||||
|:-----|:------:|------:|
|
|
||||||
| a | b | c |
|
|
||||||
| d | e | f |
|
|
||||||
|
|
||||||
== Spanning cells ==
|
|
||||||
|
|
||||||
| Header | Span |
|
|
||||||
| cell | > |
|
|
||||||
| rowspan | value |
|
|
||||||
| \/ | value |
|
|
||||||
EOF
|
|
||||||
|
|
||||||
cat > "$root/Links.wiki" <<'EOF'
|
|
||||||
= Links =
|
|
||||||
|
|
||||||
Back to [[index]].
|
|
||||||
|
|
||||||
== Wikilinks ==
|
|
||||||
|
|
||||||
- [[Notes]]
|
|
||||||
- [[Notes|described]]
|
|
||||||
- [[Notes#Section one]]
|
|
||||||
- [[Notes#Section one|anchored + described]]
|
|
||||||
- [[/index]]
|
|
||||||
- [[diary/]]
|
|
||||||
- [[#Wikilinks]]
|
|
||||||
|
|
||||||
== Diary and interwiki ==
|
|
||||||
|
|
||||||
- [[diary:2026-05-30]]
|
|
||||||
- [[wiki1:index]]
|
|
||||||
- [[wn.MyWiki:index]]
|
|
||||||
|
|
||||||
== External and raw URLs ==
|
|
||||||
|
|
||||||
- [[https://example.com]]
|
|
||||||
- [[https://example.com|Example]]
|
|
||||||
- https://example.com
|
|
||||||
- mailto:gffranco@gmail.com
|
|
||||||
- file:///etc/hosts
|
|
||||||
EOF
|
|
||||||
|
|
||||||
cat > "$root/Notes.wiki" <<'EOF'
|
|
||||||
= Notes =
|
|
||||||
|
|
||||||
A page that other pages point at. Back to [[index]].
|
|
||||||
|
|
||||||
== Section one ==
|
|
||||||
|
|
||||||
Anchor target for cross-page links.
|
|
||||||
|
|
||||||
== Section two ==
|
|
||||||
|
|
||||||
Another anchor target.
|
|
||||||
EOF
|
|
||||||
|
|
||||||
cat > "$root/diary/diary.wiki" <<'EOF'
|
|
||||||
= Diary =
|
|
||||||
|
|
||||||
Back to [[/index]].
|
|
||||||
|
|
||||||
- [[2026-05-30]]
|
|
||||||
EOF
|
|
||||||
|
|
||||||
cat > "$root/diary/2026-05-30.wiki" <<'EOF'
|
|
||||||
= 2026-05-30 =
|
|
||||||
|
|
||||||
A diary entry. Back to [[diary]].
|
|
||||||
|
|
||||||
- [X] set up sample wiki
|
|
||||||
- [ ] review every feature page
|
|
||||||
EOF
|
|
||||||
}
|
|
||||||
|
|
||||||
seed_wiki() {
|
|
||||||
mkdir -p "$WIKI_DIR" "$WIKI_DIR/diary"
|
|
||||||
# Seed the whole showcase as a unit; skip when an index already exists
|
|
||||||
# so a re-run never clobbers edits made while testing.
|
|
||||||
if [[ -f "$WIKI_DIR/index.wiki" ]]; then
|
|
||||||
return
|
|
||||||
fi
|
|
||||||
write_sample_wiki "$WIKI_DIR"
|
|
||||||
}
|
|
||||||
|
|
||||||
write_init() {
|
write_init() {
|
||||||
mkdir -p "$DEV_DIR"
|
mkdir -p "$DEV_DIR"
|
||||||
cat > "$INIT_FILE" <<EOF
|
cat > "$INIT_FILE" <<EOF
|
||||||
|
|||||||
+3
-258
@@ -25,34 +25,14 @@
|
|||||||
|
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
|
|
||||||
REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
# Shared paths + helpers (log, ensure_binary, write_sample_wiki, seed_wiki).
|
||||||
DEV_DIR="${XDG_CACHE_HOME:-$HOME/.cache}/nuwiki-dev"
|
source "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/_common.sh"
|
||||||
WIKI_DIR="${NUWIKI_DEV_WIKI:-$DEV_DIR/wiki}"
|
|
||||||
VIMRC="$DEV_DIR/vimrc"
|
VIMRC="$DEV_DIR/vimrc"
|
||||||
VIM_STATE="$DEV_DIR/vim-state"
|
VIM_STATE="$DEV_DIR/vim-state"
|
||||||
VIM_LSP_DIR="$DEV_DIR/vim-lsp"
|
VIM_LSP_DIR="$DEV_DIR/vim-lsp"
|
||||||
ASYNC_DIR="$DEV_DIR/async.vim"
|
ASYNC_DIR="$DEV_DIR/async.vim"
|
||||||
|
|
||||||
log() { printf '\033[1;34m[nuwiki-dev]\033[0m %s\n' "$*"; }
|
|
||||||
|
|
||||||
ensure_binary() {
|
|
||||||
local bin="$REPO_ROOT/bin/nuwiki-ls"
|
|
||||||
local built="$REPO_ROOT/target/release/nuwiki-ls"
|
|
||||||
if [[ "${NUWIKI_DEV_SKIP_BUILD:-0}" == "1" ]]; then
|
|
||||||
if [[ ! -x "$bin" ]]; then
|
|
||||||
log "NUWIKI_DEV_SKIP_BUILD=1 but $bin is missing — building anyway"
|
|
||||||
else
|
|
||||||
log "NUWIKI_DEV_SKIP_BUILD=1 — using existing $bin"
|
|
||||||
return
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
log "building nuwiki-ls (release)…"
|
|
||||||
cargo build --release -p nuwiki-ls --manifest-path "$REPO_ROOT/Cargo.toml"
|
|
||||||
mkdir -p "$REPO_ROOT/bin"
|
|
||||||
ln -sf "$built" "$bin"
|
|
||||||
log "binary ready: $bin (built $(date -r "$built" '+%Y-%m-%d %H:%M:%S'))"
|
|
||||||
}
|
|
||||||
|
|
||||||
clone_if_missing() {
|
clone_if_missing() {
|
||||||
local repo_url="$1"
|
local repo_url="$1"
|
||||||
local dest="$2"
|
local dest="$2"
|
||||||
@@ -77,241 +57,6 @@ ensure_vim_lsp() {
|
|||||||
clone_if_missing https://github.com/prabirshrestha/async.vim.git "$ASYNC_DIR" || true
|
clone_if_missing https://github.com/prabirshrestha/async.vim.git "$ASYNC_DIR" || true
|
||||||
}
|
}
|
||||||
|
|
||||||
# write_sample_wiki DIR — lay down a fixture that exercises every vimwiki
|
|
||||||
# feature nuwiki supports: one page per feature group plus a diary. Kept
|
|
||||||
# identical to the copy in start-nvim.sh so both launchers showcase the
|
|
||||||
# same surface. Heredocs use a quoted delimiter so `$math`, backticks,
|
|
||||||
# and backslashes land verbatim.
|
|
||||||
write_sample_wiki() {
|
|
||||||
local root="$1"
|
|
||||||
mkdir -p "$root" "$root/diary"
|
|
||||||
|
|
||||||
cat > "$root/index.wiki" <<'EOF'
|
|
||||||
= nuwiki sample wiki =
|
|
||||||
|
|
||||||
%% Generated by the start-* dev launchers. A single fixture that exercises
|
|
||||||
%% every vimwiki feature nuwiki supports — open the linked pages and run
|
|
||||||
%% the plugin commands against them.
|
|
||||||
|
|
||||||
One page per feature group:
|
|
||||||
|
|
||||||
- [[Syntax]] — inline formatting, blocks, comments
|
|
||||||
- [[Lists]] — bullets, ordering, checkbox states, nesting
|
|
||||||
- [[Tables]] — alignment and spanning cells
|
|
||||||
- [[Links]] — every wikilink and URL form
|
|
||||||
- [[Notes]] — anchor targets for cross-page links
|
|
||||||
- [[diary/diary]] — the diary index
|
|
||||||
|
|
||||||
=== Heading level 3 ===
|
|
||||||
==== Heading level 4 ====
|
|
||||||
===== Heading level 5 =====
|
|
||||||
====== Heading level 6 ======
|
|
||||||
|
|
||||||
== Commands to try ==
|
|
||||||
|
|
||||||
- :NuwikiTOC
|
|
||||||
- :NuwikiGenerateLinks
|
|
||||||
- :NuwikiCheckLinks
|
|
||||||
- :NuwikiMakeDiaryNote
|
|
||||||
|
|
||||||
:sample:smoke-test:sandbox:
|
|
||||||
EOF
|
|
||||||
|
|
||||||
cat > "$root/Syntax.wiki" <<'EOF'
|
|
||||||
= Syntax showcase =
|
|
||||||
|
|
||||||
Back to [[index]].
|
|
||||||
|
|
||||||
== Inline formatting ==
|
|
||||||
|
|
||||||
*bold*, _italic_, *_bold italic_*, ~~strikethrough~~, `inline code`,
|
|
||||||
super^script^ and sub,,script,,, and inline math $e^{i\pi} + 1 = 0$.
|
|
||||||
|
|
||||||
== Keywords ==
|
|
||||||
|
|
||||||
TODO STARTED FIXME XXX DONE FIXED STOPPED
|
|
||||||
|
|
||||||
== Horizontal rule ==
|
|
||||||
|
|
||||||
----
|
|
||||||
|
|
||||||
== Blockquote ==
|
|
||||||
|
|
||||||
> A quoted line.
|
|
||||||
> A second quoted line.
|
|
||||||
|
|
||||||
== Definition list ==
|
|
||||||
|
|
||||||
Term:: Definition of the term.
|
|
||||||
Another:: Its definition.
|
|
||||||
|
|
||||||
== Code block ==
|
|
||||||
|
|
||||||
{{{python
|
|
||||||
def greet(name):
|
|
||||||
return f"hello {name}"
|
|
||||||
}}}
|
|
||||||
|
|
||||||
== Math block ==
|
|
||||||
|
|
||||||
{{$
|
|
||||||
\sum_{i=1}^{n} i = \frac{n(n+1)}{2}
|
|
||||||
}}$
|
|
||||||
|
|
||||||
== Comments ==
|
|
||||||
|
|
||||||
%% a single-line comment
|
|
||||||
%%+ a multi-line
|
|
||||||
comment block +%%
|
|
||||||
|
|
||||||
== Transclusion ==
|
|
||||||
|
|
||||||
{{file:image.png}}
|
|
||||||
{{image.png|alt text|width=120}}
|
|
||||||
EOF
|
|
||||||
|
|
||||||
cat > "$root/Lists.wiki" <<'EOF'
|
|
||||||
= Lists =
|
|
||||||
|
|
||||||
Back to [[index]].
|
|
||||||
|
|
||||||
== Unordered ==
|
|
||||||
|
|
||||||
- item with dash
|
|
||||||
- second
|
|
||||||
- nested under dash
|
|
||||||
* item with star
|
|
||||||
# item with hash
|
|
||||||
|
|
||||||
== Ordered ==
|
|
||||||
|
|
||||||
1. first
|
|
||||||
2. second
|
|
||||||
1. nested ordered
|
|
||||||
1) paren style
|
|
||||||
a) alpha
|
|
||||||
A) Alpha
|
|
||||||
i) roman
|
|
||||||
I) Roman
|
|
||||||
|
|
||||||
== Checkbox states ==
|
|
||||||
|
|
||||||
- [ ] empty (0%)
|
|
||||||
- [.] started (1-33%)
|
|
||||||
- [o] in progress (34-66%)
|
|
||||||
- [O] nearly done (67-99%)
|
|
||||||
- [X] done (100%)
|
|
||||||
- [-] rejected
|
|
||||||
|
|
||||||
== Nested with checkboxes ==
|
|
||||||
|
|
||||||
- [ ] parent task
|
|
||||||
- [X] done subtask
|
|
||||||
- [ ] pending subtask
|
|
||||||
- [ ] deep subtask
|
|
||||||
EOF
|
|
||||||
|
|
||||||
cat > "$root/Tables.wiki" <<'EOF'
|
|
||||||
= Tables =
|
|
||||||
|
|
||||||
Back to [[index]].
|
|
||||||
|
|
||||||
== Plain ==
|
|
||||||
|
|
||||||
| Name | Role |
|
|
||||||
| Alice | Author |
|
|
||||||
| Bob | Editor |
|
|
||||||
|
|
||||||
== Aligned ==
|
|
||||||
|
|
||||||
| Left | Center | Right |
|
|
||||||
|:-----|:------:|------:|
|
|
||||||
| a | b | c |
|
|
||||||
| d | e | f |
|
|
||||||
|
|
||||||
== Spanning cells ==
|
|
||||||
|
|
||||||
| Header | Span |
|
|
||||||
| cell | > |
|
|
||||||
| rowspan | value |
|
|
||||||
| \/ | value |
|
|
||||||
EOF
|
|
||||||
|
|
||||||
cat > "$root/Links.wiki" <<'EOF'
|
|
||||||
= Links =
|
|
||||||
|
|
||||||
Back to [[index]].
|
|
||||||
|
|
||||||
== Wikilinks ==
|
|
||||||
|
|
||||||
- [[Notes]]
|
|
||||||
- [[Notes|described]]
|
|
||||||
- [[Notes#Section one]]
|
|
||||||
- [[Notes#Section one|anchored + described]]
|
|
||||||
- [[/index]]
|
|
||||||
- [[diary/]]
|
|
||||||
- [[#Wikilinks]]
|
|
||||||
|
|
||||||
== Diary and interwiki ==
|
|
||||||
|
|
||||||
- [[diary:2026-05-30]]
|
|
||||||
- [[wiki1:index]]
|
|
||||||
- [[wn.MyWiki:index]]
|
|
||||||
|
|
||||||
== External and raw URLs ==
|
|
||||||
|
|
||||||
- [[https://example.com]]
|
|
||||||
- [[https://example.com|Example]]
|
|
||||||
- https://example.com
|
|
||||||
- mailto:gffranco@gmail.com
|
|
||||||
- file:///etc/hosts
|
|
||||||
EOF
|
|
||||||
|
|
||||||
cat > "$root/Notes.wiki" <<'EOF'
|
|
||||||
= Notes =
|
|
||||||
|
|
||||||
A page that other pages point at. Back to [[index]].
|
|
||||||
|
|
||||||
== Section one ==
|
|
||||||
|
|
||||||
Anchor target for cross-page links.
|
|
||||||
|
|
||||||
== Section two ==
|
|
||||||
|
|
||||||
Another anchor target.
|
|
||||||
EOF
|
|
||||||
|
|
||||||
cat > "$root/diary/diary.wiki" <<'EOF'
|
|
||||||
= Diary =
|
|
||||||
|
|
||||||
Back to [[/index]].
|
|
||||||
|
|
||||||
- [[2026-05-30]]
|
|
||||||
EOF
|
|
||||||
|
|
||||||
cat > "$root/diary/2026-05-30.wiki" <<'EOF'
|
|
||||||
= 2026-05-30 =
|
|
||||||
|
|
||||||
A diary entry. Back to [[diary]].
|
|
||||||
|
|
||||||
- [X] set up sample wiki
|
|
||||||
- [ ] review every feature page
|
|
||||||
EOF
|
|
||||||
}
|
|
||||||
|
|
||||||
seed_wiki() {
|
|
||||||
if [[ "${NUWIKI_DEV_NO_SEED:-0}" == "1" ]]; then
|
|
||||||
log "NUWIKI_DEV_NO_SEED=1 — skipping wiki seed (using $WIKI_DIR as-is)"
|
|
||||||
return
|
|
||||||
fi
|
|
||||||
# Seed the whole showcase as a unit; skip when an index already exists
|
|
||||||
# so a re-run never clobbers edits made while testing.
|
|
||||||
if [[ -f "$WIKI_DIR/index.wiki" ]]; then
|
|
||||||
return
|
|
||||||
fi
|
|
||||||
write_sample_wiki "$WIKI_DIR"
|
|
||||||
}
|
|
||||||
|
|
||||||
write_vimrc() {
|
write_vimrc() {
|
||||||
mkdir -p "$DEV_DIR"
|
mkdir -p "$DEV_DIR"
|
||||||
cat > "$VIMRC" <<EOF
|
cat > "$VIMRC" <<EOF
|
||||||
|
|||||||
Reference in New Issue
Block a user