Major clean up and improvements to vimwiki compatibility and documentation.
Reviewed-on: #1
This commit was merged in pull request #1.
This commit is contained in:
Executable
+91
@@ -0,0 +1,91 @@
|
||||
#!/usr/bin/env bash
|
||||
#
|
||||
# start-nvim.sh — launch Neovim with a minimal config that loads nuwiki.
|
||||
#
|
||||
# Builds the language server (release mode), symlinks it into `bin/` so
|
||||
# the plugin's default install path resolves, then spawns Neovim with
|
||||
# `--clean` and a generated `init.lua` that:
|
||||
# * adds this repo to `runtimepath`
|
||||
# * configures wiki_root to a scratch directory under
|
||||
# $XDG_CACHE_HOME/nuwiki-dev/wiki
|
||||
# * calls `require('nuwiki').setup({...})`
|
||||
#
|
||||
# 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 # reuse the cached binary
|
||||
#
|
||||
# The release binary is rebuilt on every launch so source changes
|
||||
# always reach the running LSP. `cargo build --release` is incremental,
|
||||
# so this is a fast no-op when nothing changed. Set
|
||||
# NUWIKI_DEV_SKIP_BUILD=1 to skip the build step entirely.
|
||||
#
|
||||
# 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.g.nuwiki_binary_path = '$REPO_ROOT/bin/nuwiki-ls'
|
||||
|
||||
-- Friendly defaults for an interactive smoke test.
|
||||
vim.opt.number = true
|
||||
vim.opt.signcolumn = 'yes'
|
||||
vim.opt.termguicolors = true
|
||||
vim.opt.swapfile = false
|
||||
vim.opt.writebackup = false
|
||||
vim.opt.undofile = false
|
||||
vim.g.mapleader = ' '
|
||||
|
||||
require('nuwiki').setup({
|
||||
wiki_root = '$WIKI_DIR',
|
||||
})
|
||||
|
||||
-- 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
|
||||
seed_wiki
|
||||
write_init
|
||||
mkdir -p "$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 "$@"
|
||||
Reference in New Issue
Block a user