lsp

karol.adamiec 2025-04-04T17:03:06.677809Z

hello, i have issue with lsp reference navigation in clojurescript. It very stubbornly tries to navigate into compiled folder that has cljs copied files. This is extremely frustrating as one can guess. I tried setting the ~/.config/clojure-lsp/config.edn with content:

{:paths-ignore-regex ["target.*"
                      "public/js/.*"
                      "js"
                      "ui/dev-resources/public/js/compiled/out/*"]
 :source-paths-ignore-regex ["public/js/.*"
                             "js"
                             "ui/dev-resources/public/js/compiled/out/*"]}
to stop lsp from traversing there, but to no avail. The lsp-find-reference is also showing the compiled folder results before the actually correct source. How can i proceed with this issue?

ericdallo 2025-04-04T17:12:31.815249Z

We had this problem multiple times in the past, and I think I solved adding the :source-paths-ignore-regex which the default value is ["target.*"] indeed to avoid your problem. Make sure you don't have any target file opened - clojure-lsp lint opened files in editor, if you open target file it will lint (although not sure if with the source-paths-ignore-regex setting it should ignore it anyway). Double check if your regex is correct, https://clojure-lsp.io/troubleshooting/#server-log the used source-paths when starting, check the server logs If that's it's not working yet, please make a small cljs project repo where the problem does happen so I can try myself and understand the problem

karol.adamiec 2025-04-04T17:35:14.537519Z

will do. Just for my own sanity check, as i go a bit crazy by now, the source path i land in, that i never actually want to see is:

~/dev/my-project/ui/dev-resources/public/js/compiled/out/ui/component.cljs
What would a regex to exclude it look like? And is this the source-paths or paths-ignore setting?

ericdallo 2025-04-04T17:43:20.711419Z

Let me check the config, it's been a while I don't look to that part of the code

karol.adamiec 2025-04-04T17:43:38.162749Z

Did a restart with config for lsp deleted and i get the same set of paths being read in, as per below message from server logs. Starts to look like the config files are not read in at all... Is there some easy way to make sure which config is read and that it indeed is processed? some trace/debug? or maybe just some simple and obvious setting that

2025-04-04T17:37:12.825Z  INFO [clojure-lsp.source-paths:85] - [Startup] Using source-paths from classpath: ["/Users/karoladamiec/dev/fortum/madhouse/dev-resources" "/Users/karoladamiec/dev/my-project/palantir-resources" "/Users/karoladamiec/dev/my-project/test" "/Users/karoladamiec/dev/my-project/dev" "/Users/karoladamiec/dev/my-project/ui/resources" "/Users/karoladamiec/dev/my-project/ui/dev-resources" "/Users/karoladamiec/dev/my-project/ui/src" "/Users/karoladamiec/dev/my-project/resources" "/Users/karoladamiec/dev/my-project/src"]

ericdallo 2025-04-04T17:44:23.982849Z

Can you try the config in .lsp/config.edn in the project root dir

ericdallo 2025-04-04T17:44:43.921739Z

The log for the config is a interesting suggestion we could add

karol.adamiec 2025-04-04T17:45:56.604249Z

ERROR [clojure-lsp.config:22] - WARNING: error while reading /Users/karoladamiec/dev/my-project/.lsp/config.edn (Map literal must contain an even number of forms)

karol.adamiec 2025-04-04T17:46:02.953069Z

ok, it does try to read it 😄

👍 1
karol.adamiec 2025-04-04T18:05:03.979499Z

