I'm working up a Neovim-based IDE for Java anchored around a SpaceVim installation. It's taken quite a journey to get everything configured appropriately but I'm almost there. The JDTLS language server is configured and working. When I open a java file, I get all the expected goodies including live autocomplete and syntax checking.
My current problem has to do with the debugger. SpaceVim has the "debug" layer enabled and I'd like to use "vimspector" as the debug plugin so that's been configured in ~/.SpaceVim.d/init.toml. I've run :VimspectorInstall vscode-java-debug from within Neovim and it appears to have installed the specified gadget correctly. I have a Java application I'm using for testing created with Apache Maven as follows:
mvn archetype:generate -DgroupId=my.test.app \
-DartifactId=hello \
-DarchetypeArtifactId=maven-archetype-quickstart \
-DinteractiveMode=false
In the root of that application directory I have the following .vimspector.json file:
{
"configurations": {
"Java Attach": {
"adapter": "vscode-java",
"filetypes": [ "java" ],
"configuration": {
"request": "attach",
"hostName": "localhost",
"port": "${port}",
"sourcePaths": [
"${workspaceRoot}/src/main/java",
"${workspaceRoot}/src/test/java"
]
}
}
}
}
With a java source file open, trying to launch the debugger ([SPC] d c), I'm prompted for a port number. This is logical since I didn't specify one in the config file above. And here is where I'm stuck. Somehow, based on my configuration, nvim "knows" how to communicate with the jdtls server whenever a java file is loaded, for the purposes of syntax and formatting. I know that's working because if it weren't I wouldn't get the live syntax checking etc. But Vimspector doesn't seem to be able to do the same natively. I suspect it has something to do with the .vimspector.json file above, which is probably not quite right for my installation. Assuming it's a port issue, I can see what port it's listening on with a netstat -lnt. But the port number changes every time. Furthermore, while looking it up and keying it in does allow the debugger to launch, there are errors. So I'm missing something somewhere. Any direction toward a working solution is much appreciated.