mfussenegger / nvim-jdtls

Extensions for the built-in LSP support in Neovim for eclipse.jdt.ls
GNU General Public License v3.0
1k stars 62 forks source link

Unexpected `root directory` when using `require('jdtls.setup').find_root` #516

Closed GiuseppeMP closed 1 year ago

GiuseppeMP commented 1 year ago

LSP client configuration

local root_markers = { 'gradlew', 'mvnw', '.git', 'settings.gradle', 'pom.xml', '.lsp_root' }
local root_dir = function() require('jdtls.setup').find_root(root_markers) end

...
local config = {
...

root_dir = root_dir()
...

}

The complete config file: https://github.com/GiuseppeMP/my-nvim-config/blob/main/lua/user/plugins/configs/lsp/jdtls.lua

Eclipse.jdt.ls version

v1.24.0

Steps to Reproduce

  1. Create a simple project with a pom.xml in the source root, for example ~/projects/repro.
  2. Create a simple .java and attach de jdtls.
  3. Look the :LspInfo

Expected Result

The output of LspInfo, at jdtls client should be:

root directory: ~/projects/repro

Actual Result

What actually happens:

root directory: /Users/<user>

If I execute git init only to create a .git directory, the bug stops. Maybe I misunderstood the root_markers.

mfussenegger commented 1 year ago

:lua =require('jdtls.setup').find_root({"pom.xml"}) shows the correct folder for me.

GiuseppeMP commented 1 year ago

@mfussenegger I found the bug, were in my configs. 😄 I created a reproduce files to find it, may it be useful for other ppl that are investigating problems with their configs.

https://github.com/GiuseppeMP/nvim_jdtls_repro