nvchad/install.sh

144 lines
3.0 KiB
Bash
Raw Normal View History

2021-03-18 21:42:44 -04:00
#!/usr/bin/env bash
BASE=$(git rev-parse --show-toplevel)
LSP_BIN_PATH=$HOME/.local/bin
2021-04-26 04:26:27 -04:00
default_lsp_langs="css html ts rust python bash"
lsp_langs=""
choose_langs() {
read -p "Would you like to install $1 lsp?(y/n)" lang
2021-04-07 21:59:39 -04:00
if [ "$lang" = "y" ]; then
lsp_langs+="$1 "
fi
}
2021-04-07 21:59:39 -04:00
for lang in $default_lsp_langs; do
choose_langs $lang
done
2021-03-18 21:42:44 -04:00
npm config set prefix=~/.node_modules # for global npm pkg installation
2021-03-18 21:42:44 -04:00
pfx="~~~~~ "
heading() {
echo
echo $pfx $1
}
get_platform() {
case "$(uname -s)" in
2021-04-07 21:59:39 -04:00
Linux*) platform=Linux ;;
Darwin*) platform=Mac ;;
CYGWIN*) platform=Cygwin ;;
MINGW*) platform=MinGw ;;
*) platform="UNKNOWN:${unameOut}" ;;
2021-03-18 21:42:44 -04:00
esac
echo $platform
}
2021-03-28 13:50:53 -04:00
heading "installing packer"
if [[ ! -e ~/.local/share/nvim/site/pack/packer/start/packer.nvim ]]; then
heading "Installing packer"
2021-04-07 21:59:39 -04:00
git clone https://github.com/wbthomason/packer.nvim \
2021-03-28 13:50:53 -04:00
~/.local/share/nvim/site/pack/packer/start/packer.nvim
fi
2021-03-18 21:42:44 -04:00
heading "Linking config"
2021-03-28 13:50:53 -04:00
heading "old nvim config will be deleted so watchout :0"
2021-03-26 22:50:15 -04:00
2021-04-07 21:59:39 -04:00
# copying config
2021-03-26 22:50:15 -04:00
2021-04-01 08:00:32 -04:00
rm -rf ~/.config/nvim/ && mkdir -p ~/.config/nvim
2021-04-07 21:59:39 -04:00
cp -r init.lua ~/.config/nvim && cp -r lua ~/.config/nvim
2021-03-26 22:50:15 -04:00
2021-04-06 00:05:22 -04:00
# change shell for nvim
read -p "which shell do you use?: " shellname
echo "$shellname"
2021-04-24 08:51:13 -04:00
if [ "$(get_platform)" = "Mac" ]; then
gsed -i "s/bash/$shellname/g" ~/.config/nvim/lua/mappings.lua
2021-04-24 08:51:13 -04:00
else
sed -i "s/bash/$shellname/g" ~/.config/nvim/lua/mappings.lua
2021-04-24 08:51:13 -04:00
fi
2021-04-06 00:05:22 -04:00
echo "shell changed to $shellname on nvim successfully!"
2021-03-26 22:50:15 -04:00
#for f in `find -E . -regex ".*\.vim$|.*\.lua$"`; do
# p=${f#*/}
# echo -e '\t' ${p}
# path=~/.config/nvim/${p}
# rm -rf ~/.config/nvim/${p}
# mkdir -p $(dirname "${path}")
# ln -s ${BASE}/${p} ~/.config/nvim/${p}
#done
2021-03-18 21:42:44 -04:00
2021-03-28 13:50:53 -04:00
#heading "Installing plugins"
2021-03-26 22:50:15 -04:00
#nvim --headless +PackerInstall +qa
#nvim --headless +TSUpdate +qa
2021-03-18 21:42:44 -04:00
echo
2021-04-07 21:59:39 -04:00
fn_exists() { declare -F "$1" >/dev/null; }
2021-03-18 21:42:44 -04:00
warn_path=false
2021-04-07 21:59:39 -04:00
install_node_deps() {
2021-03-18 21:42:44 -04:00
if [[ -z $(which npm) ]]; then
echo "npm not installed"
return
fi
npm install -g $@
}
2021-04-26 04:26:27 -04:00
# install languages
install_ts() {
install_node_deps typescript typescript-language-server prettier
}
install_html() {
install_node_deps vscode-html-languageserver-bin
}
install_css() {
install_node_deps vscode-css-languageserver-bin
2021-03-18 21:42:44 -04:00
}
install_rust() {
if [[ ! -e ~/.local/bin/rust-analyzer ]]; then
mkdir -p ${LSP_BIN_PATH}
curl -L https://github.com/rust-analyzer/rust-analyzer/releases/latest/download/rust-analyzer-$(get_platform) -o ~/.local/bin/rust-analyzer
chmod +x ~/.local/bin/rust-analyzer
warn_path=true
else
echo "already installed"
fi
}
2021-04-07 21:59:39 -04:00
install_python() {
install_node_deps pyright
}
2021-04-26 04:26:27 -04:00
install_bash() {
install_node_deps bash-language-server
}
2021-03-18 21:42:44 -04:00
for lang in ${lsp_langs}; do
2021-04-07 21:59:39 -04:00
if fn_exists install_$lang; then
2021-03-18 21:42:44 -04:00
heading "Installing $lang language server"
install_$lang
else
echo $lang setup not implemented
2021-04-07 21:59:39 -04:00
echo
2021-03-18 21:42:44 -04:00
fi
done
2021-04-07 21:59:39 -04:00
if [[ ${warn_path} == true ]]; then
2021-03-18 21:42:44 -04:00
echo ""
echo "Ensure ${LSP_BIN_PATH} is available in your \$PATH variable"
fi
2021-04-12 07:07:15 -04:00
echo "add ~/.node_modules/bin at PATH!"
2021-04-12 07:07:15 -04:00
# install all plugins via packer
nvim +PackerInstall