This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-02-08
Channels
- # announcements (14)
- # babashka (12)
- # beginners (140)
- # calva (2)
- # cider (22)
- # clj-commons (14)
- # clj-kondo (49)
- # cljdoc (34)
- # clojure (92)
- # clojure-europe (41)
- # clojure-france (2)
- # clojure-new-zealand (2)
- # clojure-nl (2)
- # clojure-norway (60)
- # clojure-uk (17)
- # clojured (2)
- # clojurescript (7)
- # community-development (3)
- # conjure (2)
- # cryogen (13)
- # cursive (4)
- # data-oriented-programming (2)
- # datahike (5)
- # datomic (12)
- # defnpodcast (10)
- # events (2)
- # fulcro (20)
- # gratitude (3)
- # honeysql (4)
- # introduce-yourself (3)
- # jobs (10)
- # lsp (58)
- # malli (12)
- # missionary (19)
- # off-topic (8)
- # pathom (18)
- # podcasts-discuss (1)
- # polylith (41)
- # releases (1)
- # remote-jobs (3)
- # shadow-cljs (52)
- # spacemacs (1)
- # sql (37)
- # xtdb (19)
Is there a way to know which config files have been loaded for a clojure-lsp process? I’m trying to determine whether the proper config files have been loaded (in the context of a monorepo with configs at multiple levels).
My scenario seems to be similar to the one described https://clojurians.slack.com/archives/CPABC1H61/p1643018024170800
That command is available for all clients, you just need to know how to call it from your client
My current solution to the problem is what borkdude described https://clojurians.slack.com/archives/CPABC1H61/p1643018141171800, but I was trying to figure out if I could have something smarter.
Have a clj-kondo config at project root with :config-paths, pointing to the submodules configs
Yeah, for lein mono-repo projects, this is the recommended for now: https://clojurians.slack.com/archives/CPABC1H61/p1643018184172800
> Have a clj-kondo config at project root with :config-paths, pointing to the submodules configs If I understand correctly, what I have now is the opposite. One shared config at the monorepo root and one config per-project pointing to the monorepo root via config-paths. Are you suggesting the opposite?
Both works, but I prefer to have specific on each submodule and just link from the project root as I mentioned
> specific on each submodule and just link from the project root as I mentioned
So, in a scenario with root config
, module a
and module b
, you have:
• module a
-specific config
• module b
-specific config
• root config
with config-paths
pointing to module a
and module b
• lsp root is set to the dir containing the root config
Is that right?
I do have .lsp/config.edn
at the monorepo root adding source-paths to sub-projects along with sub-project/.lsp/config.edn
files
I guess I’m confused by the interaction between lsp and clj-kondo and how each one defines the configs. I have to look that up first
Why you need to specify source-paths manually? clojure-lsp has a logic to find it automatically, isn't that working for your project?
I’m actually trying to figure that out right now (that’s why I asked about inspecting which config files were loaded). I figured I can use :LspInfo
from nvim-lsp to get the project root.
If I open a subproject file, I get the following:
Language client log: /Users/fuad/.cache/nvim/lsp.log
Detected filetype: clojure
1 client(s) attached to this buffer:
Client: clojure_lsp (id: 1, pid: 20845, bufnr: [1])
filetypes: clojure, edn
autostart: true
root directory: <path-to-sub-project-root>
cmd: clojure-lsp
Configured servers list: html, jsonls, cssls, tsserver, eslint, clojure_lsp
yeah, that sounds wrong, you need to configure vim to open the subproject with the root as the project mono-repo root
right, so I know I can do the following:
(defn opts [default-server-opts]
(a.merge default-server-opts {:on_attach on-attach
:root_dir (util.root_pattern ".git")}))
this would tell it to use .git
to detect the rootHey weah I would consider playing with root_pattern
cool. so, is it right to say that, in the context of a monorepo, it doesn’t make sense to have lsp configs at multiple levels?
I did read this in the docs
> clojure-lsp
will look for project specific settings in a file called `.lsp/config.edn`. It will search from your project root folder up the directory structure so you can have multiple projects share the same settings.
yes, it probably makes sense for some cases but we don't have support for that yet 😅
what we do here is something like this, with symbolic links (not the best tho)
and I always start vim from backoffice folder
since it has it's own deps.edn
@U3RBA0P4L check it out the config search logic https://github.com/clojure-lsp/clojure-lsp/blob/master/lib/src/clojure_lsp/config.clj#L58, we actually check for project-root and parents, I forgot about that 😅
so having multiple configs on sub-a and mono-repo, should work, but I don't remember the last time I tested or saw that work 😂
Right! So if I set the lsp root to the monorepo root, it does give me a different result when running :LspInfo
. The root config adds "source-paths"
for the sub-projects, but then I don’t know if it’s picking up the sub-projects’s lsp configs. My guess is no but I’ll try to confirm that.
cool! so our understanding is the same.
I’m not even sure we need configs at multiple levels, so
• if we need different configs at multiple levels
◦ we should prefer to pick up mono/sub/.lsp/config
and let clojure-lsp recurse up to get the parent one
• if we don’t need different configs at multiple levels
◦ we should prefer to pick up mono/.lsp/config
yeah, as my experience you may face other issues opening sub projects instead of the mono one, so I'd suggest using always the mono-repo one with one single config to avoid confusion
now, just for the sake of completeness, going back to the initial clj-kondo considerations: different clj-kondo configs per-project might be needed.
if I have a single clj-kondo config at the root with :config-paths
pointing to sub-projects, does that mean I can have different linting rules per project?
or does that mean I would have to go with the 1-config-per-project-each-one-pointing-to-the-root approach?
yes, the former should work, a config on mono-repo pointing to the subprojects ones
ok, so the bottom-up approach (which @UMMMKKADU also mentioned) works fine for me. however, I can’t get my setup to work with just one monorepo top-level clj-kondo config. lsp simply doesn’t pick it up. looking at this https://github.com/clojure-lsp/clojure-lsp/blob/fe232a719707258ee53d72bf44166d5149e6ee0b/lib/src/clojure_lsp/kondo.clj#L27-L30 I think it should just work since my lsp project root is the monorepo root
👋 > you need to configure vim to open the subproject with the root as the project mono-repo root I'd like to share that, afaik, VS Code can't be configured to open a subproject like this. You need to open the project root. And to be able to open the same project root in separate VS Code windows, you need to create separate workspaces and at the same project root folder to them.
I'm working in the same monorepo as @U3RBA0P4L, btw. 😃