From 959e7ab631f07aeea35d0d7660d063e842e5f3b6 Mon Sep 17 00:00:00 2001 From: jack Date: Fri, 19 Mar 2021 12:12:44 +1030 Subject: [PATCH 1/2] add install script --- install.sh | 81 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 81 insertions(+) create mode 100755 install.sh diff --git a/install.sh b/install.sh new file mode 100755 index 0000000..aacbc55 --- /dev/null +++ b/install.sh @@ -0,0 +1,81 @@ +#!/usr/bin/env bash +BASE=$(git rev-parse --show-toplevel) +LSP_BIN_PATH=$HOME/.local/bin + +default_langs="ts rust" +lsp_langs=${@:-"$default_langs"} + +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 +} + +heading "Linking config" +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 + +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 + +heading "Installing plugins" +nvim --headless +PackerInstall +qa +nvim --headless +TSUpdate +qa +echo + +fn_exists() { declare -F "$1" > /dev/null; } +warn_path=false + +install_ts() { + if [[ -z $(which npm) ]]; then + echo "npm not installed" + return + fi + npm install -g vscode-html-languageserver-bin typescript typescript-language-server vscode-css-languageserver-bin prettier +} + +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 +} + +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 From 3abb3ed97e953132e2527fe2893a88607b916f5b Mon Sep 17 00:00:00 2001 From: jack Date: Fri, 19 Mar 2021 13:31:09 +1030 Subject: [PATCH 2/2] fix(install): add css and html to default_lsp_langs --- install.sh | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/install.sh b/install.sh index aacbc55..9b739a4 100755 --- a/install.sh +++ b/install.sh @@ -2,8 +2,8 @@ BASE=$(git rev-parse --show-toplevel) LSP_BIN_PATH=$HOME/.local/bin -default_langs="ts rust" -lsp_langs=${@:-"$default_langs"} +default_lsp_langs="css html ts rust" +lsp_langs=${@:-"$default_lsp_langs"} pfx="~~~~~ " heading() { @@ -46,12 +46,24 @@ echo fn_exists() { declare -F "$1" > /dev/null; } warn_path=false -install_ts() { +install_node_deps () { if [[ -z $(which npm) ]]; then echo "npm not installed" return fi - npm install -g vscode-html-languageserver-bin typescript typescript-language-server vscode-css-languageserver-bin prettier + npm install -g $@ +} + +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 } install_rust() {