kotlin-language-server
kotlin-language-server copied to clipboard
Unresolved reference when using Kotlin source files with a standalone compiler (kotlinc)
Hi,
I'm trying to use this extension with a simple, standalone Kotlin source file. The file looks like this:
fun main() {
println("Hello, world!")
}
With this, I get an Unresolved reference: printlnkotlin(UNRESOLVED_REFERENCE)
.
I have found some past issues that look similar: https://github.com/fwcd/kotlin-language-server/issues/73 https://github.com/fwcd/kotlin-language-server/issues/58
But I'm still not sure what I should do to make this work. Is there some kind of setting I need to change in order to work with standalone files?
I also saw that one issue mentioned something akin to a default Gradle directory or something, but, somehow, I can't find that issue anymore. Anyway, assuming that I have a completely fresh setup that has never touched a Gradle project, can I somehow make this work?
I have an installation of Android Studio, if that makes any difference. I have added the kotlinc
and Java
included with my Android Studio installation to my path, which enables me to compile my example file from the command line.
What does the language server logs say? My main guess is that the resolution of the standard library fails. It should in theory load the standard library based upon the kotlinc location. If you can share the language server logs, we see for sure 🙂
So, as mentioned, I'm accessing Kotlin from my Android Studio installation. For good measure, I just completely removed that and reinstalled it, but the problem persists.
Here are my logs: https://gist.github.com/LeCyberDucky/99c6fdc537df2cc9b16f5ed0af0a88cd
I have the same setup on my laptop (same installation method and same directory structure), but I don't have the same problem there, which seems odd.