-
Notifications
You must be signed in to change notification settings - Fork 175
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Java Support via coc.nvim #3
Comments
As a core maintainer of YCM/ycmd, and author of the LSP integration in ycmd, it just makes more sense for me to use that. I hadn't seen coc before. It's not obvious what advantage it would have in terms of integrating with jdt.ls over what I could do with YCM, but I will take a look. TBH, reverse engineering the java debug plugin is proving to be pretty tricky, so java support is probably a way off either ways. |
For the record the DAP server is not part of jdt.ls. It's actually an extension bundle that is contributed in the Microsoft/vscode-java-debug VSCode extension, which ultimately boils down to the Microsoft/java-debug-server. This then does things with VSCode's commands, and LSP's executeCommand abomination, which I have yet to fully get my head around. |
You are right. I should have read the whole thread. |
Well, as it happens I have made it work (sort of) with jdt.ls/java debug server without any hard-dependency on the mechanism used for starting the debug server. vimspector asks the user what port to connect to and does not itself initiate jdt.ls's In my fork of ycmd I have made it possible to send this command to the jdt.ls within ycmd and voila, java debugging works! I haven't pushed this yet, but I'm quite pleased how simple it turned out to be. |
Nice! Will ycmd be a hard requirement for this or could it be configured to use another LSP-Provider? |
As it stands, there is no dependency on anything. You just have to tell vimspector the port on which the debug adapter is listening. How to start up the debug adapter int his case is not handled by vimspector. It just happens that it is trivial for me to make a ycm command which starts the debug server and returns the port to use. here's a demo: |
I would like to improve the workflow for firing up the adapter etc, but for now I would declare this "supported" by 14603ae so closing this issue (for now) |
@puremourning How exactly did you start the debug plugin? I had a look at java-debug, but couldn't figure it out. |
As you can see in my demo, i'm using a customised version of YouCompleteMe (actually ycmd) to send a custom command to the jdt.ls server. Ultimately, the way the debug server is started is:
The result of this is a number (a port) which is the TCP port on which the debug adapter is now listening. This is passed to vimspector by setting So you have to be able to execute this custom command implemented by jdt.ls and forwarded to the debug adapter plugin. Because that's the way it is designed. In VSCode, this is all done by the extensions collaborating within the VScode IDE. Vimspector doesn't have all of that (yet?) so it's all a bit manual. |
Feel free to contact me on gitter if you want more info. |
FWIW i actually use this regularly with my YCM and it works well. |
Just found https://github.com/georgewfraser/java-language-server, which includes a debug adapter that can be started independently of the language server. |
I think I tried it and found it didn’t work wel. But try it out. Let us know. |
I was able to get George Fraser's debugger working at a basic level, but it seems a lot less stable. It requires that you start your process with the java debug port set, then attach to it. I pushed a change to make it possible to install it, and update the example java project. Here are some instructions for the vimspector example (in support/test/java/test_project):
{
"adapters": {
"vscode-javac": {
"attach": {
"pidSelect": "none"
},
"command": [
"${gadgetDir}/java-language-server/dist/debug_adapter_mac.sh"
],
"name": "vscode-javac",
"type": "vscode-javac"
}
}
}
I tested it a bit and it crashed a lot. |
Is there a way to set the value for |
can you be more specific ? I mean if you always use port 1234, then just put 1234 in the vimspector.json. If you have a shell command you can run to work out the port, use a variable e.g.
|
Sorry for not being more specific... It is definitely nice to use a random port to allow multiple sessions at the same time. I'd like to be able to take the result of the |
Ah yes, this is a pain and on my sort of background TODO list to do something better. Unfortunately there's no way to "tell" Vimsector the DAP communication port at the moment. Please feel free to raise a new issue for that. PRs of course also welcome :) |
Ok, thanks for that clarification. I've opened the issue here #97. I'll dig through the code to see if its something I could tackle. I'd love to contribute if there's time, but python and viml are definitely not by forte. Definitely like where this plugin is heading. Thanks again! |
I replied. On reflection, it's trivial to do without changes. |
I have updated the README with instructions for using java with YCM: |
Just to update the thread, @dansomething has nicely provided coc-java-debug to integrate with Vimspector. |
Cool |
The Readme mentions, that java support could be gained by integrating something like ycmd. I would propose using coc.nvim for this instead. It has much better language support and even offers bundled language servers. The java extension for coc should already contain a working DAP Server. It is part of eclipse.jdt.ls.
The text was updated successfully, but these errors were encountered: