-
Notifications
You must be signed in to change notification settings - Fork 231
[Multiplatform + Neovim + VSCode] Performance, unresolved references, errors #376
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Just checked, same problems applies to VSCode Kotlin extension with two differences: the extension reacts on a situation when I make an error. In this case it successfully shows an error after 3-4 seconds which is acceptable delay in my opinion. And startup time for the moment of displaying an error is about 30 seconds which is good. |
That sounds extremely weird 😱 Are you sure the indexing dependencies operations are done at that point? (in VSCode you have a kotlin-option in the output section, and I usually check my Sorry if I seem surprised. In newer times I have not had any issues with external libs in Maven and Gradle 🙁 Issues relating to low performance and memory usage: #327 and #352. |
@themkat , thanks for the answer. The project I use here for testing is closed source, so can't share it. But I just googled a ktor example project we can both use for comparison of results. It's not using Android but produce the same errors. git clone https://github.com/ktorio/ktor-samples
cd ktor-samples/chat Then open this whole directory in nvim/VSCode/Emacs. Then choose specific file inside your app of choice: First time I just opened this project without prebuilding it via command line. Then, after I saw errors, I built the project via So have no idea what the problem is, but the project can be successfully built via the command I specified. |
I can confirm that I also experience these errors... 😢 My guess it that it is because of this being a KMM project. I remember there was some other issue relating to KMM posted in the VSCode plugin: fwcd/vscode-kotlin#98 . My guess is that it expects top-level dependencies-sections in the build.gradle files, and do nothing with the sourceSet declarations (found in the ktor one, and probably also your other one?). Have to familiarize myself with the gradle based part of the language server before I can think of a possible solution... |
Yeah, I see no usages of It's not only KMP problem. For example, opening this directory produce the same result: https://github.com/simplex-chat/simplex-chat/tree/stable/apps/android |
@themkat can you, please, share a link to any gradle project in the internet you're successfully using with this language server? Just want to try if I able to use it also. |
Hmm. that one I get errors in for one reason: not having installed the Android SDK (tons of warnings during the fetch dependencies stage). I guess your ANDROID_HOME env variable is set?
After installing it and fiddling around, I get these errors:
Do you get any sort of similar errors? I had to fiddle a local.properties files in apps/android to set the properties. I could not find a specific cmake executable within the Android SDK, and I don't think fiddling with this for a long time is that useful. Seems a little wasteful to continue bloating up my system. Could not find that old of a cmake version with homebrew. I never do Android stuff, which is why I did not have any of the Android stuff installed 😆 (at least it gets much farther than the other KMM project! That one didn't even try to load any dependencies!) I think the issue caused by this project is that it is a mix of both ndk and sdk usage, but I might be wrong.
Sure. This project (the language server itself) works like a charm. Same with https://github.com/fwcd/kotlin-debug-adapter. You could also try to create a plain Kotlin app with https://start.spring.io/ . |
Starting to wonder if either my setup is weird, or if the server is weird with Android apps. Tried this project and got this error during dependency resolution:
I'm probably not the best person to debug Android issues, but hopefully all of these comments either help future me or someone else who wants to try to debug it 😆 EDIT: Updated the Gradle wrapper version to 7.5, got no errors, but still NO resolved Android symbols... Weird. Only Kotlin stdlib reported in lsp output. |
Just don't try to build this project, it's hard) For the CMake part the already built lib is needed which you don't have. I just opened it out of curiosity, saw errors and closed again:) I found a test project for us, which is:
|
I didn't try to build it manually, it is from the standard dependency resolution part of the language server (which runs gradle with a custom task I linked to above) 🙂 "Installing it" referred to Android SDK, as I don't code for Android (I dislike app development). If you can't run gradle to resolve dependencies, you can't do anything relating to external dependencies, it is that simple. Get a cryptic error this time, due to class file major versions. Maybe it is because of me using Java 18. Have to investigate further later, as I have other things I need to do before getting back to work tomorrow. |
Yes, have set it for the entire environment: env | grep ANDROID
ANDROID_HOME=/home/user/Android/Sdk
Probably, yes. In my case Java version is 11. Don't see errors related to SDK, but see unresolved dependencies. Kotlin keyword Seeing errors like P.S. file is |
Do you have a buffer like mine for Language server outputs? The errors I'm talking about is not shown as code errors, just in my lsp-log-buffer (or Kotlin-output section if using VSCode).
I get none of those issues. lazy is found, no errors on Unit etc. Stdlib should be resolved automatically if it is present. On my machine it falls back to using Maven, and looks in my .m2-directory. From the language server output/logs:
stdlib should in general not be a problem, as long as it is either included in your dependencies (build.gradle or pom.xml) or is somewhere on your system (both Maven and Gradle should use .m2 if I'm not mistaken). There is a special stdlib resolver who tries a bunch of different things to fetch it. Tried experimenting a bit now using Java 11. Had to install some packages in the Android SDK. This is from the language server output/logs (Gradle get dependencies step):
After installing those (had to do it manually for it to work), I had to wait for the symbol indexing populating to work, and the project just works 🙂 (this took almost 5 minutes on my M1 Macbook Air, which is insanely long for a project in my experience!). Only error is BuildConfig not being found. Completions work, and the external dependencies are loaded as expected. Without having my My conclusions is this:
Hope my stuff is helpful and not just spam 🙁 Not really that knowledgable on Android and its ecosystem... On the bright side, I'm learning something new 🙂 I will try to look more into the multi platform project issues (one of the first ones you sent, simplex-chat or ktor-samples chat) later this evening, or maybe tomorrow as I'm starting to get tired 🙂 EDIT: The ktor-samples chat issues, and other kotlin multi platform projects, seems to have another root cause. Still getting issues with external dependencies on those |
I cloned this repo ( Then I opened Keymapper project. I'm now much older than I was when did so. Project setup takes centuries. I stopped counting my age:) I mean, Now I got this error in lsp log file:
First result in search is this: https://stackoverflow.com/questions/64834818/android-studio-could-not-get-unknown-property-kotlin-version Results from this repo: https://github.com/fwcd/kotlin-language-server/search?q=kotlinVersion Maybe after adapting language-server source code to suggestions from SO result will be better. But at least it's something new. Which means installing maven helped somehow.
There are so many lines in the lsp log (more than 160000), almost all of them about Regarding sample
After that multiple errors related to different things. In nvim it's still can't find
As I said, better don't. To fully build the lib, you need to install Haskell, nix package manager, build GCC from source (which is a part of Nix build process), setup CMake and so on. It will take at least one day of your time. Would be better to get results with |
Don't underestimate how stubborn I can be 😉 I ended up playing with the ktor chat example for now. I think I will soon have a working solution for resolving dependencies in kotlin multiplatfor projects, but it needs some more testing. The current solution I have implemented needs some tweaking to work, as it is far from perfect. Hope to get a PR done by this evening.
Those are really fun to play with indeed 🙂 I've been wanting to go through the How To Solve It book my George Polya, and solve it in Haskell. Heard from someone long ago that it was really fun to do so. There is too much fun stuff to do for me to have time for everything 🙁 |
Hello, thank you for the work on this server. Trying to make it work with Neovim. I'm using Intellij IDEA maaaany years and the project I testing now works in IDEA beautifully. So I suppose I need to somehow setup the server if I want to use it with Neovim.
I filling this issue with multiple problems because I think that all issues related to one thing that I'm missing. If it's not the case, tell me to create multiple small issues or to read docs:)
Prerequests:
pacman -S kotlin
pacman -S gradle
Issues I have:
Overload resolution ambiguity
It's a main problem. The main thing for KMPP is not working properly. While
Goto reference
works perfectly within MY common/native/Android code. The server able to find reference to a function from different source set.Unresolved references
Third-party libraries don't work. While all of them work in Intellj IDEA.
Low performance
After reopening vim (closing vim and reopening it again) on the same file I worked before it takes 4-8 minutes to see first error highlighting. All this time CPU almost on max. Memory usage increases from 1G to 4-5GB easily (numbers without including Gradle memory usage). Almost all CPU usage from the server, not Gradle.
When the server started (for the moment when I see highlighted errors), I try to edit something. So I just removing a piece of code to make the server showing an error. Error is not highlighted even after a couple of minutes. In IDEA it takes 2-3 seconds on a long file.
Screenshot after 3 minutes of loading the project:

Video about not highlighted error in a code after making an error:
kotlin-2022-07-29_23.39.32.mp4
Project structure:
settings.gradle
What am I doing wrong?
The text was updated successfully, but these errors were encountered: