vscode-java-kotlin icon indicating copy to clipboard operation
vscode-java-kotlin copied to clipboard

Alternative approach, run Kotlin LS as Java LS plugin

Open nisargjhaveri opened this issue 1 year ago • 2 comments

Since #3 and likely more such integrations would require communicating between the java.ls extension and the kotlin language server running separately, I tried an alternate approach to simplify the communication.

Have a look at https://github.com/nisargjhaveri/kotlin-language-server/commit/c8129aab28887a9ba3c2b38a774329a84df62564, if interested.

This essentially attempts to run the entire Kotlin ls as a java.ls plugin. The server is started via a custom command Kotlin ls would contribute to the Java ls. This certainly requires some more modifications, but would have a number of benefit for the java-kotlin multi-lingual projects.

  • Easier to implement more integrations such as #3, without having to figure out a new communication channel.
  • We can modify the Kotlin LS to use the project definition, classpath etc from the Java LS. This way both Java and Kotlin part of the project sees the same project configuration. Lesser chances of mismatch and surprises between the two.
  • Kotlin build can be integrated with the Java build, such that we see even lesser errors, even at the initial stages of the project setup and build.

I was able to run the language server this way, see the commit above. Though this commit does not have the corresponding changes required in kotlin plugin to trigger the custom command to start the LS. Obviously this helps in the Java-Kotlin interop cases only. We'd still need the standalone Kotlin server for other cases.

I'm really not an expert at this and could not follow up post this. Thought I'd share in case this helps.

Also, the changes there might also help with #4 as I was able to use gradle only for the Java ls plugin.

nisargjhaveri avatar Apr 10 '23 16:04 nisargjhaveri