This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-11-29
Channels
- # adventofcode (9)
- # announcements (2)
- # aws (78)
- # babashka (55)
- # beginners (97)
- # biff (9)
- # calva (11)
- # cherry (2)
- # cider (8)
- # clerk (7)
- # clj-kondo (6)
- # clj-on-windows (4)
- # clojure (213)
- # clojure-austin (6)
- # clojure-europe (63)
- # clojure-nl (1)
- # clojure-norway (5)
- # clojure-spec (10)
- # clojure-uk (1)
- # clojurescript (14)
- # clr (2)
- # community-development (3)
- # conjure (14)
- # datomic (2)
- # deps-new (5)
- # dev-tooling (10)
- # editors (3)
- # emacs (3)
- # etaoin (19)
- # events (4)
- # fulcro (71)
- # holy-lambda (20)
- # java (3)
- # jobs (2)
- # leiningen (4)
- # lsp (24)
- # malli (15)
- # membrane (107)
- # music (1)
- # off-topic (29)
- # pedestal (4)
- # polylith (1)
- # portal (2)
- # rdf (5)
- # releases (7)
- # scittle (5)
- # shadow-cljs (8)
- # tools-build (15)
- # tools-deps (6)
- # xtdb (13)
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 🙂
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?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.
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?
@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?
(again, my reference is Cursive, which is not very convention-driven, but needs more manual config)
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
could you share a little bit more about your mono-repo? how is the project structure and core files?
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 projectsfor 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
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 🙂
but https://github.com/clojure-lsp/clojure-lsp/blob/master/deps.edn#L2-L5 that will make thinks work
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
ah, okay, didn't know that a :dev
alias had a special meaning - is that a clojure-lsp thing or a more general convention?
thanks for the pointers @ericdallo!
https://clojure-lsp.io/settings/#classpath-scan should help a lot understand that better