2025-04-04T17:49:23.478Z  INFO [clojure-lsp.source-paths:85] - [Startup] Using source-paths from classpath: []
a small progress... but then an ignore path in the form of .compiled. for sure should exclude files like
~/dev/my-project/ui/dev-resources/public/js/compiled/out/ui/sections/component.cljs
even did repl test and it does match that path...
(clojure.core/re-matches #".*compiled.*" "~/dev/my-project/ui/dev-resources/public/js/compiled/out/ui/sections/component.cljs")
(clojure.core/re-matches #".*compiled.*" "~/dev/my-project/ui/dev-resources/public/js/c/out/ui/sections/component.cljs")

karol.adamiec 2025-04-04T18:27:23.860459Z

thanks, will take a peek there, maybe even run it with local debug to actually see what is going on.

👍 1
karol.adamiec 2025-04-04T18:29:21.562699Z

i have in my deps.edn following fragment:

:dev {:extra-paths ["dev" "dev-resources" "test" #_"ui/dev-resources"]
commenting out that extra path resolves the issue....

ericdallo 2025-04-04T18:30:19.540079Z

so the problem is indeed clojure-lsp considering that ui/dev-resources source-path, you must exclude the whole source-path

karol.adamiec 2025-04-04T18:31:28.122209Z

yeah... also, maybe irrelevant but it is clojure project with cljs subproject. that UI folder is having another deps.edn for the clojurescripty parts... if that makes sense

ericdallo 2025-04-04T18:32:08.408209Z

in the end for clojure-lsp is a single one, the used source-path by clojure-lsp is the truth

👍 1
karol.adamiec 2025-04-04T18:34:38.264819Z

is there some recursive reading of deps.edn having place in lsp server maybe? because in the ui/deps.edn we do again:

:extra-paths ["dev-resources"]

ericdallo 2025-04-04T18:35:26.540639Z

clojure-lsp simplify does clj -A:dev:test -Spath to get the source-paths, run that on the root and you will see the outcome

karol.adamiec 2025-04-04T18:38:22.330889Z

i see. out of curiosity, why dev and test aliases? we scan the deps to find used aliases? EDIT: i see it it the linked source file so nvmind :)

karol.adamiec 2025-04-04T18:40:06.961319Z

anyways, thank You very much Eric for your time. Will experiment a bit over the weekend. 🙇

ericdallo 2025-04-04T18:46:14.021009Z

no problem, LMK if you find any bug on that, but almost sure it's a regex issue or something

👍 1
karol.adamiec 2025-04-05T08:25:20.804229Z

ok, woke up this morning and i have reasonable take (i think) on what is going on. So the paths in questions are filtered as-is. I.e. the regex pattern is filtering the ACTUAL path strings returned by clj -A:dev:test -Spath and not their possible path tree expansions on disk. So one can filter based on strings returned from above call, but not on their subpaths that actually happen to exist. In any case, adding a regex that targets the actual values returned from above clj call helped in my case. Still have not run the debug of lsp server though to verify that is the case. But if it is, then i would guess this is not really how a layman thinks about this.... and is a bit confusing.

karol.adamiec 2025-04-05T09:30:10.827309Z

yeah, i confirmed this on debug session of clojure-lsp. @ericdallo so this is expected behaviour i guess?

karol.adamiec 2025-04-05T10:32:25.943829Z

so my current understanding is that the "source" variant of setting is loaded once on startup and is excluding the paths returned by clj -path command. It works with relative paths. The :path-ignore-regex is run basically on every feature all the time, but in it, the path is absolute and not relative, so the regex patterns used better be flexible in the beginning to accommodate for this. I.e i can not fathom how the default regex from documentation can work. my guess is it does not. ["target.*"] to be fair, that regex example is at the :source-paths-ignore-regex setting variant listed as default (and example by proxy i guess) so all is good in theory.

ericdallo 2025-04-07T13:25:28.194509Z

sorry I think I got a littlbe bit lost, can you elaborate the cases with examples? From my POV, :source-paths-ignore-regex should have regex to ignore source-paths dirs, like src/main/foo , and it should be relative to the project root. :path-ignore-regex indeed checks the full filename, maybe it should be relative too. Even so, why those features aren't enough to fix your problem?

👍 1
karol.adamiec 2025-04-07T14:20:02.472189Z

they are. they totally solve my problem. My mistakes were: • not understanding the difference in source-paths and paths • not understanding which parameter what "format" or "style" of path is working on.

ericdallo 2025-04-07T15:33:25.946779Z

makes really sense, I think we can mention that on the docs of those settings WDYT? willing to open a PR?

karol.adamiec 2025-04-07T15:46:09.430669Z

i think it would save me some time 🙂 Will prep a PR with some clarification around those settings, maybe with examples of what actually is matched by regex we write..

1
2025-04-04T17:57:18.712209Z

Is it possible to extend protocol function renaming to extend and extend-protocol and extend-type? I can rename a protocol function and get it changed at call-sites, but not in extend-* calls.

👍 1