Maven multimodule project woes, and fixes.#411
-
BetaWas this translation helpful?Give feedback.
All reactions
Replies: 2 comments 23 replies
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
-
Looks like#399. Look at the comments where I go through the process with the reporter. You can also see the starter-kickstart repo for relevant example. And you can share your config to see if I can spot anything. |
BetaWas this translation helpful?Give feedback.
All reactions
-
I have only ever been running nvim from the project root - i.e. the parent project directory - in general I would never open a child module of a multimodule project in isolation of it's parent and siblings. I assume that nvim-java interracts with jdtls, and provides it with the project root directory using the root_markers - I think the way it finds and determines the project root directory is flawed - proof of which is that my achange above resolved the issue. I don't think it relates to jdtls itself because I am using jdtls in sublime text (LSP-jdtls) and this is not, and never has been, an issue. |
BetaWas this translation helpful?Give feedback.
All reactions
👍 1
-
If you clone the repo, have in mind there's another - nvim-java-core, where the LSP stuff happens. |
BetaWas this translation helpful?Give feedback.
All reactions
-
Thanks for the headsup. So it seems there are two values documented withinlsp.lua (within the core neovim project) that relate to the root directory of a project: root_markers is used to figure out the root of the project, and root_dir is the explicit root of the project. If root_dir is provided, the root_markers is ignored. root_dir can be either a string or a function - a function would be useful because the evaluation of where the root directory is could be deferred till after the lsp client has been created. I tried adding root_dir to the java setup config - instead of configuring root_markers - but it didn't seem to work. If you assume that the directory neovim is opened from is the project root then finding the project root should be trivial by passing neovim's PWD to the language server using the root_dir property. |
BetaWas this translation helpful?Give feedback.
All reactions
-
Maybe integration with project.nvim or similar could be beneficial. |
BetaWas this translation helpful?Give feedback.
All reactions
-
You've raised an interesting topic thank you! I almost certainly will join the effort when I get back home. |
BetaWas this translation helpful?Give feedback.
All reactions
👍 1
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
-
Thanks for your time and response. Some thoughts: with respect to other editors I use such as Sublime Text, VSCode, Zed - I usually open the editor in the root directory as follows: So I would navigate to the project root, and then open the editor in the project root (signified by the '.' representing the current directory). This will tell the editor that the project root is the PWD, and hence any language servers will operate correctly if the editor is opened at the project root. With respect to neovim, and language servers running within it, it takes a different approach - when a file is opened, rather than starting the language server based on the PWD, it starts from the file and works it's way up looking for a root marker, and when it find one it starts the language server from that point. This obviously breaks down in the case of a maven multimodule project. Rather than this being a maven issue I think it illustrates a shortcomming with the root markers approach. I think if neovim supported the approaches to opening files and directories similar to the other editors it would make the language server implementation so much easier to support - for example: Not only would this make the use of neovim more consistent with other editors, it would greatly simplify the support for language servers - you would no longer have to search the tree to determine the project root - it would be the PWD. When you explicitly open a directory with neovim by either cd-ing to the directory and invoking neovim - When you open a file using neovim by passing the path of the file to neovim - When you open neovim without specifying either a file or a directory then either the project root is set to the user's home directory, or there is no project root set. In my opinion the root markers approach is problematic - some projects at an early stage are not yet under revision control, and other projects - such as maven projects - contain artefacts that break the approach. It makes sense in some cases, but it breaks down in others. I think it could be used as an option to estimate a project root, but it should not be relied upon. Specifying a root directory rather than root markers would be preferable, and would make the process of starting a language server much more stable. For my part I would love to see this feature implemented in neovim - it would be one of the last pieces in the puzzle with respect to transferring my workflow from subl, code, or zed to nvim. I appreciate this might not be the place to discuss this - I may post something on reddit to see what others think about it. I am not sure what the neovim community is like as I am pretty new to it - hopefully they will be kind. Thanks again for your time. |
BetaWas this translation helpful?Give feedback.
All reactions
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
-
Project.nvim allows for switching projects on the fly. Although I don't think nvim-java supports changing the project on the fly. At least not jdtls-wise. Which might be implemented as well. I can look in that direction too. It also maintains a list of recently opened projects. I've been using project.nvim since I started using Neovim and it does some stuff silently under the hood but I don't remember anymore what it was, because it requires nothing from your side. Here's an extension for fzf-lua:https://github.com/jakobwesthoff/project-fzf.nvim/
No idea but I think
As I said it does a bit more and not all projects contain .git.
I'm not sure either, but if it's true lsp detection, then jdtls must be perfectly capable doing that for itself. |
BetaWas this translation helpful?Give feedback.
All reactions
-
I'm actually using this fork:https://github.com/ansidev/project.nvim. Its commit log contains something about workspace_folders which I don't understand. |
BetaWas this translation helpful?Give feedback.
All reactions
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
-
I will definitely have to look into this. If I understand correctly, it allows you to change from project to project - selected from a list of previously opened projects maintained by the plugin. If that is the case, then I assume the language server will have to be re-created when the project is (re) opened and killed when the project is closed or changed? And thanks for the links - I am quite new to nvim so any recommendations are appreciated greatly.
That might be the way to go. Definitely worth checking out.
I said the same earlier in this discussion. I still think the best approach is to determine the project root based upon the directory that nvim is opened in - which should be returned by the two functions I referenced above. This makes the most sense IMHO - and is consitent with all other editors I use (such as subl, zed, code, etc.) - but that's perhaps a different discussion. |
BetaWas this translation helpful?Give feedback.
All reactions
-
Same thoughts on my side.
I too. Only e few months.
I think the same way. I was just considering what other editors I've used do.
I haven't used other Java IDE's. The common denominator of all of the above is they are graphic stand-alone applications which set everything for themselves and the difference with Neovim is you use it in the terminal where some things are already set for the editor. But it also depends on patterns of usage. |
BetaWas this translation helpful?Give feedback.
All reactions
-
BetaWas this translation helpful?Give feedback.

