-
-
Notifications
You must be signed in to change notification settings - Fork 154
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
Refactorings and jar definition lookups do not work on Windows #223
Comments
Regarding the jar definition i found in the lsp log that it cant start lein. Started my own repl and tested: |
@kstehn, that can be fixed in .lsp/config.edn
However, It seems clojure-lsp in calva use clj-kondo to scan classpath dependent jars and cache metadata in .clj-kondo/.cache, but clj-kondo doesn't seem do that either on windows. |
@PEZ's workaround restored most of calva features with connected repl (autocomplete still doesn't work in comment block though). @ericdallo, I think the fundamental problem on windows is that clj-kondo on windows does not index dependent jars from classpath path (see below screenshot). If clojure-lsp in calva depends on it, most of clojure-lsp features that rely on these metadata won't work. My setup on windows, lein classpath only has one jar in .cpcache because windows can't handle long classpath. The full classpath is in META-INF/MANIFEST.MF. I don't think clj-kondo scan jars from there. Hence only two .json files from project src showed up .clj-kondo/.cache. One more observation, I used to use clojure-lsp in coc-nvim running in WLS Ubuntu on the same windows laptop, I remember everyting work fine including refactoring and autocomplete features that depends on full classpath metadata. But these feature seems not avaliable in calva integrated clojure-lsp even VSCode is started from remote WSL (I verified integrated clj-kondo indeed scan all jars successfully in this case). |
Sorry, but I still don't get it if it's a |
Things seem get complicated when all three interact with each other :-) No worries, what's been added are still great. Thank you very much for your work! |
Thanks! Still, if we have any evidence that may be a bug on |
I tested this in a Windows VM and can reproduce. This is the code I'm using on both, in a windows.clj file. I put my cursor at (ns windows
(:require [hiccup.core :as h]))
(comment
(h/html [:div "hello"])) This is the request/response on Linux (working): [Trace - 10:12:15 AM] Sending request 'textDocument/definition - (110)'.
Params: {
"textDocument": {
"uri": "file:///home/brandon/development/clojure-test/src/windows.clj"
},
"position": {
"line": 1,
"character": 21
}
}
[Trace - 10:12:15 AM] Received response 'textDocument/definition - (110)' in 8ms.
Result: {
"uri": "jar:file:///home/brandon/.m2/repository/hiccup/hiccup/1.0.5/hiccup-1.0.5.jar!/hiccup/core.clj",
"range": {
"start": {
"line": 0,
"character": 4
},
"end": {
"line": 0,
"character": 15
}
}
} And this is the request/response on Windows (not working - also it's an image because not easy to copy/paste from my VM without some added effort: |
Both of the above are in a deps.edn project |
Oh, so it looks separator issue on |
@bpringe you may have noticed that, but Calva probably is sending the |
I'm not sure how clojure-lsp is saving the uri. What does it want? Maybe |
Not sure how is the correct to be sent, could you check other LSP requests/responses and how it's sending the uri? |
Yeah, probably... we'd need to know how we should send the jar files path for windows :/ |
So the Uri isnt the Problem here. I dont know if you can find it in your lsp logs but on my machine it tries to execute lein classpath to Index all jar files and the containing namespaces but it failes because the shell cant find lein |
Got it, I'll look into that. I'm using clj but could be the same thing. |
Aha! From /tmp/lsp.out (pasting from my Windows VM):
|
We may need to play with configuration to find what lsp needs, as @fonghou was saying. |
Thanks for the info with the |
I've added this config and I don't get the above exception any more, but LSP still does not find the reference in the jar dep. Btw {:project-specs [{:project-path "deps.edn"
:classpath-cmd ["powershell.exe" "clj" "-Spath"]}]}
|
On windows, with the above classpath-cmd, the classpath is returned like In the lsp messages I see this after trying to go to definition:
So we can see lsp is sending back the document uri like |
Also regarding my message about lsp still not finding the ref after config change, I had to delete the sqllite db in |
Hum, quite interesting, this is the code from the |
the issue is: it tries to find in db the uri: |
When I look in the sqlite db, though, the uri in the |
FYI, we now include |
Took me a while to get dependencies set up in my fresh Windows VM, but finally here are the logs:
Note the I also got that error when I called |
Thank you @bpringe, not sure yet what is causing it... |
@bpringe I think the worst here is don't know what is the correct uri path to respond to client for windows users... |
Thanks @ericdallo. I'm currently playing in the repl in clojure-lsp on Windows with the |
I found that the code works if I change the (import (org.eclipse.lsp4j TextDocumentIdentifier))
(->> "jar:file:/C:\\Users\\brand\\.m2\\repository\\hiccup\\hiccup\\1.0.5\\hiccup-1.0.5.jar!/hiccup/core.clj"
TextDocumentIdentifier.
(extension "dependencyContents")) clojure-lsp stores them with |
Well done! |
Though it's not very explicit, I think these docs point to using a single |
Indeed! |
This is actually two separate issues, one of them to be fixed in lsp (jar files navigation), and one to be fixed in Calva (refactorings). The refactorings issue can be tracked here. |
@bpringe LMK if you need any help, I saw your PR, so the |
|
If you're trying through a Calva release, I still need to include the new version, but I'll update this issue when I do. |
I am not sure this is not related to Calva, but it seems we do things right on the client end when I look at it.
Anyway, for this example, on Windows,, definitions for
remove
,apply
,mapv
etcetera do not work. Definitions forutil/add7
and forv
works.Also refactorings like trying to unwind the thread on
v
doesn't work. It gives a warning in the log:This seem somewhat covered by #25
The text was updated successfully, but these errors were encountered: