I am having some issues getting the groovy-language-server to work correctly in neovim.
When I open a .groovy
file into a new buffer, I can see a message indicating that the LSP client failed to start: Client 1 quit with exit code 1 and signal 0
Ok cool, so I go to check the logs using :LspLog
and I can see this error: Error: Unable to access jarfile groovy-language-server-all.jar
. (Also, if anyone has any tips on how to clear out LSP logs or only get the tail of the log file, that would be handy, my system gets very laggy opening these logs as it is at least 300,000 lines long).
The error message is:
[ERROR][2024-02-23 18:24:57] .../vim/lsp/rpc.lua:734 "rpc" "/Users/wmoorby/.sdkman/candidates/java/current/bin/java" "stderr" "Error: Unable to access jarfile groovy-language-server-all.jar\n"
I thought I might be getting this error because I am managing my java version with SDKMan, so I played around and installed a few different versions of java from different vendors, but always got the same result. I don't believe it's because of this.
Next I went to find where Mason stores all it's installed packages. I noticed that you can set the directory for this in the Mason configuration with install_root_dir = path.concat { vim.fn.stdpath "data", "mason" }
and so to find this location, I executed :!echo $PATH
inside neovim. I found the location in the PATH was /Users/wmoorby/.local/share/nvim/mason/bin
. I navigated to this directory and poked around a bit to find the groovy LSP package. With the help of the README on the groovy-language-server Github page, I found that the .jar
artefacts are located in groovy-language-server/build/libs
and I attempted to run the artefact that is stated in the :LspLog
with java -jar groovy-language-server-all.jar
and I think it works? I execute the command, I don't get any errors and then, my terminal just stays put, which I think means that the server is running within this terminal process and it is waiting for a client to attach itself.
But then, I still don't know why it is unable to be executed within neovim. I checked the permissions on the file and noticed it wasn't executable, but it's java that executes, not the artefact itself. I also checked the shell script wrapper that is used to run java -jar groovy-language-server-all.jar
and that works too (I think this shell script is what is run when the LSP is started inside neovim)
reference to server_configurations.md
so you need to setup lspconfig like:
require'lspconfig'.groovyls.setup{
cmd = { "groovy-language-server" },
...
}