98 lines
3.3 KiB
Bash
Executable File
98 lines
3.3 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
|
|
## The MIT License (MIT)
|
|
##
|
|
## Copyright © 2026 Scott E. Graves <scott.e.graves@protonmail.com>
|
|
##
|
|
## 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=nightly
|
|
|
|
NVIM_ARCH=x86_64
|
|
NVIM_ARCH2=x64
|
|
if uname -m | grep arm; then
|
|
NVIM_ARCH=arm64
|
|
NVIM_ARCH2=arm64
|
|
fi
|
|
|
|
if uname | grep 'Darwin'; then
|
|
NVIM_OS="macOS"
|
|
else
|
|
NVIM_OS="linux"
|
|
fi
|
|
|
|
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
|
|
}
|
|
|
|
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
|
|
|
|
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
|
|
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_VERSION
|
|
export NVIM_OS
|