Fork me on GitHub
#polylith
<
2021-11-26
>
Stefan09:11:25

Not sure which channel I should post this, but I’m guessing people in this channel have experienced and solved the issue I’m having. In my polylith repo clojure-lsp (via Calva) doesn’t seem to work properly. New files don’t get the (ns …) form, references are not found until the target files are opened in the editor, things like that. I found https://github.com/clojure-lsp/clojure-lsp/issues/416 and https://github.com/clojure-lsp/clojure-lsp/pull/445, which suggest that this should work. I tried creating a .lsp/config.edn at top level to see if that helps, but that didn’t seem to make a difference. What am I missing? Thanks!!!

furkan3ayraktar12:11:05

I’m mentioning @U0ETXRFEW in case he has an idea about this

pez12:11:07

Thanks! I think this is mostly a question for @UKFSJSM38 (who probably, like me, has already been alerted to it 😃). It might very well lead to requests on Calva, we had a similar discussion in another thread. (And I have Better monorepo support high up on my todo-list.)

ericdallo12:11:31

I think polylith should work unless we introduced a bug somewhere, I can test with a sample polylith project later today and confirm jt

Stefan12:11:36

Thanks @UKFSJSM38, much appreciated!!

seancorfield18:11:13

@UGNFXV1FA FWIW, this has never worked for me, nor does Calva's jump between source and test functionality, but we've never been able to repro outside of our repo at work -- it works in "simpler" repos just fine.

seancorfield18:11:50

One "quirk" of our repo at work is that the Clojure code is all in a subfolder of the main repo so we have wsmain/.lsp but the Polylith workspace is centered on wsmain/clojure/deps.edn -- although, again, in a repo that seems similar to that structure, things appear to work just fine.

seancorfield18:11:10

I'd suggest trying to create a minimal repo where you can see this problem and put them up on GitHub to see if we can debug things. I'm definitely curious about this problem too (although the addition of (ns ...) is of such little value to me since I want to add a copyright header etc anyway).

☝️ 1
Stefan18:11:11

Thanks @U04V70XH6 I can certainly try to reproduce, I’ll get back. (The ns thing was just one example indeed; especially the incorrect references is not helpful.)

Stefan07:11:25

I have setup a repo that reproduces the described issues for me: https://github.com/svdo/polyrepro. If you have some time it would be great if you could verify that you experience the issue as well in that setup. Thanks!!

pez07:11:39

Nice name!

pez07:11:50

Can we device tests of clojure-lsp alone here somehow. See if we can isolate it to what should be changed in Calva.

ericdallo14:11:30

@UGNFXV1FA I found the issue on clojure-lsp, It works for https://github.com/furkan3ayraktar/clojure-polylith-realworld-example-app because all source-paths are on the root deps.edn, so clojure-lsp find correctly via its default dev and test aliases:

ericdallo14:11:07

It doesn't work for your sample though, clojure-lsp only find this source-path:

ericdallo14:11:58

because clojure-lsp doesn't scan nested deps.edn of polylith projects, is that really common? I could try to support that somehow but I'd need to know when should we seek for nested deps.edn and the correct rules for polylith projects

ericdallo14:11:27

would it be enough to support :local/root deps.edn scans on :extra-deps and :deps on deps.edn root and aliases?

ericdallo17:11:53

@UGNFXV1FA I'm implementing support for :local/root search following ☝️ and it's fixes your issue on your sample :) I'll polish a little more and do more tests and let you know, I created this issue to track that: https://github.com/clojure-lsp/clojure-lsp/issues/652

Stefan18:11:06

That’s awesome @UKFSJSM38!! Yes, I think it makes sense for it to work like that; after all, :local/root dependencies are sources that you want to know about while developing, so taking them into account makes sense. gratitude

👍 1
seancorfield19:11:45

@UKFSJSM38 That is the issue that Cursive has with Polylith too -- it can't find source via :local/root -- which is why the Polylith docs says to use :extra-paths as a workaround for that. But the "right" way is to use :extra-deps with :local/root deps for the bricks (`bases` and components).

seancorfield20:11:02

So I'm really glad to see LSP support this, thank you!

ericdallo20:11:55

Good to know! Yeah, I cannot see any issues checking nested :local/root so I think there is no reason besides complexity why clojure-lsp/cursive can't check that. Probably fixing that should fix other mono-repos support as well 🤞

seancorfield20:11:20

I wonder if that might also fix the switch between source and test files in Calva or whether that's an unrelated bug?

ericdallo20:11:02

what feature is that? 😅 maybe is something vscode specific?

seancorfield20:11:31

It probably is. I think the code is pure Calva and doesn't lean on anything from LSP. It was mostly a joke on my part, sorry.

😅 1
👍 1
ericdallo20:11:43

Fixed on clojure-lsp master! If anyone wanna test it before the next release (couple of days), you can just run make on clojure-lsp to generate a dev clojure-lsp binary.

ivangalbans18:11:06

nice Eric! gratitude

👍 1
Stefan07:11:18

@UKFSJSM38 Now running clojure-lsp from master, and I can confirm that it works for me too. Super-happy and grateful! 🙂

ericdallo12:11:59

Good to know, thanks @UGNFXV1FA

Stefan16:11:10

cmd-period > “Add require ’[…]” 🎉 Love you @UKFSJSM38 :)

pez17:11:12

Get in line, @UGNFXV1FA. I also love @UKFSJSM38!

calva 1
ericdallo17:11:45

haha thank you both !