#!/usr/bin/env bash ## The MIT License (MIT) ## ## Copyright © 2026 Scott E. Graves ## ## Permission is hereby granted, free of charge, to any person obtaining a copy of this software ## and associated documentation files (the “Software”), to deal in the Software without restriction, ## including without limitation the rights to use, copy, modify, merge, publish, distribute, ## sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is ## furnished to do so, subject to the following conditions: ## ## The above copyright notice and this permission notice shall be included in all copies or ## substantial portions of the Software. ## ## THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING ## BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND ## NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, ## DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, ## OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ## SCRIPT_DIR="$(dirname "$(readlink -f "$0")")" NVIM_CPPTOOLS_VERSION=1.30.5 NVIM_VERSION=stable NVIM_ARCH=x86_64 NVIM_ARCH2=x64 if uname -m | grep arm || uname -m | grep aarch; then NVIM_ARCH=arm64 NVIM_ARCH2=arm64 fi if uname | grep 'Darwin'; then NVIM_OS="macOS" else NVIM_OS="linux" fi NVIM_REQUIRED_BINARIES=( cmake curl dart flutter fzf g++ gcc git go java make node npm python3 rg rsync sed shfmt sqlite3 tar tidy tree-sitter unzip wget zip ) function create_link() { local cur local res cur=$(readlink -f "$2") res=$(readlink -f "$1") if [ ! -L "$2" ] || [ "${cur}" != "${res}" ]; then echo "linking $1->$2" rm -f "$2" 1>/dev/null 2>&1 ln -sf "$1" "$2" fi } function error_exit() { echo "$1" exit 1 } function check_binary() { if ! command -v "$1" >/dev/null 2>&1; then error_exit "failed to find required binary: $1" fi } function ensure_brew_binary() { if ! command -v "$1" >/dev/null 2>&1; then check_binary brew brew install "$2" fi check_binary "$1" } function ensure_brew_keg_binary() { local formula_prefix if command -v "$1" >/dev/null 2>&1; then return fi check_binary brew formula_prefix=$(brew --prefix "$2") if [ ! -x "${formula_prefix}/bin/$1" ]; then brew install "$2" fi export PATH="${formula_prefix}/bin:${PATH}" check_binary "$1" } export PATH="${HOME}/.local/bin:${PATH}" for BINARY in "${NVIM_REQUIRED_BINARIES[@]}"; do check_binary "$BINARY" done if ! command -v eslint >/dev/null 2>&1; then npm install --global --prefix "${HOME}/.local" eslint fi check_binary eslint if ! command -v luafmt >/dev/null 2>&1; then npm install --global --prefix "${HOME}/.local" lua-fmt fi check_binary luafmt if [ "${NVIM_OS}" = "macOS" ]; then ensure_brew_binary cppcheck cppcheck ensure_brew_binary cppman cppman ensure_brew_binary pwsh powershell ensure_brew_binary vala-language-server vala-language-server ensure_brew_keg_binary clang-tidy llvm fi check_binary clang-tidy check_binary cppcheck check_binary cppman check_binary valac pushd "${SCRIPT_DIR}" 1>/dev/null 2>&1 || error_exit "failed to push: ${SCRIPT_DIR}" FNAME=cpptools-${NVIM_OS}-${NVIM_ARCH2}.vsix if [ ! -f "dap/${FNAME}" ]; then mkdir -p dap/ wget "https://github.com/microsoft/vscode-cpptools/releases/download/v${NVIM_CPPTOOLS_VERSION}/${FNAME}" \ -O "dap/${FNAME}" fi if [ ! -d "${HOME}/.local/share/${NVIM_APPNAME}/dap/cpp/extension" ]; then mkdir -p "${HOME}/.local/share/${NVIM_APPNAME}/dap/cpp" unzip "dap/${FNAME}" -d "${HOME}/.local/share/${NVIM_APPNAME}/dap/cpp" fi CPPDBG_PATH="${HOME}/.local/share/${NVIM_APPNAME}/dap/cpp/extension/debugAdapters/bin/OpenDebugAD7" if [ -f "${CPPDBG_PATH}" ] && [ ! -x "${CPPDBG_PATH}" ]; then chmod +x "${CPPDBG_PATH}" fi if [ ! -x "${CPPDBG_PATH}" ]; then error_exit "failed to find executable C/C++ debug adapter: ${CPPDBG_PATH}" fi mkdir -p pkg/ if [ ! -f "/tmp/nvim-${NVIM_OS}-${NVIM_ARCH}/bin/nvim" ]; then FNAME=nvim-${NVIM_OS}-${NVIM_ARCH}.tar.gz [[ -f "pkg/${FNAME}" ]] && rm -f "pkg/${FNAME}" wget "https://github.com/neovim/neovim/releases/download/${NVIM_VERSION}/${FNAME}" \ -O "pkg/${FNAME}" fi if [ ! -d "${HOME}/.local/share/${NVIM_APPNAME}/Dart-Code" ]; then mkdir -p "${HOME}/.local/share/${NVIM_APPNAME}" pushd "${HOME}/.local/share/${NVIM_APPNAME}" 1>/dev/null 2>&1 || error_exit "failed to pushd: ${HOME}/.local/share/${NVIM_APPNAME}" git clone https://github.com/Dart-Code/Dart-Code.git pushd "Dart-Code" 1>/dev/null 2>&1 || error_exit "failed to pushd: Dart-Code" npm i npx webpack --mode production popd 1>/dev/null 2>&1 || error_exit "failed to popd: Dart-Code" popd 1>/dev/null 2>&1 || error_exit "failed to popd: ${HOME}/.local/share/${NVIM_APPNAME}" fi if [ ! -e "${HOME}/.local/bin/kiro-cli" ]; then curl -fsSL https://cli.kiro.dev/install | bash fi popd 1>/dev/null 2>&1 || error_exit "failed to popd: ${SCRIPT_DIR}" export NVIM_ARCH export NVIM_ARCH2 export NVIM_CPPTOOLS_VERSION export NVIM_OS export NVIM_REQUIRED_BINARIES export NVIM_VERSION