fwcd / kotlin-language-server

Kotlin code completion, diagnostics and more for any editor/IDE using the Language Server Protocol
MIT License
1.58k stars 202 forks source link

Feature - disable extension on per-file basis to mitigate `Unresolved reference:` errors #567

Open spaceunifyfifty opened 4 months ago

spaceunifyfifty commented 4 months ago

From my research it looks that the extension still does not support code from third party dependencies like JUnit or KMP. Examples #487, #101 The code successfully compiles and executes, but I have VSCode visually alerting me with red errors everywhere. I want to tell the extension to ignore certain files or sets of files where libraries are imported and used. I can tolerate not having autocompletion and hints in a few minority sections of my codebase while getting to benefit from the extension in the vanilla kotlin majority of cases. But currently it looks like my only options are to totally remove your extension and have no ide support for the language or use your extension but be limited from using any libraries if I don't want red squiggles everywhere.

fwcd commented 4 months ago

From my research it looks that the extension still does not support code from third party dependencies like JUnit or KMP.

It should support that, but only if your project follows a standard Maven/Gradle layout. If it does not, you could create a kls-classpath script to tell it where to find the corresponding JARs.

But currently it looks like my only options are to totally remove your extension and have no ide support for the language or use your extension but be limited from using any libraries if I don't want red squiggles everywhere.

If you "just" want to disable errors (and still get code completion etc.), you can also set "kotlin.diagnostics.enabled": false, but that will disable them everywhere. This is a more of a feature of last resort to make the language support somewhat usable even if the language server cannot resolve all dependencies correctly.

Ignoring specific files is still to be implemented, it has come up every now and then (see e.g. the discussion in https://github.com/fwcd/kotlin-language-server/pull/560).

spaceunifyfifty commented 3 months ago

I looked at the classpath example, and I'm not really sure what it would look like for example, a project that uses the ktor library? Where is that located?