Add rust-analyzer support
parent
020d00dbe7
commit
eecdb79987
909
symlinks/bin/lsp
909
symlinks/bin/lsp
|
@ -3,120 +3,120 @@
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
echov () {
|
echov () {
|
||||||
if [ $VERBOSE -eq 1 ]; then
|
if [ $VERBOSE -eq 1 ]; then
|
||||||
echo "$@"
|
echo "$@"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
usage () {
|
usage () {
|
||||||
case $1 in
|
case $1 in
|
||||||
install)
|
install)
|
||||||
usage_install; exit 0 ;;
|
usage_install; exit 0 ;;
|
||||||
uninstall)
|
uninstall)
|
||||||
usage_uninstall; exit 0 ;;
|
usage_uninstall; exit 0 ;;
|
||||||
status)
|
status)
|
||||||
usage_status; exit 0 ;;
|
usage_status; exit 0 ;;
|
||||||
link)
|
link)
|
||||||
usage_link; exit 0 ;;
|
usage_link; exit 0 ;;
|
||||||
esac
|
esac
|
||||||
if [ ! -z "$1" ]; then
|
if [ ! -z "$1" ]; then
|
||||||
echo -e "Unknown command: $1 \n"
|
echo -e "Unknown command: $1 \n"
|
||||||
fi
|
fi
|
||||||
echo "Basic LSP (Language Server Protocol) manager."
|
echo "Basic LSP (Language Server Protocol) manager."
|
||||||
echo "Manages installations of language servers."
|
echo "Manages installations of language servers."
|
||||||
echo -e "\nUsage: lsp COMMAND [options] [arguments] \n"
|
echo -e "\nUsage: lsp COMMAND [options] [arguments] \n"
|
||||||
echo "Commands:"
|
echo "Commands:"
|
||||||
echo " install - installs a new language server (or a new version of already installed one)"
|
echo " install - installs a new language server (or a new version of already installed one)"
|
||||||
echo " link - links previously installed language server to $HOME/.local/bin"
|
echo " link - links previously installed language server to $HOME/.local/bin"
|
||||||
echo " status - prints status of servers installed (if server name is passed, prints status of that server)"
|
echo " status - prints status of servers installed (if server name is passed, prints status of that server)"
|
||||||
echo " uninstall - uninstalls a language server"
|
echo " uninstall - uninstalls a language server"
|
||||||
echo ""
|
echo ""
|
||||||
echo "Options:"
|
echo "Options:"
|
||||||
echo " -h --help - prints this help message (if one of commands is passed, prints help message for that command)"
|
echo " -h --help - prints this help message (if one of commands is passed, prints help message for that command)"
|
||||||
echo " -v --verbose - enables verbose logging"
|
echo " -v --verbose - enables verbose logging"
|
||||||
if [ ! -z "$1" ]; then
|
if [ ! -z "$1" ]; then
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
usage_install () {
|
usage_install () {
|
||||||
echo "LSP Install"
|
echo "LSP Install"
|
||||||
echo "Installs a new language server. If language server is already installed, this overwrites that installation."
|
echo "Installs a new language server. If language server is already installed, this overwrites that installation."
|
||||||
echo -e "\nUsage: lsp install [options] <server> [<version>] \n"
|
echo -e "\nUsage: lsp install [options] <server> [<version>] \n"
|
||||||
echo "Arguments:"
|
echo "Arguments:"
|
||||||
echo " server - name of server to install ('status --all' can be used to get a list of all)"
|
echo " server - name of server to install ('status --all' can be used to get a list of all)"
|
||||||
echo " version - optional argument representing version of server (otherwise default is used)"
|
echo " version - optional argument representing version of server (otherwise default is used)"
|
||||||
echov " - version is hardcoded and could be outdated"
|
echov " - version is hardcoded and could be outdated"
|
||||||
echo ""
|
echo ""
|
||||||
echo "Options:"
|
echo "Options:"
|
||||||
echo " -l --link - automatically links installed binaries to $HOME/.local/bin"
|
echo " -l --link - automatically links installed binaries to $HOME/.local/bin"
|
||||||
echo " -h --help - prints this help message"
|
echo " -h --help - prints this help message"
|
||||||
echo " -v --verbose - enables verbose logging"
|
echo " -v --verbose - enables verbose logging"
|
||||||
echov "Examples:"
|
echov "Examples:"
|
||||||
echov " > lsp install jdtls"
|
echov " > lsp install jdtls"
|
||||||
echov ""
|
echov ""
|
||||||
echov " > lsp install jdtls 1.4.0"
|
echov " > lsp install jdtls 1.4.0"
|
||||||
}
|
}
|
||||||
|
|
||||||
usage_link () {
|
usage_link () {
|
||||||
echo "LSP Link"
|
echo "LSP Link"
|
||||||
echo "Links installed language server. This can be automatically done when installing by passing -l flag."
|
echo "Links installed language server. This can be automatically done when installing by passing -l flag."
|
||||||
echo -e "\nUsage: lsp link [options] <server> \n"
|
echo -e "\nUsage: lsp link [options] <server> \n"
|
||||||
echo "Arguments:"
|
echo "Arguments:"
|
||||||
echo " server - name of server to link ('status' can be used to get a list of installed servers)"
|
echo " server - name of server to link ('status' can be used to get a list of installed servers)"
|
||||||
echo ""
|
echo ""
|
||||||
echo "Options:"
|
echo "Options:"
|
||||||
echo " -h --help - prints this help message"
|
echo " -h --help - prints this help message"
|
||||||
echo " -v --verbose - enables verbose logging"
|
echo " -v --verbose - enables verbose logging"
|
||||||
echov "Examples:"
|
echov "Examples:"
|
||||||
echov " > lsp link jdtls"
|
echov " > lsp link jdtls"
|
||||||
}
|
}
|
||||||
|
|
||||||
usage_uninstall () {
|
usage_uninstall () {
|
||||||
echo "LSP Uninstall"
|
echo "LSP Uninstall"
|
||||||
echo "Uninstalls a language server. Silently fails if server is not present."
|
echo "Uninstalls a language server. Silently fails if server is not present."
|
||||||
echo -e "\nUsage: lsp uninstall [options] <server> \n"
|
echo -e "\nUsage: lsp uninstall [options] <server> \n"
|
||||||
echo "Arguments:"
|
echo "Arguments:"
|
||||||
echo " server - name of server to uninstall ('status' can be used to get a list of installed servers)"
|
echo " server - name of server to uninstall ('status' can be used to get a list of installed servers)"
|
||||||
echo ""
|
echo ""
|
||||||
echo "Options:"
|
echo "Options:"
|
||||||
echo " -h --help - prints this help message"
|
echo " -h --help - prints this help message"
|
||||||
echo " -v --verbose - enables verbose logging"
|
echo " -v --verbose - enables verbose logging"
|
||||||
echov "Examples:"
|
echov "Examples:"
|
||||||
echov " > lsp uninstall jdtls"
|
echov " > lsp uninstall jdtls"
|
||||||
}
|
}
|
||||||
|
|
||||||
usage_status () {
|
usage_status () {
|
||||||
echo "LSP Status"
|
echo "LSP Status"
|
||||||
echo "Prints status of installed servers"
|
echo "Prints status of installed servers"
|
||||||
echo -e "\nUsage: lsp status [options] [<server>] \n"
|
echo -e "\nUsage: lsp status [options] [<server>] \n"
|
||||||
echo "Arguments:"
|
echo "Arguments:"
|
||||||
echo " server - name of server or language to show status for"
|
echo " server - name of server or language to show status for"
|
||||||
echov " - if it does not exist, this tool tries to look for it in every language listed"
|
echov " - if it does not exist, this tool tries to look for it in every language listed"
|
||||||
echo ""
|
echo ""
|
||||||
echo "Options:"
|
echo "Options:"
|
||||||
echo " -k --known-only - shows only known servers"
|
echo " -k --known-only - shows only known servers"
|
||||||
echo " -a --all - shows servers which are not installed too"
|
echo " -a --all - shows servers which are not installed too"
|
||||||
echo " -h --help - prints this help message"
|
echo " -h --help - prints this help message"
|
||||||
echo " -v --verbose - enables verbose logging"
|
echo " -v --verbose - enables verbose logging"
|
||||||
echov ""
|
echov ""
|
||||||
echov "Examples:"
|
echov "Examples:"
|
||||||
echov " > lsp status java
"
|
echov " > lsp status java
"
|
||||||
echov " Language java:"
|
echov " Language java:"
|
||||||
echov " Server google-java-format (UNKNOWN):"
|
echov " Server google-java-format (UNKNOWN):"
|
||||||
echov " Installed: true"
|
echov " Installed: true"
|
||||||
echov " Version: UNKNOWN"
|
echov " Version: UNKNOWN"
|
||||||
echov " Location: /Users/ensar.sarajcic/lsp/java/google-java-format"
|
echov " Location: /Users/ensar.sarajcic/lsp/java/google-java-format"
|
||||||
echov " On path: false"
|
echov " On path: false"
|
||||||
echov ""
|
echov ""
|
||||||
echov " > lsp status java --all
"
|
echov " > lsp status java --all
"
|
||||||
echov " Language java:"
|
echov " Language java:"
|
||||||
echov " Server google-java-format (UNKNOWN):"
|
echov " Server google-java-format (UNKNOWN):"
|
||||||
echov " Installed: true"
|
echov " Installed: true"
|
||||||
echov " Version: UNKNOWN"
|
echov " Version: UNKNOWN"
|
||||||
echov " Location: /Users/ensar.sarajcic/lsp/java/google-java-format"
|
echov " Location: /Users/ensar.sarajcic/lsp/java/google-java-format"
|
||||||
echov " On path: false"
|
echov " On path: false"
|
||||||
echov ""
|
echov ""
|
||||||
echov " Server jdtls:"
|
echov " Server jdtls:"
|
||||||
echov " Installed: false"
|
echov " Installed: false"
|
||||||
}
|
}
|
||||||
|
@ -163,13 +163,13 @@ COMMAND="${POSITIONAL[0]}"
|
||||||
echov "Detected command: $COMMAND"
|
echov "Detected command: $COMMAND"
|
||||||
|
|
||||||
if [ $HELP -eq 1 ]; then
|
if [ $HELP -eq 1 ]; then
|
||||||
usage $COMMAND
|
usage $COMMAND
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
UNAME=$(sh -c 'uname 2>/dev/null || echo Unknown')
|
UNAME=$(sh -c 'uname 2>/dev/null || echo Unknown')
|
||||||
if [[ "$UNAME" == "Windows_NT" ]]; then
|
if [[ "$UNAME" == "Windows_NT" ]]; then
|
||||||
UNAME="Windows"
|
UNAME="Windows"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echov "Detected host: $UNAME"
|
echov "Detected host: $UNAME"
|
||||||
|
@ -181,381 +181,408 @@ echov "Detected server: $SERVER"
|
||||||
echov "Detected version: $VERSION"
|
echov "Detected version: $VERSION"
|
||||||
|
|
||||||
declare -A SUPPORTED_SERVERS=(
|
declare -A SUPPORTED_SERVERS=(
|
||||||
["java"]="jdtls"
|
["java"]="jdtls"
|
||||||
["dotnet"]="omnisharp"
|
["dotnet"]="omnisharp"
|
||||||
["haskell"]="hls"
|
["haskell"]="hls"
|
||||||
["solidity"]="solang"
|
["solidity"]="solang"
|
||||||
["xml"]="lemminx"
|
["xml"]="lemminx"
|
||||||
["kotlin"]="kotlin-language-server"
|
["kotlin"]="kotlin-language-server",
|
||||||
|
["rust"]="rust-analyzer"
|
||||||
)
|
)
|
||||||
declare -A LINK_SOURCES=(
|
declare -A LINK_SOURCES=(
|
||||||
["omnisharp"]="$HOME/lsp/dotnet/omnisharp/run"
|
["omnisharp"]="$HOME/lsp/dotnet/omnisharp/run"
|
||||||
["solang"]="$HOME/lsp/solidity/solang/solang"
|
["solang"]="$HOME/lsp/solidity/solang/solang"
|
||||||
["lemminx"]="$HOME/lsp/xml/lemminx/lemminx"
|
["lemminx"]="$HOME/lsp/xml/lemminx/lemminx"
|
||||||
["kotlin-language-server"]="$HOME/lsp/kotlin/kotlin-language-server/bin/kotlin-language-server"
|
["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=(
|
declare -A LINK_TARGETS=(
|
||||||
["omnisharp"]="$HOME/.local/bin/omnisharp"
|
["omnisharp"]="$HOME/.local/bin/omnisharp"
|
||||||
["solang"]="$HOME/.local/bin/solang"
|
["solang"]="$HOME/.local/bin/solang"
|
||||||
["lemminx"]="$HOME/.local/bin/lemminx"
|
["lemminx"]="$HOME/.local/bin/lemminx"
|
||||||
["kotlin-language-server"]="$HOME/.local/bin/kotlin-language-server"
|
["kotlin-language-server"]="$HOME/.local/bin/kotlin-language-server"
|
||||||
|
["rust-analyzer"]="$HOME/.local/bin/rust-analyzer"
|
||||||
)
|
)
|
||||||
|
|
||||||
is_linked () {
|
is_linked () {
|
||||||
SERVER=$1
|
SERVER=$1
|
||||||
SOURCE_TO_CHECK="${LINK_SOURCES[$SERVER]}"
|
SOURCE_TO_CHECK="${LINK_SOURCES[$SERVER]}"
|
||||||
TARGET_TO_CHECK="${LINK_TARGETS[$SERVER]}"
|
TARGET_TO_CHECK="${LINK_TARGETS[$SERVER]}"
|
||||||
if [ -z "$SOURCE_TO_CHECK" ]; then
|
if [ -z "$SOURCE_TO_CHECK" ]; then
|
||||||
case $SERVER in
|
case $SERVER in
|
||||||
jdtls)
|
jdtls)
|
||||||
echo 1
|
|
||||||
return 0
|
|
||||||
;;
|
|
||||||
hls)
|
|
||||||
echo 1
|
|
||||||
return 0
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
echo 0
|
|
||||||
return 0
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
else
|
|
||||||
if [ ! -f "$TARGET_TO_CHECK" ]; then
|
|
||||||
echo 0
|
|
||||||
return 0
|
|
||||||
fi
|
|
||||||
if [ ! -f "$SOURCE_TO_CHECK" ]; then
|
|
||||||
echo 0
|
|
||||||
return 0
|
|
||||||
fi
|
|
||||||
if [ "$SOURCE_TO_CHECK" != "$(readlink $TARGET_TO_CHECK)" ]; then
|
|
||||||
echo 0
|
|
||||||
return 0
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
echo 1
|
echo 1
|
||||||
|
return 0
|
||||||
|
;;
|
||||||
|
hls)
|
||||||
|
echo 1
|
||||||
|
return 0
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo 0
|
||||||
|
return 0
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
else
|
||||||
|
if [ ! -f "$TARGET_TO_CHECK" ]; then
|
||||||
|
echo 0
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
if [ ! -f "$SOURCE_TO_CHECK" ]; then
|
||||||
|
echo 0
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
if [ "$SOURCE_TO_CHECK" != "$(readlink $TARGET_TO_CHECK)" ]; then
|
||||||
|
echo 0
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
echo 1
|
||||||
}
|
}
|
||||||
|
|
||||||
link_server () {
|
link_server () {
|
||||||
SERVER=$1
|
SERVER=$1
|
||||||
SOURCE=""
|
SOURCE=""
|
||||||
TARGET=""
|
TARGET=""
|
||||||
SOURCE_TO_CHECK="${LINK_SOURCES[$SERVER]}"
|
SOURCE_TO_CHECK="${LINK_SOURCES[$SERVER]}"
|
||||||
SOURCE=$SOURCE_TO_CHECK
|
SOURCE=$SOURCE_TO_CHECK
|
||||||
TARGET="${LINK_TARGETS[$SERVER]}"
|
TARGET="${LINK_TARGETS[$SERVER]}"
|
||||||
if [ -z "$SOURCE" ]; then
|
if [ -z "$SOURCE" ]; then
|
||||||
case $SERVER in
|
case $SERVER in
|
||||||
jdtls)
|
jdtls)
|
||||||
echo "No need to link jdtls. Use 'jdtls-start.sh' instead!"
|
echo "No need to link jdtls. Use 'jdtls-start.sh' instead!"
|
||||||
exit 0
|
exit 0
|
||||||
;;
|
;;
|
||||||
hls)
|
hls)
|
||||||
SOURCE_TO_CHECK="$HOME/lsp/haskell/hls/haskell-language-server-wrapper"
|
SOURCE_TO_CHECK="$HOME/lsp/haskell/hls/haskell-language-server-wrapper"
|
||||||
SOURCE="$HOME/lsp/haskell/hls/*"
|
SOURCE="$HOME/lsp/haskell/hls/*"
|
||||||
TARGET="$HOME/.local/bin"
|
TARGET="$HOME/.local/bin"
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
echo "Unknown server: $SERVER"
|
echo "Unknown server: $SERVER"
|
||||||
echo "Run 'lsp status' for a list of installed servers"
|
echo "Run 'lsp status' for a list of installed servers"
|
||||||
exit 1
|
exit 1
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
fi
|
fi
|
||||||
IS_LINKED=$(is_linked $SERVER)
|
IS_LINKED=$(is_linked $SERVER)
|
||||||
if [ $IS_LINKED -eq 1 ]; then
|
if [ $IS_LINKED -eq 1 ]; then
|
||||||
echo "Server $SERVER is already linked. Nothing to do."
|
echo "Server $SERVER is already linked. Nothing to do."
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
if [ -z "$SOURCE_TO_CHECK" ]; then
|
if [ -z "$SOURCE_TO_CHECK" ]; then
|
||||||
SOURCE_TO_CHECK="$SOURCE"
|
SOURCE_TO_CHECK="$SOURCE"
|
||||||
fi
|
fi
|
||||||
if [ ! -f "$SOURCE_TO_CHECK" ]; then
|
if [ ! -f "$SOURCE_TO_CHECK" ]; then
|
||||||
echo "File not found!"
|
echo "File not found!"
|
||||||
echo "Make sure $SERVER is installed. Check status with 'lsp status'."
|
echo "Make sure $SERVER is installed. Check status with 'lsp status'."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
if [ -f "$TARGET" ]; then
|
if [ -f "$TARGET" ]; then
|
||||||
echo "File already exists at $TARGET"
|
echo "File already exists at $TARGET"
|
||||||
echo "Aborting..."
|
echo "Aborting..."
|
||||||
echo ""
|
echo ""
|
||||||
echo "File info:"
|
echo "File info:"
|
||||||
ls -lahF "$TARGET"
|
ls -lahF "$TARGET"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
ln -s "$SOURCE" "$TARGET"
|
ln -s "$SOURCE" "$TARGET"
|
||||||
echov "Successfully linked $SERVER from $SOURCE to $TARGET"
|
echov "Successfully linked $SERVER from $SOURCE to $TARGET"
|
||||||
}
|
}
|
||||||
|
|
||||||
install () {
|
install () {
|
||||||
SERVER=$1
|
SERVER=$1
|
||||||
VERSION=$2
|
VERSION=$2
|
||||||
case $SERVER in
|
case $SERVER in
|
||||||
jdtls)
|
jdtls)
|
||||||
if [ -z "$VERSION" ]; then
|
if [ -z "$VERSION" ]; then
|
||||||
VERSION="1.4.0"
|
VERSION="1.4.0"
|
||||||
fi
|
fi
|
||||||
FILE_NAME=$(curl https://download.eclipse.org/jdtls/milestones/$VERSION/latest.txt)
|
FILE_NAME=$(curl https://download.eclipse.org/jdtls/milestones/$VERSION/latest.txt)
|
||||||
wget -O - https://download.eclipse.org/jdtls/milestones/$VERSION/$FILE_NAME > /tmp/jdtls.tar.gz
|
wget -O - https://download.eclipse.org/jdtls/milestones/$VERSION/$FILE_NAME > /tmp/jdtls.tar.gz
|
||||||
mkdir -p $HOME/lsp/java/jdtls
|
mkdir -p $HOME/lsp/java/jdtls
|
||||||
tar -xf /tmp/jdtls.tar.gz -C $HOME/lsp/java/jdtls
|
tar -xf /tmp/jdtls.tar.gz -C $HOME/lsp/java/jdtls
|
||||||
;;
|
;;
|
||||||
omnisharp)
|
omnisharp)
|
||||||
if [ -z "$VERSION" ]; then
|
if [ -z "$VERSION" ]; then
|
||||||
VERSION="v1.37.16"
|
VERSION="v1.37.16"
|
||||||
fi
|
fi
|
||||||
case $UNAME in
|
case $UNAME in
|
||||||
Linux)
|
Linux)
|
||||||
FILE_NAME="omnisharp-linux-x64.tar.gz"
|
FILE_NAME="omnisharp-linux-x64.tar.gz"
|
||||||
;;
|
;;
|
||||||
Darwin)
|
Darwin)
|
||||||
FILE_NAME="omnisharp-osx.tar.gz"
|
FILE_NAME="omnisharp-osx.tar.gz"
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
wget -O - https://github.com/OmniSharp/omnisharp-roslyn/releases/download/$VERSION/$FILE_NAME > /tmp/omnisharp.tar.gz
|
wget -O - https://github.com/OmniSharp/omnisharp-roslyn/releases/download/$VERSION/$FILE_NAME > /tmp/omnisharp.tar.gz
|
||||||
mkdir -p $HOME/lsp/dotnet/omnisharp
|
mkdir -p $HOME/lsp/dotnet/omnisharp
|
||||||
tar -xf /tmp/omnisharp.tar.gz -C $HOME/lsp/dotnet/omnisharp
|
tar -xf /tmp/omnisharp.tar.gz -C $HOME/lsp/dotnet/omnisharp
|
||||||
;;
|
;;
|
||||||
hls)
|
hls)
|
||||||
if [ -z "$VERSION" ]; then
|
if [ -z "$VERSION" ]; then
|
||||||
VERSION="1.4.0"
|
VERSION="1.4.0"
|
||||||
fi
|
fi
|
||||||
case $UNAME in
|
case $UNAME in
|
||||||
Linux)
|
Linux)
|
||||||
FILE_NAME="haskell-language-server-Linux-${VERSION}.tar.gz"
|
FILE_NAME="haskell-language-server-Linux-${VERSION}.tar.gz"
|
||||||
;;
|
;;
|
||||||
Darwin)
|
Darwin)
|
||||||
FILE_NAME="haskell-language-server-macOS-${VERSION}.tar.gz"
|
FILE_NAME="haskell-language-server-macOS-${VERSION}.tar.gz"
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
wget -O - https://github.com/haskell/haskell-language-server/releases/download/$VERSION/$FILE_NAME > /tmp/hls.tar.gz
|
wget -O - https://github.com/haskell/haskell-language-server/releases/download/$VERSION/$FILE_NAME > /tmp/hls.tar.gz
|
||||||
mkdir -p $HOME/lsp/haskell/hls
|
mkdir -p $HOME/lsp/haskell/hls
|
||||||
tar -xf /tmp/hls.tar.gz -C $HOME/lsp/haskell/hls
|
tar -xf /tmp/hls.tar.gz -C $HOME/lsp/haskell/hls
|
||||||
chmod +x $HOME/lsp/haskell/hls/*
|
chmod +x $HOME/lsp/haskell/hls/*
|
||||||
;;
|
;;
|
||||||
solang)
|
solang)
|
||||||
if [ -z "$VERSION" ]; then
|
if [ -z "$VERSION" ]; then
|
||||||
VERSION="v0.1.8"
|
VERSION="v0.1.8"
|
||||||
fi
|
fi
|
||||||
case $UNAME in
|
case $UNAME in
|
||||||
Linux)
|
Linux)
|
||||||
FILE_NAME="solang-linux"
|
FILE_NAME="solang-linux"
|
||||||
;;
|
;;
|
||||||
Windows)
|
Windows)
|
||||||
FILE_NAME="solang.exe"
|
FILE_NAME="solang.exe"
|
||||||
;;
|
;;
|
||||||
Darwin)
|
Darwin)
|
||||||
FILE_NAME="solang-mac-intel"
|
FILE_NAME="solang-mac-intel"
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
mkdir -p $HOME/lsp/solidity/solang
|
mkdir -p $HOME/lsp/solidity/solang
|
||||||
wget -O - https://github.com/hyperledger-labs/solang/releases/download/$VERSION/$FILE_NAME > $HOME/lsp/solidity/solang/solang
|
wget -O - https://github.com/hyperledger-labs/solang/releases/download/$VERSION/$FILE_NAME > $HOME/lsp/solidity/solang/solang
|
||||||
chmod +x $HOME/lsp/solidity/solang/solang
|
chmod +x $HOME/lsp/solidity/solang/solang
|
||||||
;;
|
;;
|
||||||
lemminx)
|
lemminx)
|
||||||
if [ -z "$VERSION" ]; then
|
if [ -z "$VERSION" ]; then
|
||||||
VERSION="0.18.0-400"
|
VERSION="0.18.0-400"
|
||||||
fi
|
fi
|
||||||
case $UNAME in
|
case $UNAME in
|
||||||
Linux)
|
Linux)
|
||||||
FILE_NAME="lemminx-linux.zip"
|
FILE_NAME="lemminx-linux.zip"
|
||||||
;;
|
;;
|
||||||
Windows)
|
Windows)
|
||||||
FILE_NAME="lemminx-win32.zip"
|
FILE_NAME="lemminx-win32.zip"
|
||||||
;;
|
;;
|
||||||
Darwin)
|
Darwin)
|
||||||
FILE_NAME="lemminx-osx-x86_64.zip"
|
FILE_NAME="lemminx-osx-x86_64.zip"
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
mkdir -p $HOME/lsp/xml/lemminx
|
mkdir -p $HOME/lsp/xml/lemminx
|
||||||
|
|
||||||
wget -O - https://download.jboss.org/jbosstools/vscode/stable/lemminx-binary/$VERSION/$FILE_NAME > /tmp/lemminx-download.zip
|
wget -O - https://download.jboss.org/jbosstools/vscode/stable/lemminx-binary/$VERSION/$FILE_NAME > /tmp/lemminx-download.zip
|
||||||
unzip -p /tmp/lemminx-download.zip > $HOME/lsp/xml/lemminx/lemminx
|
unzip -p /tmp/lemminx-download.zip > $HOME/lsp/xml/lemminx/lemminx
|
||||||
chmod +x $HOME/lsp/xml/lemminx/lemminx
|
chmod +x $HOME/lsp/xml/lemminx/lemminx
|
||||||
;;
|
;;
|
||||||
kotlin-language-server)
|
kotlin-language-server)
|
||||||
if [ -z "$VERSION" ]; then
|
if [ -z "$VERSION" ]; then
|
||||||
VERSION="1.1.2"
|
VERSION="1.1.2"
|
||||||
fi
|
fi
|
||||||
FILE_NAME="server.zip"
|
FILE_NAME="server.zip"
|
||||||
wget -O - https://github.com/fwcd/kotlin-language-server/releases/download/$VERSION/$FILE_NAME > /tmp/kotlin-language-server.zip
|
wget -O - https://github.com/fwcd/kotlin-language-server/releases/download/$VERSION/$FILE_NAME > /tmp/kotlin-language-server.zip
|
||||||
mkdir -p $HOME/lsp/kotlin
|
mkdir -p $HOME/lsp/kotlin
|
||||||
unzip /tmp/kotlin-language-server.zip -d /tmp/kotlin-language-server
|
unzip /tmp/kotlin-language-server.zip -d /tmp/kotlin-language-server
|
||||||
mv /tmp/kotlin-language-server/server $HOME/lsp/kotlin/kotlin-language-server
|
mv /tmp/kotlin-language-server/server $HOME/lsp/kotlin/kotlin-language-server
|
||||||
;;
|
;;
|
||||||
*)
|
rust-analyzer)
|
||||||
echo "Unknown server: $SERVER"
|
if [ -z "$VERSION" ]; then
|
||||||
echo "Run 'lsp status --all' for a list of available servers"
|
VERSION="2021-11-15"
|
||||||
exit 1
|
fi
|
||||||
;;
|
BASE_FILE_NAME="rust-analyzer-x86_64"
|
||||||
esac
|
case $UNAME in
|
||||||
echo "$SERVER $VERSION" >> "$MY_CONFIG_CACHE_DIR/lspstatus"
|
Linux)
|
||||||
echo "" >> "$MY_CONFIG_CACHE_DIR/lspstatus"
|
FILE_NAME="${BASE_FILE_NAME}-unknown-linux-gnu.gz"
|
||||||
tac "$MY_CONFIG_CACHE_DIR/lspstatus" | awk 'BEGIN { FS = " " } ; {print $2 " " $1}' | uniq -f 1 > /tmp/newlspstatus
|
;;
|
||||||
cat /tmp/newlspstatus | awk 'BEGIN { FS = " " } ; {print $2 " " $1}' > "$MY_CONFIG_CACHE_DIR/lspstatus"
|
Windows)
|
||||||
rm /tmp/newlspstatus
|
FILE_NAME="${BASE_FILE_NAME}-pc-windows-msvc.gz"
|
||||||
echov "Successfully installed $SERVER, version $VERSION"
|
;;
|
||||||
if [ $LINK -eq 1 ]; then
|
Darwin)
|
||||||
link_server $SERVER
|
FILE_NAME="${BASE_FILE_NAME}-apple-darwin.gz"
|
||||||
fi
|
;;
|
||||||
|
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"
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
echo "$SERVER $VERSION" >> "$MY_CONFIG_CACHE_DIR/lspstatus"
|
||||||
|
echo "" >> "$MY_CONFIG_CACHE_DIR/lspstatus"
|
||||||
|
tac "$MY_CONFIG_CACHE_DIR/lspstatus" | awk 'BEGIN { FS = " " } ; {print $2 " " $1}' | uniq -f 1 > /tmp/newlspstatus
|
||||||
|
cat /tmp/newlspstatus | awk 'BEGIN { FS = " " } ; {print $2 " " $1}' > "$MY_CONFIG_CACHE_DIR/lspstatus"
|
||||||
|
rm /tmp/newlspstatus
|
||||||
|
echov "Successfully installed $SERVER, version $VERSION"
|
||||||
|
if [ $LINK -eq 1 ]; then
|
||||||
|
link_server $SERVER
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
uninstall () {
|
uninstall () {
|
||||||
SERVER=$1
|
SERVER=$1
|
||||||
case $SERVER in
|
case $SERVER in
|
||||||
jdtls)
|
jdtls)
|
||||||
rm -rf $HOME/lsp/java/jdtls
|
rm -rf $HOME/lsp/java/jdtls
|
||||||
;;
|
;;
|
||||||
omnisharp)
|
omnisharp)
|
||||||
rm -rf $HOME/lsp/dotnet/omnisharp
|
rm -rf $HOME/lsp/dotnet/omnisharp
|
||||||
;;
|
;;
|
||||||
hls)
|
hls)
|
||||||
rm -rf $HOME/lsp/haskell/hls
|
rm -rf $HOME/lsp/haskell/hls
|
||||||
;;
|
;;
|
||||||
solang)
|
solang)
|
||||||
rm -rf $HOME/lsp/solidity/solang
|
rm -rf $HOME/lsp/solidity/solang
|
||||||
;;
|
;;
|
||||||
lemminx)
|
lemminx)
|
||||||
rm -rf $HOME/lsp/xml/lemminx
|
rm -rf $HOME/lsp/xml/lemminx
|
||||||
;;
|
;;
|
||||||
kotlin-language-server)
|
kotlin-language-server)
|
||||||
rm -rf $HOME/lsp/kotlin/kotlin-language-server
|
rm -rf $HOME/lsp/kotlin/kotlin-language-server
|
||||||
;;
|
;;
|
||||||
*)
|
rust-analyzer)
|
||||||
echo "Unknown server: $SERVER"
|
rm -rf $HOME/lsp/rust/rust-analyzer
|
||||||
echo "Run 'lsp status' for a list of installed servers"
|
;;
|
||||||
exit 1
|
*)
|
||||||
;;
|
echo "Unknown server: $SERVER"
|
||||||
esac
|
echo "Run 'lsp status' for a list of installed servers"
|
||||||
sed -i -e "/$SERVER/d" "$MY_CONFIG_CACHE_DIR/lspstatus"
|
exit 1
|
||||||
echov "Successfully removed $SERVER"
|
;;
|
||||||
|
esac
|
||||||
|
sed -i -e "/$SERVER/d" "$MY_CONFIG_CACHE_DIR/lspstatus"
|
||||||
|
echov "Successfully removed $SERVER"
|
||||||
}
|
}
|
||||||
|
|
||||||
status () {
|
status () {
|
||||||
SERVER=$1
|
SERVER=$1
|
||||||
HAD_UNKNOWN=0
|
HAD_UNKNOWN=0
|
||||||
TREAT_SERVER_AS_LANGUAGE=0
|
TREAT_SERVER_AS_LANGUAGE=0
|
||||||
BOLDSTART="\033[1m"
|
BOLDSTART="\033[1m"
|
||||||
ERRORSTART="\033[91m"
|
ERRORSTART="\033[91m"
|
||||||
INFOSTART="\033[34m"
|
INFOSTART="\033[34m"
|
||||||
MODEND="\033[0m"
|
MODEND="\033[0m"
|
||||||
LANGUAGES=$(ls $HOME/lsp)
|
LANGUAGES=$(ls $HOME/lsp)
|
||||||
echov "Found languages: $LANGUAGES"
|
echov "Found languages: $LANGUAGES"
|
||||||
if [ $ALL -eq 1 ]; then
|
if [ $ALL -eq 1 ]; then
|
||||||
echov "Adding all supported languages"
|
echov "Adding all supported languages"
|
||||||
LANGUAGES+=" ${!SUPPORTED_SERVERS[@]}"
|
LANGUAGES+=" ${!SUPPORTED_SERVERS[@]}"
|
||||||
LANGUAGES=$(echo $LANGUAGES | tr ' ' '\n' | sort | uniq -)
|
LANGUAGES=$(echo $LANGUAGES | tr ' ' '\n' | sort | uniq -)
|
||||||
|
fi
|
||||||
|
echov "Checking languages: $LANGUAGES"
|
||||||
|
if [ ! -z "$SERVER" ]; then
|
||||||
|
EXPECTED_SERVERS="${SUPPORTED_SERVERS[$SERVER]}"
|
||||||
|
if [ ! -z "$EXPECTED_SERVERS" ]; then
|
||||||
|
echov "Passed server name: $SERVER was recognized as a language"
|
||||||
|
TREAT_SERVER_AS_LANGUAGE=1
|
||||||
|
LANGUAGES="$SERVER"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
echov ""
|
||||||
|
for lang in $LANGUAGES; do
|
||||||
|
if [ -d "$HOME/lsp/$lang" ]; then
|
||||||
|
INSTALLED_SERVERS=$(ls $HOME/lsp/$lang)
|
||||||
|
else
|
||||||
|
INSTALLED_SERVERS=""
|
||||||
|
fi
|
||||||
|
SERVERS="$INSTALLED_SERVERS"
|
||||||
|
EXPECTED_SERVERS="${SUPPORTED_SERVERS[$lang]}"
|
||||||
|
if [ $ALL -eq 1 ]; then
|
||||||
|
SERVERS+=" $EXPECTED_SERVERS"
|
||||||
|
SERVERS=$(echo $SERVERS | tr ' ' '\n' | sort | uniq -)
|
||||||
|
fi
|
||||||
|
if [ -z "$EXPECTED_SERVERS" ]; then
|
||||||
|
HAD_UNKNOWN=1
|
||||||
|
if [ $KNOWN_ONLY -eq 1 ]; then
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
echo -e "Language $BOLDSTART${lang}$MODEND $ERRORSTART(UNKNOWN)$MODEND:"
|
||||||
|
else
|
||||||
|
echo -e "Language $BOLDSTART${lang}$MODEND:"
|
||||||
|
fi
|
||||||
|
if [ ! -z "$SERVER" ]; then
|
||||||
|
if [ $TREAT_SERVER_AS_LANGUAGE -eq 0 ]; then
|
||||||
|
if [ ! -z "$INSTALLED_SERVERS" ]; then
|
||||||
|
SERVERS="$SERVER"
|
||||||
fi
|
fi
|
||||||
echov "Checking languages: $LANGUAGES"
|
fi
|
||||||
if [ ! -z "$SERVER" ]; then
|
fi
|
||||||
EXPECTED_SERVERS="${SUPPORTED_SERVERS[$SERVER]}"
|
for server in $SERVERS; do
|
||||||
if [ ! -z "$EXPECTED_SERVERS" ]; then
|
VERSION="UNKNOWN"
|
||||||
echov "Passed server name: $SERVER was recognized as a language"
|
for available_server in "${EXPECTED_SERVERS[@]}"; do
|
||||||
TREAT_SERVER_AS_LANGUAGE=1
|
if [ "$server" == "$available_server" ]; then
|
||||||
LANGUAGES="$SERVER"
|
VERSION=$(get_version $server)
|
||||||
fi
|
break
|
||||||
fi
|
fi
|
||||||
echov ""
|
done
|
||||||
for lang in $LANGUAGES; do
|
if [ "$VERSION" == "UNKNOWN" ]; then
|
||||||
if [ -d "$HOME/lsp/$lang" ]; then
|
if [ $KNOWN_ONLY -eq 1 ]; then
|
||||||
INSTALLED_SERVERS=$(ls $HOME/lsp/$lang)
|
continue
|
||||||
else
|
|
||||||
INSTALLED_SERVERS=""
|
|
||||||
fi
|
|
||||||
SERVERS="$INSTALLED_SERVERS"
|
|
||||||
EXPECTED_SERVERS="${SUPPORTED_SERVERS[$lang]}"
|
|
||||||
if [ $ALL -eq 1 ]; then
|
|
||||||
SERVERS+=" $EXPECTED_SERVERS"
|
|
||||||
SERVERS=$(echo $SERVERS | tr ' ' '\n' | sort | uniq -)
|
|
||||||
fi
|
|
||||||
if [ -z "$EXPECTED_SERVERS" ]; then
|
|
||||||
HAD_UNKNOWN=1
|
|
||||||
if [ $KNOWN_ONLY -eq 1 ]; then
|
|
||||||
continue
|
|
||||||
fi
|
|
||||||
echo -e "Language $BOLDSTART${lang}$MODEND $ERRORSTART(UNKNOWN)$MODEND:"
|
|
||||||
else
|
|
||||||
echo -e "Language $BOLDSTART${lang}$MODEND:"
|
|
||||||
fi
|
|
||||||
if [ ! -z "$SERVER" ]; then
|
|
||||||
if [ $TREAT_SERVER_AS_LANGUAGE -eq 0 ]; then
|
|
||||||
if [ ! -z "$INSTALLED_SERVERS" ]; then
|
|
||||||
SERVERS="$SERVER"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
for server in $SERVERS; do
|
|
||||||
VERSION="UNKNOWN"
|
|
||||||
for available_server in "${EXPECTED_SERVERS[@]}"; do
|
|
||||||
if [ "$server" == "$available_server" ]; then
|
|
||||||
VERSION=$(get_version $server)
|
|
||||||
break
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
if [ "$VERSION" == "UNKNOWN" ]; then
|
|
||||||
if [ $KNOWN_ONLY -eq 1 ]; then
|
|
||||||
continue
|
|
||||||
fi
|
|
||||||
echo -e " Server $BOLDSTART${server}$MODEND $ERRORSTART(UNKNOWN)$MODEND:"
|
|
||||||
HAD_UNKNOWN=1
|
|
||||||
else
|
|
||||||
echo -e " Server $BOLDSTART${server}$MODEND:"
|
|
||||||
fi
|
|
||||||
INSTALLED=0
|
|
||||||
for installed_server in ${INSTALLED_SERVERS}; do
|
|
||||||
if [ "$server" == "$installed_server" ]; then
|
|
||||||
INSTALLED=1
|
|
||||||
if [ -z "$VERSION" ]; then
|
|
||||||
VERSION="UNKNOWN"
|
|
||||||
fi
|
|
||||||
echo -e " Installed: ${INFOSTART}true${MODEND}"
|
|
||||||
echo " Version: $VERSION"
|
|
||||||
echo " Location: $HOME/lsp/$lang/$server"
|
|
||||||
LINKED=$(is_linked $server)
|
|
||||||
if [[ ":$PATH:" == *":$HOME/lsp/$lang/$server:"* ]]; then
|
|
||||||
echo -e " On path: ${INFOSTART}true${MODEND}"
|
|
||||||
elif [ $LINKED -eq 1 ]; then
|
|
||||||
echo -e " On path: ${INFOSTART}${BOLDSTART}linked${MODEND}${MODEND}"
|
|
||||||
echo " Linked to: ${LINK_TARGETS[$server]}"
|
|
||||||
else
|
|
||||||
echo " On path: false"
|
|
||||||
fi
|
|
||||||
break
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
if [ $INSTALLED -eq 0 ]; then
|
|
||||||
echo -e " Installed: ${ERRORSTART}false${MODEND}"
|
|
||||||
fi
|
|
||||||
echo ""
|
|
||||||
done
|
|
||||||
echo ""
|
|
||||||
done
|
|
||||||
if [ $HAD_UNKNOWN -eq 1 ]; then
|
|
||||||
if [ $KNOWN_ONLY -eq 0 ]; then
|
|
||||||
echov "Found unknown servers."
|
|
||||||
echov "Make sure $HOME/lsp contains only LSP servers and similar tools."
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
|
echo -e " Server $BOLDSTART${server}$MODEND $ERRORSTART(UNKNOWN)$MODEND:"
|
||||||
|
HAD_UNKNOWN=1
|
||||||
|
else
|
||||||
|
echo -e " Server $BOLDSTART${server}$MODEND:"
|
||||||
|
fi
|
||||||
|
INSTALLED=0
|
||||||
|
for installed_server in ${INSTALLED_SERVERS}; do
|
||||||
|
if [ "$server" == "$installed_server" ]; then
|
||||||
|
INSTALLED=1
|
||||||
|
if [ -z "$VERSION" ]; then
|
||||||
|
VERSION="UNKNOWN"
|
||||||
|
fi
|
||||||
|
echo -e " Installed: ${INFOSTART}true${MODEND}"
|
||||||
|
echo " Version: $VERSION"
|
||||||
|
echo " Location: $HOME/lsp/$lang/$server"
|
||||||
|
LINKED=$(is_linked $server)
|
||||||
|
if [[ ":$PATH:" == *":$HOME/lsp/$lang/$server:"* ]]; then
|
||||||
|
echo -e " On path: ${INFOSTART}true${MODEND}"
|
||||||
|
elif [ $LINKED -eq 1 ]; then
|
||||||
|
echo -e " On path: ${INFOSTART}${BOLDSTART}linked${MODEND}${MODEND}"
|
||||||
|
echo " Linked to: ${LINK_TARGETS[$server]}"
|
||||||
|
else
|
||||||
|
echo " On path: false"
|
||||||
|
fi
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
if [ $INSTALLED -eq 0 ]; then
|
||||||
|
echo -e " Installed: ${ERRORSTART}false${MODEND}"
|
||||||
|
fi
|
||||||
|
echo ""
|
||||||
|
done
|
||||||
|
echo ""
|
||||||
|
done
|
||||||
|
if [ $HAD_UNKNOWN -eq 1 ]; then
|
||||||
|
if [ $KNOWN_ONLY -eq 0 ]; then
|
||||||
|
echov "Found unknown servers."
|
||||||
|
echov "Make sure $HOME/lsp contains only LSP servers and similar tools."
|
||||||
|
fi
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
get_version () {
|
get_version () {
|
||||||
SERVER=$1
|
SERVER=$1
|
||||||
cat "$MY_CONFIG_CACHE_DIR/lspstatus" | grep "$SERVER" | cut -f 2 -d ' '
|
cat "$MY_CONFIG_CACHE_DIR/lspstatus" | grep "$SERVER" | cut -f 2 -d ' '
|
||||||
}
|
}
|
||||||
|
|
||||||
case $COMMAND in
|
case $COMMAND in
|
||||||
install)
|
install)
|
||||||
install $SERVER $VERSION
|
install $SERVER $VERSION
|
||||||
;;
|
;;
|
||||||
status)
|
status)
|
||||||
status $SERVER
|
status $SERVER
|
||||||
;;
|
;;
|
||||||
uninstall)
|
uninstall)
|
||||||
uninstall $SERVER
|
uninstall $SERVER
|
||||||
;;
|
;;
|
||||||
link)
|
link)
|
||||||
link_server $SERVER
|
link_server $SERVER
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
usage $COMMAND; exit 1 ;;
|
usage $COMMAND; exit 1 ;;
|
||||||
esac
|
esac
|
||||||
|
|
Loading…
Reference in New Issue