A language server that provides IDE-independent smart code completion, diagnostics, hover, document symbols, method signature help and more for Kotlin and a VSCode extension that uses the language server.
This repository needs your help!
The original author created this project while he was considering using Kotlin in his work. He ended up deciding not to and is not really using Kotlin these days though this is a pretty fully-functional language server that just needs someone to use it every day for a while and iron out the last few pesky bugs.
There are two hard parts of implementing a language server:
The project uses the internal APIs of the Kotlin compiler.
Dependencies are determined by the findClassPath function, which invokes Maven or Gradle and tells it to output a list of dependencies. Currently, both Maven and Gradle projects are supported.
I get incremental compilation at the file-level by keeping the same
Getting incremental compilation at the expression level is a bit more complicated:
The incremental expression compilation logic is all in CompiledFile.kt. The Kotlin AST has a built-in repair API, which seems to be how IntelliJ works, but as far as I can tell this API does not work if the surrounding IntelliJ machinery is not present. Hence I created the "fake tiny file" incremental-compilation mechanism, which seems to be quite fast and predictable.
There is an extensive suite of behavioral tests, which are all implemented in terms of the language server protocol, so you should be able to refactor the code any way you like and the tests should still work.
Go-to-definition, find all references