neovim-confs/install.sh

115 lines
2.5 KiB
Bash
Raw Normal View History

2021-03-19 02:42:44 +01:00
#!/usr/bin/env bash
BASE=$(git rev-parse --show-toplevel)
LSP_BIN_PATH=$HOME/.local/bin
default_lsp_langs="css html ts rust python"
lsp_langs=${@:-"$default_lsp_langs"}
2021-03-19 02:42:44 +01:00
pfx="~~~~~ "
heading() {
echo
echo $pfx $1
}
get_platform() {
case "$(uname -s)" in
Linux*) platform=Linux;;
Darwin*) platform=Mac;;
CYGWIN*) platform=Cygwin;;
MINGW*) platform=MinGw;;
*) platform="UNKNOWN:${unameOut}"
esac
echo $platform
}
2021-03-28 19:50:53 +02:00
heading "installing packer"
if [[ ! -e ~/.local/share/nvim/site/pack/packer/start/packer.nvim ]]; then
heading "Installing packer"
git clone https://github.com/wbthomason/packer.nvim\
~/.local/share/nvim/site/pack/packer/start/packer.nvim
fi
2021-03-19 02:42:44 +01:00
heading "Linking config"
2021-03-28 19:50:53 +02:00
heading "old nvim config will be deleted so watchout :0"
2021-03-27 03:50:15 +01:00
# copying config
2021-04-01 14:00:32 +02:00
rm -rf ~/.config/nvim/ && mkdir -p ~/.config/nvim
2021-03-28 19:50:53 +02:00
cp -r init.lua ~/.config/nvim && cp -r lua ~/.config/nvim
2021-03-27 03:50:15 +01: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-19 02:42:44 +01:00
2021-03-28 19:50:53 +02:00
#heading "Installing plugins"
2021-03-27 03:50:15 +01:00
#nvim --headless +PackerInstall +qa
#nvim --headless +TSUpdate +qa
2021-03-19 02:42:44 +01:00
echo
fn_exists() { declare -F "$1" > /dev/null; }
warn_path=false
install_node_deps () {
2021-03-19 02:42:44 +01:00
if [[ -z $(which npm) ]]; then
echo "npm not installed"
return
fi
2021-04-01 13:54:10 +02:00
sudo npm install -g $@
}
install_python_deps () {
2021-04-01 13:57:15 +02:00
if [[ -z $(which pip) && -z $(which pip3) ]]; then
2021-04-01 13:40:38 +02:00
echo "python/pip not installed"
return
fi
2021-04-01 13:54:10 +02:00
sudo python3 -m pip install $@
}
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-19 02:42:44 +01: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
}
install_python(){
install_python_deps 'python-language-server[all]'
}
2021-03-19 02:42:44 +01:00
for lang in ${lsp_langs}; do
if fn_exists install_$lang ; then
heading "Installing $lang language server"
install_$lang
else
echo $lang setup not implemented
echo
fi
done
if [[ ${warn_path} = true ]]; then
echo ""
echo "Ensure ${LSP_BIN_PATH} is available in your \$PATH variable"
fi