question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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:open
  • Created 2 years ago
  • Reactions:1
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
DonnieWestcommented, Apr 12, 2021

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:

        pathString.contains("kotlin-stdlib") && !pathString.contains("kotlin-stdlib-common") && pathString.contains("jdk")

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:

nvim_lsp.kotlin_language_server.setup{
  settings = {
    kotlin = {
      compiler = {
        jvm = {
          target = "1.8";
        }
      };
    };
  }
}
1reaction
kheaactuacommented, Apr 14, 2021

@DonnieWest I think both changes (classpath and version version) are working! For example, now whe nmy cursor is over Collections.synchronizedList and I invoke vim.lsp.buf.hover(), I get the full definition:

fun <T : Any!> synchronizedList((Mutable)List<T!>!): (Mutable)List<T!>!

Thanks!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Anyone interested in creating an coc.nvim extension for Kotlin?
I've been using kotlin-language-server. It works to a certain extent. It's missing auto-imports which... in the JVM world, unfortunately, is ...
Read more >
KotlinLanguageServer - Bountysource
when I open a Kotlin project build with gradle,the "Kotlin:Indexing" ... coc + kotlin-language-server + nvim building former Android Studio Project $ 0....
Read more >
Coc.nvim – Intellisense Engine for Vim8 and Neovim
I wrote a javascript language server based on ESLint and Tern: ... good support for it and it is the basis for Android...
Read more >
Language Server Extension Guide - Visual Studio Code
LSP is a win for both language tooling providers and code editor vendors! LSP Languages and Editors. In this guide, we will: Explain...
Read more >
Vim for people who use Visual Studio Code - Medium
How do you exit Vim? Probability is high that you've ever edited a file on a Linux server, and couldn't figure out how...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found