This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-07-10
Channels
- # announcements (3)
- # architecture (54)
- # babashka (11)
- # beginners (12)
- # calva (5)
- # clj-on-windows (1)
- # cljdoc (2)
- # cljs-dev (1)
- # cljsrn (6)
- # clojure (130)
- # clojure-europe (8)
- # clojurescript (21)
- # conjure (23)
- # core-async (4)
- # datomic (7)
- # depstar (77)
- # events (1)
- # fulcro (27)
- # lsp (88)
- # malli (5)
- # meander (1)
- # off-topic (4)
- # pathom (43)
- # polylith (39)
- # re-frame (9)
- # shadow-cljs (14)
- # timbre (3)
- # tools-deps (53)
I’ve recently started using clojure-lsp with CIDER and emacs. With CLJS “jump to definition” jumps to files in my /out
folder where figwheel outputs. I should probably tell lsp to not look into this directory…?
Thanks for a very quick response! If I set this, can I still jump into dependencies sources? :thinking_face:
I added a .lsp/config.edn
file into my project with this content {:ignore-classpath-directories true}
and restarted emacs but it still jumps to out/...
If it helps, my emacs config is stolen from Borkdude and jump to definition is defined like this
(defun find-definition ()
"Try to find definition of cursor via LSP otherwise fallback to cider."
(interactive)
(let ((cursor (point))
(buffer (current-buffer)))
(lsp-find-definition)
(when (and (eq buffer (current-buffer))
(eq cursor (point)))
(cider-find-var))))
But I think it’s using the lsp
functionality in this caseHere’s the project.clj
https://github.com/lipas-liikuntapaikat/lipas/blob/master/webapp/project.clj
Sorry I’ll have to jump away for a couple of hours but after that I’ll look into this again!
I can't make the project generate the out folder, I'm getting:
java.io.FileNotFoundException: /home/greg/dev/lipas/webapp/dist/index.bundle.js (No such file or directory)
during lein figwheel
Also, probably not related with your issue, but I maybe found another one, clojure-lsp is resolving this source-paths as Automatically resolved source-paths from project.clj: #{"test/clj" "src/cljc" "src/clj"}
, are you sure is not missing src/cljs
in your project.clj :source-paths? if this is intended, you can still tell to clojure-lsp use specific :source-paths in your .lsp/config.edn
Otherwise, some features may not work for your cljs files, like find-references
or find-definition
of a re-frame sub/event
Locally you need to install and bundle npm dependencies.
npm install
npx webpack
Then leing figwheel
should probably work
Alright, so you can fix it with :source-aliases clojure-lsp config, specifying the cljsbuild alias
Ok, cool. Now I’m using cider-jack-in-clj&cljs
so I get both repls. Should I have separate configs for backend / frontend from lsp point of view?
Ach.. Reading the docs and it looks like source-aliases
should just do the trick. I’ll give it a spin
Also, make sure you imported the project-root with lsp-mode on the webapp folder, not the root of the repo
You can confirm that with lsp-workspace-folders-remove and then lsp
and I
to import it manually
Hmmm I had both the project root and /webapp in workspace folders. That could’ve messed it up
Do I btw need to restart something after config changes or workspace changes or should it just be effective immediately?
Now I have only /webapp in workspace folders but still it jumps to /out. Looking at the logs now. Is there something particular you’re looking for or would you like me to dump the whole file here?
Hum, about the out issue not sure we will find anything useful on logs, it'd be better if I could repro here
> 2021-07-10T15:51:46.297Z Tipo INFO [clojure-lsp.crawler:244] - Using default source-paths: #{“src” “test”}
Did you do these steps already? https://clojurians.slack.com/archives/CPABC1H61/p1625931317335600?thread_ts=1625920732.330700&cid=CPABC1H61
Oh missed that msg, I'm not near the note right now, but I'll try to repro following those steps
Clojure-lsp should check the project.clj source-paths and resolve automatically, following the source-aliases setting
Hmm all my sources are under src/ and test/. out/ is under resources/something/something
Check here: https://clojure-lsp.github.io/clojure-lsp/settings/#source-paths-discovery
Hum, but from your project.clj the source-paths are others, you can check if the namespaces of your code match the source-paths
src
is not the same of src/cljc
for example, it may behave wrong as your namespace name would be my-project.foo
and not cljc.my-project.foo
Tldr, check the docs and try to use source-aliases and on last case if that doesn't work, source-paths settings on config.edn
I have this in my .lsp/config.edn
:source-aliases #{:dev :test :cljsbuild}
Should I see some mention about :cljsbuild
in logs?
the source-aliases should point to a alias that has a source-paths keyword in your project.clj
I just tried grepping all the clojure-lsp.xxxxxx.out
files with cljsbuild and no hits
Found this in one of the logs > [37mcom.oracle.svm.core.posix.thread.PosixJavaThreads.pthreadStartRoutine[m [32m PosixJavaThreads.java: 192[m > [37mcom.oracle.svm.core.thread.JavaThreads.threadStartRoutine[m [32m JavaThreads.java: 553[m > [37mjava.util.concurrent.ForkJoinWorkerThread.run[m [32mForkJoinWorkerThread.java: 183[m > [37mjava.util.concurrent.ForkJoinPool.runWorker[m [32m ForkJoinPool.java: 1594[m > [37mjava.util.concurrent.ForkJoinPool.scan[m [32m ForkJoinPool.java: 1656[m > [37mjava.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec[m [32m ForkJoinPool.java: 1020[m > [37mjava.util.concurrent.ForkJoinTask.doExec[m [32m ForkJoinTask.java: 290[m > [37mjava.util.concurrent.CompletableFuture$AsyncSupply.exec[m [32m CompletableFuture.java: 1692[m > [37mjava.util.concurrent.CompletableFuture$AsyncSupply.run[m [32m CompletableFuture.java: 1700[m > [33mclojure-lsp.main.LSPTextDocumentService/reify/[1;33mget[m [32m main.clj: 187[m > [33mclojure-lsp.handlers/[1;33mcode-actions[m [32m handlers.clj: 248[m > [33mclojure-lsp.feature.code-actions/[1;33mall[m [32m code_actions.clj: 281[m > [33mclojure-lsp.refactor.transform/[1;33mfind-other-colls[m [32m transform.clj: 26[m > [33mrewrite-clj.zip/[1;33msexpr[m [32m zip.cljc: 237[m > [33mrewrite-clj.zip.base/[1;33msexpr[m [32m base.cljc: 72[m > [33mrewrite-clj.node.protocols/[1;33msexpr[m [32m protocols.cljc: 49[m > [33mrewrite-clj.node.seq.SeqNode/[1;33msexpr*[m [32m seq.cljc: 19[m > [33mrewrite-clj.node.seq/map-node/[1;33mfn[m [32m seq.cljc: 142[m > [33mclojure.core/[1;33mapply[m [32m core.clj: 667[m > [37m...[m [32m [m > [33mclojure.core/[1;33mhash-map[m [32m core.clj: 381[m > [33mclojure.core/[1;33mhash-map[m [32m core.clj: 389[m > [37m...[m [32m [m > [1;31mjava.lang.IllegalArgumentException[m: [3mNo value supplied for key: source-aliases[m
This is my config.edn
{:ignore-classpath-directories true
:source-aliases #{:dev :test :cljsbuild}}
I can try to fix it soon, meanwhile you can use the source-paths LSP config manually
Yep, this is not a showstopper for me now. 🙂 But thanks a ton for looking into this!
Started creating minimal repro but now I can’t repro it even with the original repo. 😄 Jump to definition works like a charm. Tried even removing :ignore-classpath-directories
but it still works as it should after emacs restart. I’m a bit confused but happy.
I’ll be working tomorrow with the large project and I’ll investigate more if/when the problem manifests again. Also if I have time I’ll still try backtrack all the things we tried earlier today and see if there was something that actually made it work.