Fork me on GitHub
#lsp
<
2022-06-07
>
frank20:06:17

Has anyone experienced an issue where go to definition for CLJS goes to the copy of the cljs file in the resources directory instead of src? I tried using :ignore-classpath-directories true in my config hoping it would help, but unfortunately it didn't work 😞

ericdallo20:06:59

Someone complained about it recently and I suggested ignore-classpath-directories, if it's not working, feel free to create a issue with detailed repro project

👍 1
borkdude20:06:21

Mine also went to target after calling clojure -T:build

borkdude20:06:39

I don't think clojure-lsp should add that to the classpath automatically. I think it might have happened because I also have project.clj in that project, but even then

ericdallo21:06:21

Yeah, I think the issue is, the classpath contains the target folder so clojure-lsp consider it as a source-path

ericdallo21:06:37

I don't know a way to know that is not a source-path

borkdude15:06:04

This is my config:

{:ignore-classpath-directories ["target"]}
And no matter how many times I restart lsp, it keeps navigating to that damn target dir

borkdude15:06:50

I think it's a good default to never put target on the classpath btw, I've never seen a Clojure project in which it was a source directory. But this config doesn't work

frank15:06:59

oh, I thought that setting was meant to be a boolean?

borkdude15:06:42

oh that's even more strange, since src is also on the classpath, why would I want to ignore that one

ericdallo15:06:28

could you paste your classpath here please? it's printed when clojure-lsp is starting on server logs

borkdude15:06:39

2022-06-09T15:45:03.903Z  INFO [clojure-lsp.db:70] - [DB] Reading transit analysis cache from /Users/borkdude/dev/cli/.lsp/.cache/db.transit.json db took 185ms
2022-06-09T15:45:03.936Z  INFO [clojure-lsp.crawler:160] - [Startup] Using cached db for project root /Users/borkdude/dev/cli
2022-06-09T15:45:03.938Z  INFO [clojure-lsp.source-paths:209] - [Startup] Using source-paths from classpath: ["/Users/borkdude/dev/cli/dev-resources" "/Users/borkdude/dev/cli/.build" "/Users/borkdude/dev/cli/target/classes" "/Users/borkdude/dev/cli/resources" "/Users/borkdude/dev/cli/src" "/Users/borkdude/dev/cli/src" "/Users/borkdude/dev/cli/test" "/Users/borkdude/dev/cli/test"]

ericdallo15:06:21

Alright, before that log, it should have a classpath string and the command clojure-lsp used right? probably /Users/borkdude/dev/cli/target/classes is on the classpath returned by lein/clojure

ericdallo15:06:36

so the target is on the classpath, that's the problem

ericdallo15:06:47

we would need to know some way to ignore that

borkdude15:06:01

I don't see anything before that

borkdude15:06:10

but ignore-classpath-dirs doesn't ignore it

borkdude15:06:23

the only thing that works is actually deleting the target dir

ericdallo15:06:51

I suspect ignore-classpath-dirs is broken since we started using source-paths from classpath

ericdallo15:06:08

and I don't know a proper way to fix it since the target comes from the classpath

ericdallo15:06:22

could you clojure -Spath or lein classpath ?

borkdude15:06:23

I think it's safe to always ignore target

borkdude15:06:52

I don't even want to use the classpath from lein btw, I just added a project.clj because I needed to deploy

ericdallo15:06:54

Not sure it's safe to ignore the source-path just because it includes target string

borkdude15:06:25

ok, but then maybe ignore-classpath-dirs should be configurable as a regex or so?

ericdallo16:06:15

I'll take a look soon, and try to make :ignore-classpath-directories-regex ["target"] possible, and probably with that value as default

👍 1
borkdude16:06:36

awesome! now to clojure meetup in Berlin :)

metal 1
ericdallo16:06:49

@U06M4ST0F do you have a simple project where I can test it while implementing it?

frank16:06:10

I think my case is a bit more complicated - I have resources in my path so I don't think ignore-classpath-directories would work for me

frank16:06:01

I'm going to try and work around by setting :source-paths

ericdallo16:06:45

but what you have inside resources? clojure code similar to target dir?

frank16:06:17

the clojurescript compiler is dumping cljs files into my resources/public/js/compiled

ericdallo16:06:21

if so, the suggested fix would work for you too right if you have something like :ignore-classpath-directories-regex [".*resources.*"]

ericdallo16:06:54

alright, so something like :ignore-classpath-directories-regex ["resources/public/js/compiled.*" "target.*"] seems to make sense as a default too

ericdallo16:06:45

If you could provide a sample repro, it'd help a lot to fix the issue on my side

frank16:06:45

OK, I'll try to put something together soon

frank16:06:57

Thanks for looking into this 🙂

👍 1
frank19:06:45

Ah, I just noticed this was fixed recently. Thank you so much! (and apologies for not getting around to setting up the repro)

borkdude19:06:28

I did run into this again today :( let's hope this was just a one time quirk

borkdude19:06:08

yeah, no, it wasn't fixed, I can reproduce the same problem again still

borkdude19:06:52

and I was editing a file in target for half an hour until I noticed I was editing the wrong file :(

frank19:06:31

My problem with resources seems to have gone away

borkdude19:06:32

hmmm, with lsp-clojure-server-info it seems emacs is picking up an older version

😌 1
borkdude19:06:43

sorry, then that's my bad

👍 1
borkdude19:06:47

@UKFSJSM38 Suggestion: add to the lsp-clojure-server-info which binary is currently being used? does it pick the one from the path automatically?

borkdude19:06:59

or does lsp-mode have a way to show this?

borkdude19:06:49

Problem seems to be gone now, now that I've fixed the setting

ericdallo19:06:56

Hum, not sure if from server side it's possible to know it's path, if not, we could maybe add it from lsp-mode, it'd just be a little trick to edit the edn on elisp

borkdude19:06:17

ok no problem, I got it fixed now