Open fwcd opened 5 years ago
We could create a custom dependency resolver that looks up KOTLIN_HOME
(see this script) and adds the JAR files under $KOTLIN_HOME/libexec/lib
to the classpath.
I didn't know where this would fit. Issue is related to "Single files outside any project" type of issues.
I created variable.kt
for the topic with following code
val name: String? = "Abhinav"
var greeting: String = "Hello"
fun main() {
println(greeting)
println(name)
}
Then for next topic i created flow_control_if.kt
which has following code.
val name: String = "Abhinav"
var greeting: String? = null
fun main() {
val greeting_to_print = if (greeting != null) greeting else "Hi"
println(greeting_to_print)
println(name)
}
While the file is separate, and I have not created any project since #153 is solved. The language server still treats the directory as a project, and shows kotlin(REDECLARATION)
on the variables and kotlin(OVERRIDE_RESOLUTION_AMBIGUITY)
on function expressions, on all the files created down the line. I can still use kotlinc
and kotlin
to execute it. This is just on the editor.
@fwcd Is there anything more that needs to be done? I'm running it from Emacs without Gradle and I still get this error. kotlinc
is in my path along with its libraries:
/usr/bin/kotlin
/usr/bin/kotlinc
/usr/bin/kotlinc-js
/usr/bin/kotlinc-jvm
/usr/share/kotlin-bin/build.txt
/usr/share/kotlin-bin/lib/allopen-compiler-plugin.jar
/usr/share/kotlin-bin/lib/android-extensions-compiler.jar
/usr/share/kotlin-bin/lib/android-extensions-runtime.jar
/usr/share/kotlin-bin/lib/annotations-13.0.jar
/usr/share/kotlin-bin/lib/js.engines.jar
/usr/share/kotlin-bin/lib/jvm-abi-gen.jar
/usr/share/kotlin-bin/lib/kotlin-annotation-processing-cli.jar
/usr/share/kotlin-bin/lib/kotlin-annotation-processing-runtime.jar
/usr/share/kotlin-bin/lib/kotlin-annotation-processing.jar
/usr/share/kotlin-bin/lib/kotlin-annotations-android.jar
/usr/share/kotlin-bin/lib/kotlin-annotations-jvm-sources.jar
/usr/share/kotlin-bin/lib/kotlin-annotations-jvm.jar
/usr/share/kotlin-bin/lib/kotlin-ant.jar
/usr/share/kotlin-bin/lib/kotlin-compiler.jar
/usr/share/kotlin-bin/lib/kotlin-coroutines-experimental-compat-sources.jar
/usr/share/kotlin-bin/lib/kotlin-coroutines-experimental-compat.jar
/usr/share/kotlin-bin/lib/kotlin-daemon-client.jar
/usr/share/kotlin-bin/lib/kotlin-daemon.jar
/usr/share/kotlin-bin/lib/kotlin-imports-dumper-compiler-plugin.jar
/usr/share/kotlin-bin/lib/kotlin-main-kts.jar
/usr/share/kotlin-bin/lib/kotlin-preloader.jar
/usr/share/kotlin-bin/lib/kotlin-reflect-sources.jar
/usr/share/kotlin-bin/lib/kotlin-reflect.jar
/usr/share/kotlin-bin/lib/kotlin-runner.jar
/usr/share/kotlin-bin/lib/kotlin-script-runtime-sources.jar
/usr/share/kotlin-bin/lib/kotlin-script-runtime.jar
/usr/share/kotlin-bin/lib/kotlin-scripting-common.jar
/usr/share/kotlin-bin/lib/kotlin-scripting-compiler-impl.jar
/usr/share/kotlin-bin/lib/kotlin-scripting-compiler.jar
/usr/share/kotlin-bin/lib/kotlin-scripting-js.jar
/usr/share/kotlin-bin/lib/kotlin-scripting-jvm.jar
/usr/share/kotlin-bin/lib/kotlin-stdlib-jdk7-sources.jar
/usr/share/kotlin-bin/lib/kotlin-stdlib-jdk7.jar
/usr/share/kotlin-bin/lib/kotlin-stdlib-jdk8-sources.jar
/usr/share/kotlin-bin/lib/kotlin-stdlib-jdk8.jar
/usr/share/kotlin-bin/lib/kotlin-stdlib-js-sources.jar
/usr/share/kotlin-bin/lib/kotlin-stdlib-js.jar
/usr/share/kotlin-bin/lib/kotlin-stdlib-sources.jar
/usr/share/kotlin-bin/lib/kotlin-stdlib.jar
/usr/share/kotlin-bin/lib/kotlin-test-js-sources.jar
/usr/share/kotlin-bin/lib/kotlin-test-js.jar
/usr/share/kotlin-bin/lib/kotlin-test-junit-sources.jar
/usr/share/kotlin-bin/lib/kotlin-test-junit.jar
/usr/share/kotlin-bin/lib/kotlin-test-junit5-sources.jar
/usr/share/kotlin-bin/lib/kotlin-test-junit5.jar
/usr/share/kotlin-bin/lib/kotlin-test-sources.jar
/usr/share/kotlin-bin/lib/kotlin-test-testng-sources.jar
/usr/share/kotlin-bin/lib/kotlin-test-testng.jar
/usr/share/kotlin-bin/lib/kotlin-test.jar
/usr/share/kotlin-bin/lib/kotlinx-coroutines-core.jar
/usr/share/kotlin-bin/lib/kotlinx-serialization-compiler-plugin.jar
/usr/share/kotlin-bin/lib/mutability-annotations-compat.jar
/usr/share/kotlin-bin/lib/noarg-compiler-plugin.jar
/usr/share/kotlin-bin/lib/sam-with-receiver-compiler-plugin.jar
/usr/share/kotlin-bin/lib/trove4j.jar
Since I haven't tested the language server much in kotlinc-only environments and the issue seems to persistent, I'll reopen it for now.
Is there anything that can be done to turn this off?
It's been a year since the last comment, and this error is still occurring. Anything that can be done to fix it?
Any updates?
I think we need to just click on uninstall option that's the best solution
@cnshu I already did that a long time ago. The thing is, I would really like to use Kotlin for competitive programming contests, but because I can't find a good LSP, I couldn't do that... And this is not the only LSP that sucks when used on a single file, many of them are just horrible.
@AmeerTaweel Same here. It is understandable that community run projects will have tough time to maintain feature parity with official language spec, since jetbrains team will never make an official lsp. As a language Kotlin is really good for competitive programming, and its popularity is attracting a lot of students. Teaching kotlin language to students is really troublesome if this lsp can't work outside a project structure, for single files. Especially since this is also the only active lsp available for kotlin.
I was having a similar issue with the error message Cannot access built-in declaration 'kotlin.String' at neovim (vim + coc works out of the box). Ensure that you have a dependency on the Kotlin standard library
populating the linter error log. Got it resolved by appending the root_dir
key i.e., root_dir = lspconfig.util.root_pattern('', 'settings.gradle.kts', 'gradlew')
.
Currently, the language server has trouble locating the standard library for files outside of Maven/Gradle projects, despite
kotlinc
being installed on the system (see #93).This results in (incorrect) errors: