nvim(lsp): migrate to jdtls installer

main
Ensar Sarajčić 2022-05-24 19:29:50 +02:00
parent 5958f09dad
commit 0e4c9bc45f
2 changed files with 16 additions and 31 deletions

View File

@ -49,9 +49,9 @@ usage_install () {
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 zls"
echov "" echov ""
echov " > lsp install jdtls 1.4.0" echov " > lsp install zls 1.4.0"
} }
usage_link () { usage_link () {
@ -65,7 +65,7 @@ usage_link () {
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 zls"
} }
usage_uninstall () { usage_uninstall () {
@ -79,7 +79,7 @@ usage_uninstall () {
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 zls"
} }
usage_status () { usage_status () {
@ -97,25 +97,14 @@ usage_status () {
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 zig
" "
echov " Language java:" echov " Language zig:"
echov " Server google-java-format (UNKNOWN):"
echov " Installed: true"
echov " Version: UNKNOWN"
echov " Location: /Users/ensar.sarajcic/lsp/java/google-java-format"
echov " On path: false"
echov "" echov ""
echov " > lsp status java --all echov " > lsp status zig --all
" "
echov " Language java:" echov " Language zig:"
echov " Server google-java-format (UNKNOWN):" echov " Server zls:"
echov " Installed: true"
echov " Version: UNKNOWN"
echov " Location: /Users/ensar.sarajcic/lsp/java/google-java-format"
echov " On path: false"
echov ""
echov " Server jdtls:"
echov " Installed: false" echov " Installed: false"
} }
@ -253,7 +242,7 @@ link_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."
exit 0 exit 0
;; ;;
hls) hls)
@ -298,13 +287,10 @@ install () {
VERSION=$2 VERSION=$2
case $SERVER in case $SERVER in
jdtls) jdtls)
if [ -z "$VERSION" ]; then echo "jdtls is no longer supported by this!"
VERSION="1.4.0" echo "Use the following: "
fi echo ""
FILE_NAME=$(curl https://download.eclipse.org/jdtls/milestones/$VERSION/latest.txt) echo "curl https://raw.githubusercontent.com/eruizc-dev/jdtls-launcher/master/install.sh | bash"
wget -O - https://download.eclipse.org/jdtls/milestones/$VERSION/$FILE_NAME > /tmp/jdtls.tar.gz
mkdir -p $LSP_HOME/java/jdtls
tar -xf /tmp/jdtls.tar.gz -C $LSP_HOME/java/jdtls
;; ;;
omnisharp) omnisharp)
if [ -z "$VERSION" ]; then if [ -z "$VERSION" ]; then

View File

@ -21,9 +21,7 @@ function M.setup()
local root_markers = { "gradlew", "pom.xml" } local root_markers = { "gradlew", "pom.xml" }
local root_dir = require("jdtls.setup").find_root(root_markers) local root_dir = require("jdtls.setup").find_root(root_markers)
local home = os.getenv("HOME")
local workspace_folder = home .. "/.workspace" .. vim.fn.fnamemodify(root_dir, ":p:h:t")
local config = { local config = {
flags = { flags = {
allow_incremental_sync = true, allow_incremental_sync = true,
@ -41,7 +39,8 @@ function M.setup()
}, },
}, },
} }
config.cmd = { "jdtls-start.sh", workspace_folder } config.cmd = { "jdtls" }
config.root_dir = root_dir
config.on_init = function(client, _) config.on_init = function(client, _)
client.notify("workspace/didChangeConfiguration", { settings = config.settings }) client.notify("workspace/didChangeConfiguration", { settings = config.settings })
end end