Sublime Forum

LSP Code Actions for Java

#1

I hooked up and finally got working the LSP plugin with Java and Ruby.

The Java works mostly pretty well with some issues, but one of the features I cannot get working is the code actions. For example:

None of these actions seems to work.

Other things work like renaming classes, etc., and that is pretty amazing for someone who has not used IDE’s before.

But are these code actions meant to work? They seem easier than, say, the refactoring support, so I am hoping I am just doing something wrong.

Any ideas?

0 Likes

#2

Based on your screenshot, you seem to be using ST3. Code actions from jdtls require some client glue. The LSP package has evolved for ST4 to allow writing this glue in a python extension point. There’s in fact already a helper package for this: https://github.com/sublimelsp/lsp-jdtls it’ll appear on packagecontrol.io once ST4 goes public. This helper package also sets up the connection settings and downloads the server jars.

0 Likes

#3

So do you think this functionality works if I switch to ST4?

0 Likes

#4

Yep, code actions work with that package. Specifically this part makes it work https://github.com/sublimelsp/LSP-jdtls/blob/ff0288855622889918bfae8ed5421875c9ff5302/plugin.py#L164-L172

0 Likes

#5

Wow - it works like a charm!!!

Thanks for your help, mate. Fantastic!

1 Like