Something went wrong. Try again.
Neovim Plugin Template
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233#!/usr/bin/env bash# scripts/rename.sh — rename the template to a new plugin name.# Usage: make rename NAME=your-name/your-plugin.nvimset -euo pipefail
NEW="${1:-}"if [ -z "$NEW" ]; then echo "usage: $0 <owner>/<repo>.nvim (e.g. you/foo.nvim)"; exit 1fi
OLD="marco-souza/plugin.nvim"REPO_NAME="$(basename "$NEW")"LUAMOD="${REPO_NAME%.nvim}"# nvim user commands must start uppercase: coollib -> CoollibCMD="$(printf '%s' "${LUAMOD:0:1}" | tr '[:lower:]' '[:upper:]')${LUAMOD:1}"
echo "===> Renaming $OLD -> $NEW (lua module: $LUAMOD, command: $CMD)"
# lua module dirgit mv "lua/plugin" "lua/$LUAMOD" 2>/dev/null || mv "lua/plugin" "lua/$LUAMOD"
# perl -i is portable across macOS/linux, unlike sed -isub() { perl -i -pe "$1" "$2"; }
grep -rl 'require("plugin")' --include='*.lua' tests lua 2>/dev/null | while read -r f; do sub "s/\brequire\(\"plugin\"\)/require(\"$LUAMOD\")/g" "$f"done
sub "s|\Q$OLD\E|$NEW|g" README.mdsub "s|\Q$OLD\E|$NEW|g" plugin.jsonsub "s/M.command = \"Plugin\"/M.command = \"$CMD\"/g" "lua/$LUAMOD/init.lua"
echo "===> Done. Review with: git status && git diff"