Closed TheBlob42 closed 2 years ago
Hello! Ah I see. I've pushed a little something to jdtls-workspace-dir
(#504), does it work as you'd expect?
Thank you for the fast response. I tested it with the minimal_debug config and that works fine now :+1:
For my personal config I use nvim-jdtls and therefore puzzle the server config together myself before handing it to the plugin. In there I use jdtls_server:get_default_options().cmd
to use the jdtls installed by your plugin. Unfortunately for me the "default cmd" still points to the cwd, so that the problem persists. I realize that I have not add this information in the issue description (but at least it is fixed for the "default case" now)
Do you have any idea if this case could also be solved? Otherwise I need to stick with my hack.
Nevermind I figured out an easy solution (shortened to just present the basics):
local root_dir = require('jdtls.setup').find_root({ 'gradlew', '.git', 'pom.xml', 'mvnw' })
local config = { ... }
local server_available, jdtls = require('nvim-lsp-installer.servers').get_server('jdtls')
-- this will fill in the correct 'cmd' to use
jdtls:get_default_options().on_new_config(config, root_dir)
require('jdtls').start_or_attach(config)
So your change is indeed solving this as well :slightly_smiling_face:
(since the on_new_config
function did not accept the workspace_path parameter before)
Ah, cool! A bit hacky but if it works it works :D. Feel free to add your solution to the Wiki!
Problem description
In the
init.lua
file for the jdtls server the workspace folder is created by default using a "base workspace path" plus the last part of the current cwd (see here). I am wondering why we don't use the also availableroot_dir
of the current Java project which is given to the function (see here) instead? This way we would get the actual project name instead of the last part of the cwd.I am usually starting Neovim in my home directory and then do all navigation inside of it. Therefore my cwd is always
/home/user/
. As a consequence whenever I open a Java project the corresponding workspace folder points to the same folder:/home/user/workspace/user
even when I have multiple Java projects open. This obviously causes problems like for example that my project dependencies can not be found etc.I have build a "hack" in my config to change the cmd from
nvim-lsp-installer
to better point to an individual workspace folder per project (using the root_dir), but I though maybe this should be changed within the plugin. But maybe this was done on purpose and there are use cases in which my approach would cause other problems :thinking:Neovim version (>= 0.6)
NVIM v0.6.1 Build type: RelWithDebInfo LuaJIT 2.1.0-beta3
Operating system/version
Linux DTC69Y2 5.13.0-30-generic #33~20.04.1-Ubuntu SMP Mon Feb 7 14:25:10 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
I've recently downloaded the latest plugin version of both nvim-lsp-installer and nvim-lspconfig
Affected language servers
jdtls
Steps to reproduce
nvim -u ~/Downloads/minimal_debug_init.lua
jdtls
using:LspInstall jdtls
:e <path-to-file>/MainClass.java
-data
directory:LspInfo
cmd
and there the-data
pathActual behavior
-data
argument is/home/<user>/workspace/<user>
Expected behavior
-data
argument should be/home/<user>/workspace/<project-name>
LspInfo
Healthcheck
Screenshots or recordings
No response