vim-settings/install-language-servers.sh

137 lines
3.9 KiB
Bash
Raw Normal View History

2019-10-24 19:40:10 +00:00
#! /bin/bash
# Clear explicit PYTHONPATH since this gets confused between py2 and py3
export PYTHONPATH=""
2021-12-17 19:25:06 +00:00
# Ignore failed installs
if [ -z "$IGNORE_MISSING" ]; then
set -e
else
set +e
fi
# Determines if a command exists or not
function command_exist() {
command -v "$1" > /dev/null 2>&1;
}
# Runs a command or spits out the output
function maybe_run() {
if command_exist "$1" ;then
echo "> $*"
# shellcheck disable=2048,2086
eval $*
else
echo "ERROR: $1 does not exist. Could not run $*"
fi
}
2019-10-24 19:40:10 +00:00
## Language servers
function install_language_servers() {
echo "### Installing language servers..."
2019-10-24 19:40:10 +00:00
# bash
maybe_run npm install -g bash-language-server
2019-10-24 19:40:10 +00:00
# Kotlin
# https://github.com/fwcd/kotlin-language-server/blob/master/BUILDING.md
2019-10-24 19:40:10 +00:00
# Python
maybe_run pip install --user --upgrade python-language-server
maybe_run pip3 install --user --upgrade python-language-server
2021-12-09 01:12:01 +00:00
maybe_run pip install --user "python-lsp-server[all]" || echo "WARNING: python-lsp-server is py3 only"
maybe_run pip3 install --user "python-lsp-server[all]"
maybe_run npm install -g pyright
2019-10-24 19:40:10 +00:00
# Rust
maybe_run rustup component add rls rustfmt rust-analysis rust-src clippy rustfmt
2019-10-24 19:40:10 +00:00
# Go
maybe_run env GO111MODULE=on go install golang.org/x/tools/gopls@latest
echo ""
}
2019-10-24 19:40:10 +00:00
## Linters
function install_linters() {
echo "### Installing linters..."
2019-10-24 19:40:10 +00:00
# Python
maybe_run pip install --user --upgrade flake8
maybe_run pip install --user --upgrade mypy || echo "WARNING: mypy is py3 only"
maybe_run pip3 install --user --upgrade flake8 mypy
2019-10-24 19:40:10 +00:00
# CSS
maybe_run npm install -g csslint
2019-10-24 19:40:10 +00:00
# Vim
maybe_run pip install --user --upgrade vim-vint
maybe_run pip3 install --user --upgrade vim-vint
2019-10-29 19:33:08 +00:00
# YAML
maybe_run pip install --user --upgrade yamllint
maybe_run pip3 install --user --upgrade yamllint
2019-10-24 19:40:10 +00:00
# Text / Markdown
2022-01-12 17:21:08 +00:00
maybe_run npm install -g alex write-good
maybe_run pip install --user --upgrade proselint
maybe_run pip3 install --user --upgrade proselint
2019-10-24 19:40:10 +00:00
# Makefile
# maybe_run go install github.com/mrtazz/checkmake@latest
2019-10-24 19:40:10 +00:00
2022-01-10 20:39:25 +00:00
# Go
maybe_run release-gitter --git-url "https://github.com/golangci/golangci-lint" \
--map-system Windows=windows --map-system Linux=linux --map-system Darwin=darwin \
--map-arch x86_64=amd64 --map-arch armv7l=armv7 --map-arch aarch64=arm64 \
2022-01-10 20:39:25 +00:00
--extract-files golangci-lint "golangci-lint-{version}-{system}-{arch}.tar.gz" ~/bin
# Lua
2021-12-15 17:36:50 +00:00
maybe_run luarocks --local install luacheck
2022-01-21 17:21:17 +00:00
# Docker
maybe_run release-gitter --git-url "https://github.com/hadolint/hadolint" \
-c '"mv ~/bin/hadolint-* ~/bin/hadolint && chmod +x ~/bin/hadolint"' \
2022-01-21 17:21:17 +00:00
"hadolint-{system}-x86_64" ~/bin
echo ""
}
2019-10-24 19:40:10 +00:00
## Fixers
function install_fixers() {
echo "### Installing fixers..."
# CSS/JS/HTML/JSON/YAML/Markdown/and more!
maybe_run npm install -g prettier
# Python
maybe_run pip install --user --upgrade autopep8 reorder-python-imports
maybe_run pip install --user --upgrade black pyls-black python-lsp-black pyls-isort pyls-mypy || echo "WARNING: black is py3 only"
maybe_run pip3 install --user --upgrade black pyls-black python-lsp-black pyls-isort pyls-mypy autopep8 reorder-python-imports
# Rust
maybe_run rustup component add rustfmt
2021-12-15 17:22:20 +00:00
# Lua
if ! release-gitter --git-url "https://github.com/JohnnyMorganz/StyLua" \
--map-system Windows=win64 --map-system Linux=linux --map-system Darwin=macos \
--map-arch x86_64="" --map-arch aarch64=-aarch64 \
-x -c "chmod +x ~/bin/stylua" "stylua-{system}{arch}.zip" ~/bin ; then
maybe_run cargo install stylua
fi
2021-12-15 17:22:20 +00:00
echo ""
}
function main() {
maybe_run pip3 install --user --upgrade release-gitter
install_language_servers
install_linters
install_fixers
2019-10-30 00:33:14 +00:00
echo ""
echo "DONE"
}
main