kotlin-language-server
kotlin-language-server copied to clipboard
Use without a build system
I am aware this is being worked on, but is there a branch we can compile to get it right now or something?
Should already work as of #154. Is kotlinc
on your PATH?
Yup! I'm using the vscode extension, it says stuff like println and readLine()!! is undefined (and asks me to add it to gradle)
:thinking: Any ideas on how to debug the problem?
Also btw, this is offtopic, but why isn't the atom extension maintained anymore? I would love to use this on atom as well
@gsbhasin123 Sure, is there anything not working with the Atom extension? It is updated independently from the language server.
Oh, is it maintained? never mind then :sweat_smile:
Was wondering since the last commit was in august '19 and the last commit for Visual Studio Code's was just around 2 months ago
Yup! I'm using the vscode extension, it says stuff like println and readLine()!! is undefined (and asks me to add it to gradle)
For me, it only happened when I used snap to install it in ubuntu 20.04. No issue found when I manually downloaded the the kotlinc and added it to my $PATH
ah. i can't check as i don't use kotlin anymore, sorry
ah. i can't check as i don't use kotlin anymore, sorry
No worries, just hope to help whoever is debugging this by posting it
I also met this issue. Did you solve it?
no i don't do kotlin anymore.
If I'm following this thread properly, in order to write and run a kotlin file independently from the build systems, it looks like I need to put kotlinc in my PATH. I followed this guide here: [ https://kotlinlang.org/docs/tutorials/command-line.html ] to manually install the compiler and I downloaded the Kotlin zip from Github and only extracted the compiler folder. It also says to add the bin directory to the system path so I went and added the bin folder from the cli folder from the compiler folder I extracted to the ~/.bashrc file. I entered echo $PATH and it's there. but then I get this as a result...
If I remove the path I just added everything works fine. If I download kotlin via sdkman do I need to add kotlinc to my path? If not then how can I get a single kotlin file to work with the extension without the build system?
it looks like I need to put kotlinc in my PATH. I followed this guide here: [ https://kotlinlang.org/docs/tutorials/command-line.html ] to manually install the compiler and I downloaded the Kotlin zip from Github and only extracted the compiler folder. It also says to add the bin directory to the system path so I went and added the bin folder from the cli folder from the compiler folder I extracted to the ~/.bashrc file. I entered echo $PATH and it's there. but then I get this as a result...
You mistakenly downloaded the source code for Kotlin. You need to download the runnable compiler instead (kotlin-compiler-*.zip).
(Guys, make sure to "Open Folder"; see https://github.com/fwcd/vscode-kotlin/issues/56#issue-753527354.)
I'm attempting to use Kotlin Language Server without a build system, using vim-lsp
to edit standalone Kotlin files like
package foo
object FooMain {
@JvmStatic
fun main(args: Array<String>) {
println("Hello ${args[0]}")
}
}
This results in INCOMPATIBLE_CLASS
errors all over the place, with log entries like
["<---",1,"kotlin-language-server",{"response":{"method":"textDocument/publishDiagnostics","jsonrpc":"2.0","params":{"uri":"file:///private/tmp/kotlin/foo.kt","diagnostics":[{"source":"kotlin","range":{"end":{"character":11,"line":3},"start":{"character":2,"line":3}},"code":"INCOMPATIBLE_CLASS","message":"Class 'kotlin.jvm.JvmStatic' was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.7.1, expected version is 1.1.15.\nThe class is loaded from /opt/local/share/java/kotlin/lib/kotlin-stdlib.jar!/kotlin/jvm/JvmStatic.class","severity":1},{"source":"kotlin","range":{"end":{"character":9,"line":5},"start":{"character":2,"line":5}},"code":"UNRESOLVED_REFERENCE","message":"Unresolved reference: println","severity":1},{"source":"kotlin","range":{"end":{"character":11,"line":3},"start":{"character":2,"line":3}},"code":"INCOMPATIBLE_CLASS","message":"Class 'kotlin.jvm.JvmStatic' was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.7.1, expected version is 1.1.15.\nThe class is loaded from /opt/local/share/java/kotlin/lib/kotlin-stdlib.jar!/kotlin/jvm/JvmStatic.class","severity":1}]}}}]
(The key message there is Class 'kotlin.jvm.JvmStatic' was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.7.1, expected version is 1.1.15
.) kotlinc
version 1.7.22-release-288 is installed via MacPorts in /opt/local/bin/kotlinc
and is detected by the Kotlin LSP earlier in the log. It looks like in the absence of a gradle or maven build config it's defaulting to the lowest Kotlin language version, which is incompatible with the actual files included with the installation. I would expect, in the absence of a build system, to default the Kotlin language version to the version of kotlinc
that's being used.