cb11889e72
Delete all Rust crates (crates/) and Cargo files. The nuwiki-ls binary is now built in the separate nuwiki-rs repository and downloaded at install time from the Gitea release assets, with a cargo build fallback that clones nuwiki-rs. Update all documentation to reflect the split repo layout.
92 lines
3.1 KiB
Bash
Executable File
92 lines
3.1 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
#
|
|
# start-nvim.sh — launch Neovim with a minimal config that loads nuwiki.
|
|
#
|
|
# The plugin's install() downloads a pre-built release of nuwiki-ls for
|
|
# your platform from the nuwiki-rs repository. On first launch a missing
|
|
# binary is auto-downloaded via the bundled Vim script; set
|
|
# NUWIKI_DEV_SKIP_BUILD=1 to skip the download entirely.
|
|
#
|
|
# Usage: ./development/start-nvim.sh [extra args...]
|
|
# ./development/start-nvim.sh # open the scratch wiki's index
|
|
# ./development/start-nvim.sh path/to/note.wiki # open a specific file
|
|
# 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 # skip the download step
|
|
#
|
|
# Each launch starts clean: the scratch wiki is reseeded from a pristine
|
|
# copy and the editor state (cache/data/config) is wiped, so stale edits
|
|
# never carry over. A wiki you point at with NUWIKI_DEV_WIKI is never wiped
|
|
# (seeded only if empty).
|
|
#
|
|
# Tested with Neovim 0.10+. State (cache/data/config) lives under
|
|
# $XDG_CACHE_HOME/nuwiki-dev/ so your real Neovim install stays
|
|
# untouched.
|
|
|
|
set -euo pipefail
|
|
|
|
# Shared paths + helpers (log, ensure_binary, write_sample_wiki, seed_wiki).
|
|
source "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/_common.sh"
|
|
|
|
INIT_FILE="$DEV_DIR/init.lua"
|
|
STATE_DIR="$DEV_DIR/nvim-state"
|
|
DATA_DIR="$DEV_DIR/nvim-data"
|
|
CONFIG_DIR="$DEV_DIR/nvim-config"
|
|
|
|
write_init() {
|
|
mkdir -p "$DEV_DIR"
|
|
cat > "$INIT_FILE" <<EOF
|
|
-- start-nvim.sh: generated minimal config for nuwiki development.
|
|
-- Regenerated on every launch; edit start-nvim.sh, not this file.
|
|
|
|
-- Confine state to the dev cache so we never touch the user's real
|
|
-- Neovim install.
|
|
vim.env.XDG_STATE_HOME = '$STATE_DIR'
|
|
vim.env.XDG_DATA_HOME = '$DATA_DIR'
|
|
vim.env.XDG_CONFIG_HOME = '$CONFIG_DIR'
|
|
|
|
vim.opt.runtimepath:prepend('$REPO_ROOT')
|
|
vim.opt.runtimepath:append('$DEV_DIR/calendar-vim')
|
|
|
|
vim.g.nuwiki_binary_path = '$REPO_ROOT/bin/nuwiki-ls'
|
|
vim.g.nuwiki_wiki_root = '$WIKI_DIR'
|
|
vim.g.nuwiki_file_extension = '.wiki'
|
|
vim.g.nuwiki_syntax = 'vimwiki'
|
|
vim.g.nuwiki_diary_rel_path = 'diary'
|
|
|
|
require('nuwiki').setup({
|
|
wiki_root = '$WIKI_DIR',
|
|
-- Exercise the per-wiki display settings via the global shorthand: these
|
|
-- fold into the single wiki, so :NuwikiTOC writes `== Contents ==` (level 2)
|
|
-- and HTML export numbers headings.
|
|
toc_header_level = 2,
|
|
html_header_numbering = 2,
|
|
html_header_numbering_sym = ' -',
|
|
})
|
|
|
|
-- Surface log lines (the LSP logs via window/logMessage). Without this
|
|
-- they're swallowed; with it they land in :messages.
|
|
vim.lsp.set_log_level('info')
|
|
|
|
print('[nuwiki-dev] ready — wiki root: ' .. '$WIKI_DIR')
|
|
print('[nuwiki-dev] :LspInfo to inspect, :checkhealth nuwiki for diagnostics')
|
|
EOF
|
|
}
|
|
|
|
main() {
|
|
ensure_binary
|
|
ensure_calendar_vim
|
|
seed_wiki
|
|
write_init
|
|
reset_dirs "$STATE_DIR" "$DATA_DIR" "$CONFIG_DIR"
|
|
|
|
log "launching: nvim --clean -u $INIT_FILE"
|
|
if [[ $# -gt 0 ]]; then
|
|
exec nvim --clean -u "$INIT_FILE" "$@"
|
|
else
|
|
exec nvim --clean -u "$INIT_FILE" "$WIKI_DIR/index.wiki"
|
|
fi
|
|
}
|
|
|
|
main "$@"
|