Add rust-analyzer support

pull/2/head
Ensar Sarajčić 2021-11-19 17:13:59 +01:00
parent 020d00dbe7
commit eecdb79987
1 changed files with 468 additions and 441 deletions

View File

@ -181,24 +181,27 @@ echov "Detected server: $SERVER"
echov "Detected version: $VERSION"
declare -A SUPPORTED_SERVERS=(
["java"]="jdtls"
["dotnet"]="omnisharp"
["haskell"]="hls"
["solidity"]="solang"
["xml"]="lemminx"
["kotlin"]="kotlin-language-server"
["java"]="jdtls"
["dotnet"]="omnisharp"
["haskell"]="hls"
["solidity"]="solang"
["xml"]="lemminx"
["kotlin"]="kotlin-language-server",
["rust"]="rust-analyzer"
)
declare -A LINK_SOURCES=(
["omnisharp"]="$HOME/lsp/dotnet/omnisharp/run"
["solang"]="$HOME/lsp/solidity/solang/solang"
["lemminx"]="$HOME/lsp/xml/lemminx/lemminx"
["kotlin-language-server"]="$HOME/lsp/kotlin/kotlin-language-server/bin/kotlin-language-server"
["omnisharp"]="$HOME/lsp/dotnet/omnisharp/run"
["solang"]="$HOME/lsp/solidity/solang/solang"
["lemminx"]="$HOME/lsp/xml/lemminx/lemminx"
["kotlin-language-server"]="$HOME/lsp/kotlin/kotlin-language-server/bin/kotlin-language-server"
["rust-analyzer"]="$HOME/lsp/rust/rust-analyzer/rust-analyzer"
)
declare -A LINK_TARGETS=(
["omnisharp"]="$HOME/.local/bin/omnisharp"
["solang"]="$HOME/.local/bin/solang"
["lemminx"]="$HOME/.local/bin/lemminx"
["kotlin-language-server"]="$HOME/.local/bin/kotlin-language-server"
["omnisharp"]="$HOME/.local/bin/omnisharp"
["solang"]="$HOME/.local/bin/solang"
["lemminx"]="$HOME/.local/bin/lemminx"
["kotlin-language-server"]="$HOME/.local/bin/kotlin-language-server"
["rust-analyzer"]="$HOME/.local/bin/rust-analyzer"
)
is_linked () {
@ -383,6 +386,27 @@ install () {
unzip /tmp/kotlin-language-server.zip -d /tmp/kotlin-language-server
mv /tmp/kotlin-language-server/server $HOME/lsp/kotlin/kotlin-language-server
;;
rust-analyzer)
if [ -z "$VERSION" ]; then
VERSION="2021-11-15"
fi
BASE_FILE_NAME="rust-analyzer-x86_64"
case $UNAME in
Linux)
FILE_NAME="${BASE_FILE_NAME}-unknown-linux-gnu.gz"
;;
Windows)
FILE_NAME="${BASE_FILE_NAME}-pc-windows-msvc.gz"
;;
Darwin)
FILE_NAME="${BASE_FILE_NAME}-apple-darwin.gz"
;;
esac
wget -O - https://github.com/rust-analyzer/rust-analyzer/releases/download/$VERSION/$FILE_NAME > /tmp/rust-analyzer.gz
mkdir -p $HOME/lsp/rust/rust-analyzer
gunzip /tmp/rust-analyzer.gz -c > $HOME/lsp/rust/rust-analyzer/rust-analyzer
chmod +x $HOME/lsp/rust/rust-analyzer/rust-analyzer
;;
*)
echo "Unknown server: $SERVER"
echo "Run 'lsp status --all' for a list of available servers"
@ -421,6 +445,9 @@ uninstall () {
kotlin-language-server)
rm -rf $HOME/lsp/kotlin/kotlin-language-server
;;
rust-analyzer)
rm -rf $HOME/lsp/rust/rust-analyzer
;;
*)
echo "Unknown server: $SERVER"
echo "Run 'lsp status' for a list of installed servers"