hi. there is an off-by-1 error either on Idea or on clj-kondo on reporting unused function argument location. see f
in the pic. greyed out are from cursive, underlines from clj-kondo :thinking_face:
tested from command line, the PATH is corrrect, but still doesn’t work, timeouts after 30sec:
2021-07-05T07:46:22.505Z UnknownHost INFO [clojure-lsp.crawler:27] - Finding classpath via ` clojure -Spath `
2021-07-05T07:46:22.566Z UnknownHost INFO [clojure-lsp.crawler:27] - Finding classpath via ` npx shadow-cljs classpath `
2021-07-05T07:46:51.574Z UnknownHost INFO [clojure-lsp.crawler:204] - Analyzing classpath for project root /Users/tommi/projects/metosin/malli
2021-07-05T07:46:51.575Z UnknownHost INFO [clojure-lsp.crawler:88] - Analyzing 15 paths with clj-kondo with batch size of 1 ...
IDEA logs this:
2021-07-05 10:47:52,122 [ 106969] WARN - pper.LanguageServerWrapperImpl - Capabilities are null for rawCommand : /usr/local/bin/clojure-lsp
2021-07-05 10:47:52,123 [ 106970] WARN - ub.gtache.lsp.utils.FileUtils$ - invalid url: ///Users/tommi/.m2/repository/org/clojure/clojure/1.10.3/clojure-1.10.3.jar!/clojure/core.clj (java.net.MalformedURLException: no protocol: ///Users/tommi/.m2/repository/org/clojure/clojure/1.10.3/clojure-1.10.3.jar)
java.net.MalformedURLException: invalid url: ///Users/tommi/.m2/repository/org/clojure/clojure/1.10.3/clojure-1.10.3.jar!/clojure/core.clj (java.net.MalformedURLException: no protocol: ///Users/tommi/.m2/repository/org/clojure/clojure/1.10.3/clojure-1.10.3.jar)
at java.base/java.net.URL.<init>(URL.java:679)
at java.base/java.net.URL.<init>(URL.java:541)
at java.base/java.net.URL.<init>(URL.java:488)
at com.github.gtache.lsp.utils.FileUtils$.VFSToURI(FileUtils.scala:101)
at com.github.gtache.lsp.utils.FileUtils$.editorToURIString(FileUtils.scala:89)
at com.github.gtache.lsp.client.languageserver.wrapper.LanguageServerWrapperImpl.connect(LanguageServerWrapperImpl.scala:181)
at com.github.gtache.lsp.client.languageserver.wrapper.LanguageServerWrapperImpl.$anonfun$restart$1(LanguageServerWrapperImpl.scala:405)
at com.github.gtache.lsp.client.languageserver.wrapper.LanguageServerWrapperImpl.$anonfun$restart$1$adapted(LanguageServerWrapperImpl.scala:405)
at scala.collection.IndexedSeqOptimized.foreach(IndexedSeqOptimized.scala:32)
at scala.collection.IndexedSeqOptimized.foreach$(IndexedSeqOptimized.scala:29)
at scala.collection.mutable.WrappedArray.foreach(WrappedArray.scala:38)
at com.github.gtache.lsp.client.languageserver.wrapper.LanguageServerWrapperImpl.restart(LanguageServerWrapper
tested from repl, that doesn’t work:
(java.net.URL. "///Users/tommi/.m2/repository/org/clojure/clojure/1.10.3/clojure-1.10.3.jar")
; =throws=> Execution error (MalformedURLException) at java.net.URL/<init> (URL.java:593).
; no protocol: ///Users/tommi/.m2/repository/org/clojure/clojure/1.10.3/clojure-1.10.3.jar
➜ ~ ls -l ///Users/tommi/.m2/repository/org/clojure/clojure/1.10.3/clojure-1.10.3.jar
-rw-r--r-- 1 tommi staff 3914649 Mar 11 20:47 ///Users/tommi/.m2/repository/org/clojure/clojure/1.10.3/clojure-1.10.3.jar
so:
1. IDEA doesn’t set the PATH correctly
2. clojure -Spath
returns URLs that the plugin doesn’t understand (uses java.net.Url
.
➜ malli git:(malli.instrument) ✗ clojure -Spath
src:resources:/Users/tommi/.m2/repository/borkdude/dynaload/0.2.2/dynaload-0.2.2.jar:/Users/tommi/.m2/repository/borkdude/edamame/0.0.11/edamame-0.0.11.jar:/Users/tommi/.m2/repository/org/clojure/clojure/1.10.3/clojure-1.10.3.jar:/Users/tommi/.m2/repository/org/clojure/test.check/1.1.0/test.check-1.1.0.jar:/Users/tommi/.m2/repository/org/clojure/tools.reader/1.3.4/tools.reader-1.3.4.jar:/Users/tommi/.m2/repository/org/clojure/core.specs.alpha/0.2.56/core.specs.alpha-0.2.56.jar:/Users/tommi/.m2/repository/org/clojure/spec.alpha/0.2.194/spec.alpha-0.2.194.jar
@luis.tn the 2. seems a issue with clojure-lsp right? For some reason with IDEA it returns wrong urls
Or the lsp plugin is sending malformed URLs
above is what clojure -Spath
returns. The plugin uses Url
to handle those, which can’t
e.g. the plugin should be changed or the urls should be preprosessed to be compliant what Url
accepts.
Yeah, but probably is not following some convention somewhere in the plugin as all other editors like VSCode, emacs, vim works
e.g. add file:
to the urls
I can try to repro that with IDEA + LSP plugin
(java.net.URL. "file:/Users/tommi/.m2/repository/org/clojure/spec.alpha/0.2.194/spec.alpha-0.2.194.jar")
works okBTW try to disable that timeout, that will not work as sometimes (first time) clojure-lsp will take a while to scan the project and other times it will be fast
yeah, did that. just that it doesn’t load any files from classpath as it can’t read the urls
Yes, let me try understand where the issue is, I'll try to repro
I managed to make it work without any errors
But I need to say this LSP plugin is missing a lot of features and its UX is not great IMO 😞
I'd suggest you try Calva for VSCode or Emacs if you want the better clojure development experience 😕
Anyway, I didn't get any URLs errors :thinking_face: (NixOS here)
Can you paste the code? I can try in emacs
(defn kikka [x y z] (+ y z))
Can you disable clj-kondo, to see if it's related?
disabling clj-kondo makes the underlining go away, as expected
➜ ~ clj-kondo -v clj-kondo v2021.06.01
This is weird, might be an issue with the thing you’re using to integrate clj-kondo, what is that?
file-watcher
Be back in an hour or so
Try the LSP thing, might work better
See docs
👍
it works. will start using that.
ok, but, the existing cursive greying out doesnt work with LSP.
default cursive:
ok, I think the problem is not so much in clj-kondo but in the integration then
not sure if there's anything I can do
perhaps ask in #cursive
I have posted a similar issue about this before I see: https://intellij-support.jetbrains.com/hc/en-us/community/posts/360003434480-File-watcher-inspection-doesn-t-use-line-and-column-correctly
note on the LSP-version performance. for large/complex files, it’s really slow on IDEA. Trying to write (inc "kikka")
into the end of malli.core
ns, takes 10sec just to echo the characters into screen.
file-watcher does this only on save, so handles it much better.
do you have any ideas on how to make the LSP-version work better?
I think it can be improved by borrowing some ideas from clojure-lsp, especially the implementation of incremental diffing. or you might want to try clojure-lsp altogether in Cursive, it uses clj-kondo so you would get that for free as well.
actually I wrote part of that diffing code in clojure-lsp ;) (not sure if that code is still used)
@ericdallo might have some ideas here
The code is here: https://github.com/clj-kondo/clj-kondo.lsp PRs are welcome
thanks. I would assume the LSP is on different thread and would not block the basic editor features. At least with clj-kondo, seeing result later is totally ok (different case with auto-complete etc)
true. clojure-lsp might already have that and it could be ported
I'd suggest test clojure-lsp on intellij and confirm if that issue happens
it's kind of worrying that the lsp plugin for intellij is "on hold" since a year ago
Yeah... @borkdude the grey feature is a thing on the LS server, the server can add a tag on the diagnostic telling that is unused, then the LS client grey the variable
https://github.com/clojure-lsp/clojure-lsp/blob/master/src/clojure_lsp/feature/diagnostics.clj#L32
In case you want to add that to clj-kondo.lsp
sure, PR welcome! I don't use the LSP plugin myself but I'm open to improvements for who do
hmm.. says classpath lookup failed in clojure-lsp
. tried to add brew-installed clojure-lsp
as the server.
Are you using the clojure-lsp official brew one?
➜ clojure-lsp --version
clojure-lsp 2021.07.01-19.49.02
clj-kondo 2021.06.18
Alright, check the clojure-lsp log file, you can set it with :log-path setting on .lsp/config.edn
don’t have that folder, will create
The lookup is directly related with clojure-lsp running lein classpath
or clojure -Spath
And the same for boot and shadow-cljs projects
2021-07-04T20:54:19.454Z UnknownHost INFO [clojure-lsp.crawler:236] - Automatically resolved source-paths from deps.edn: #{"src" "resources" "test"}
2021-07-04T20:54:19.971Z UnknownHost WARN [clojure-lsp.db:55] - Could not load db [SQLITE_ERROR] SQL error or missing database (no such table: project)
2021-07-04T20:54:19.972Z UnknownHost INFO [clojure-lsp.crawler:27] - Finding classpath via ` clojure -A:dev -Spath `
2021-07-04T20:54:19.979Z UnknownHost ERROR [clojure-lsp.crawler:38] - Error while looking up classpath info in /Users/tommi/projects/metosin/malli Cannot run program "clojure" (in directory "/Users/tommi/projects/metosin/malli"): error=2, No such file or directory
I do have clojure
available :thinking_face:
You need clojure installed
Hum for some reason it's not finding on your PATH or something
Never saw this kind of error
not sure how can I pass any PATH to LSP, copied clojure
executable to the directory, still doesn’t see that.
Yeah, that seems that won't help, could you try the non Graalvm binary?
Its available on GitHub releases page
As clojure-lsp
sure, didn’t start in 10sec, need to set the timeout.
Yeah, it'll take 5-10s to start I think
same thing.
So it's not a issue with clojure-lsp, probably something with your OS not finding Clojure command
I never saw anyone complaining about this error :/
What OS are you using?
macOS 11.4
pasted the error here: https://gist.github.com/ikitommi/f2cacfe5c389c4459a89f397342293c3
This is how clojure-lsp call that command: https://github.com/clojure-lsp/clojure-lsp/blob/master/src/clojure_lsp/crawler.clj#L32
It's a clojure.java.shell/sh
Feel free to open an issue, I'm out of suggestions ATM
btw 10 seconds linting is quite extreme, most files take just a few milliseconds
it was the non-graalvm-thing, slow startup.
I’ll write an issue, thanks both!
@ikitommi sure, but the startup should happen only once
per project
Not if the classpath scan didn't work @borkdude
Then clojure-lsp doesn't cache the analysis
I mean for clj-kondo.lsp
Oh, ok
clj-kondo.lsp doesn't use a classpath scan, unless you do that yourself from the command line
(currently, it might be something it could borrow from clojure-lsp in the future)
Oh, @ikitommi does /`Users/tommi/projects/metosin/malli` is the correct project root?
And that folder exists?
yes, exists
and copied clojure
there too just for making sure
it seems clojure
cannot be found? what do you get for which clojure
in the shell?
intellij/cursive might have an issue with passing through the PATH
, I've seen such an issue in #cursive before
or perhaps it's in the gtache plugin
➜ ~ which clojure
/usr/local/bin/clojure
➜ ~ clojure
Clojure 1.10.3
user=>
Oh, good point, it must be something with Intellij/cursive not using the correct PATH
perhaps you could use as the lsp plugin a bb script which spits out the PATH to a file and does nothing else
so you can inspect what it gets to see
@ikitommi I can try to setup Intellij later, what plugins for intellij are you using to setup clojure-lsp?
probably the gtache lsp plugin as documented in the clj-kondo docs
yes, this: https://github.com/gtache/intellij-lsp
🙇 *2
Almost sure it's a bug in that plugin, not configuring the PATH correctly
well, IntelliJ is a UI program which might not use the same PATH as bash or whatever?
at least it could find java
in the clj-kondo.lsp plugin
Yeah, maybe try to start Intellij from a terminal which has clojure on it