Fork me on GitHub
#lsp
<
2022-11-29
>
seancorfield01:11:22

After various threads here asking for help with our somewhat non-standard monorepo structure (having all the actual source code one level down in the repo) and getting LSP and clj-kondo to play nice in the VS Code/Calva context (workspace root is the parent of the source code folder), today we bit the bullet and lifted all the Clojure code up to the top-level of the monorepo, so we were able to simplify our LSP/clj-kondo/Calva project setup (and now we can run "everything" in the repo root instead of needing (cd clojure && ..) for so many things!). So I wanted to say a big thank you to @ericdallo @borkdude @pez and several others who have been very patient with me here 🙂

gratitude 4
metal 2
polylith 1
clj-kondo 1
clojure-lsp 1
calva 1
❤️ 1
ericdallo02:11:30

Thank you! awesome, that's really nice to know!

grav14:11:20

I've got some cargo-culted lsp config in my neovim config (not restricted to clojure only, but applied for all servers):

root_dir = util.root_pattern(".git"),
Is this a good thing? Could it be a problem for some languages? Or some project structures? Should I aim for more specific configuration? Eg per language or per project?

grav14:11:24

I believe it originates from the fact that I was working with a mono-repo that had several (clojure) projects in subdirs. Apparently that was a problem for clojure-lsp specifically, but I'm not sure if this is a good general solution for other languages/projects.

ericdallo14:11:36

Not sure about nvim as I don't have experience with that (maybe #C0DF8R51A people may know more about it) clojure-lsp supports a global config in ~/.config/clojure-lsp/config.edn , maybe that would help you?

grav14:11:24

@ericdallo Thanks! Reading https://clojure-lsp.io/settings/, I don't see any way of changing the project root, though. Would this at all be needed in case of a mono-repo, or is Clojure-LSP able to handle multiple sub-projects in subfolders somehow?

grav15:11:22

(again, my reference is Cursive, which is not very convention-driven, but needs more manual config)

ericdallo15:11:30

the project-root is provided by the client, nvim in this case, from server side, we support only deps.edn and lein-monolith mono-repos

👍 1
ericdallo15:11:55

could you share a little bit more about your mono-repo? how is the project structure and core files?

grav15:11:17

Well, I'm still considering how to configure it, but I imagine it's something like

|- my-monorepo
 |--- frontend/deps.edn
 |--- backend/deps.edn
 |--- shared-lib/deps.edn
where shared-lib might contain some cljc files referred to from other projects

ericdallo15:11:52

got it, so, clojure-lsp repos itself it's pretty similar to that :)

ericdallo15:11:21

for that work smoothly, I suggest somethings to help any tool and clojure-lsp understand the repo better, which is: have a root deps.edn inside my-monorepo

grav15:11:30

I didn't know that the client supplies some of the configuration - that's interesting. I haven't managed to find a lot of docs on neovim's lsp client, but maybe I just wasn't looking the right place 🙂

ericdallo15:11:46

#C013B7MQHJQ does something similar to help understand all subprojects and deps

ericdallo15:11:55

I probably should write a page on clojure-lsp docs about that

ericdallo15:11:08

so you could open your mono-repo as the project root, and clojure-lsp would consider all subpojrects deps and build a classpath for the whole thing via clj -A:dev:test -Spath which is the default classpath command it runs

grav15:11:56

ah, okay, didn't know that a :dev alias had a special meaning - is that a clojure-lsp thing or a more general convention?

ericdallo15:11:16

totally a convention

ericdallo15:11:29

lein has the same, but it's a little bit more magical

grav15:11:40

hehe, yeah i'll believe that 😉

grav15:11:55

thanks for the pointers @ericdallo!

ericdallo15:11:08

https://clojure-lsp.io/settings/#classpath-scan should help a lot understand that better

👍 1
ericdallo15:11:25

you're welcome, LMK if that works

👍 1