coc + kotlin-language-server + nvim building former Android Studio Project
See original GitHub issue(new to Kotlin, gradle, Android Apps, etc)
I got coc and kotlin-langugage-server working in Vim, but when I open my kotlin file every symbol is basically an error:
[kotlin MISSING_BUILT_IN_DECLARATION] [E] Cannot access built-in declaration 'kotlin.String'. Ensure that you have a dependency on the Kotlin standard library
This project works when I open it with Android Studio.
I’ve seen many similar reported issues, but the ones that were solved didn’t look applicable.
My nvim is setup so that the work directory is the top of the git repo, my app is in client/
, and it has a gradlew
file. I’ve invoked ./gradlew androidDependencies
which did something successfully.
I have log files, I’m not sure how to interpret the messages, though this appears pertinent:
/tmp/kotlin-daemon.2021-03-23.09-25-02-144.00.log
2021-03-23 09:25:05.441 [daemon] INFO: Message: logging: using Kotlin home directory <no_path>
2021-03-23 09:25:05.442 [daemon] INFO: Message: logging: scripting plugin will not be loaded: not all required jars are present in the classpath (missing files: [./kotlin-scripting-compiler.jar, ./kotlin-scripting-compiler-impl.jar, ./kotlinx-coroutines-core.jar, ./kotlin-scripting-common.jar, ./kotlin-scripting-jvm.jar, ./kotlin-scripting-js.jar, ./js.engines.jar])
I found kotlin-scripting-compiler.jar
, and added its path to my CLASSPATH
(tried PATH
too) but this didn’t help. I’ve even tried symlinking some of those files to a local path in an attempt to match the ./
, all to no avail.
How can I get the kotlin-language-server to find my dependencies?
Issue Analytics
- State:
- Created 2 years ago
- Reactions:1
- Comments:5 (2 by maintainers)
Gotcha. Yeah, looks like the same issue.
https://github.com/fwcd/kotlin-language-server/blob/58966bc18dd5bf82fdfcf7a2f44bab3622f6907a/shared/src/main/kotlin/org/javacs/kt/classpath/WithStdlibResolver.kt#L14-L42
I’m finding that if we modify the function here to:
It solves the issue for me. That’s not a long term solution, but it might help you get patched up locally until a better solution is found. We’re going to have to look at how we’re resolving kotlin’s stdlib and what exactly is causing the conflict here.
As a side note:
Your error
1. Cannot inline bytecode built with JVM target 1.8 into bytecode that is being built with JVM target 1.6 Please specify proper '-jvm-target' option
is caused by Kotlin not using the right compiler. You can set it in vim like so:@DonnieWest I think both changes (classpath and version version) are working! For example, now whe nmy cursor is over
Collections.synchronizedList
and I invokevim.lsp.buf.hover()
, I get the full definition:Thanks!