Hello.
When I create a new Clojure file in my monorepo project, the top-level alias is missing from the automatic namespace.
E.g. A new file created in monorepo/cool_project/services/email/core.clj , a deps.edn file is at the root (`monorepo/deps.edn`), and the auto-generated namespace is (ns services.email.core) (missing cool-project. ).
It’s annoying, but only annoying. It’s not breaking anything. I just have to manually add cool-project. to the front of the new namespace.
Is there a setting that I can change to assist clojure-lsp in getting it correct?
I’m running the latest Calva with lsp version 2024.08.05-18.16.00 but this annoyance has been happening for years.
We’re using a non-standard build tool and I start my REPL with a Java command, which isn’t helping the situation, I’m sure.
Kind of unusual not to have src in the path somewhere. Is your classpath ["."] instead?
I suspect LSP assumes that the top-level folders in the repo are the classpath roots, rather than the entire repo -- but I think you should be able to configure LSP to match your unconventional structure... have you checked the config docs for LSP?
I have looked through the documentation, but couldn’t find an answer. Fortunately, we have a great and helpful community so I thought I’d finally ask.
I tried switching {:source-paths #{"cool_project"}} for {:source-paths #{"."}} in my .lsp/config.edn and it seems to have fixed my issue! Creating a new file had the correct namespace declaration!
Thanks for the suggestion, Sean!
I wonder if revealing the other ~20 top-level directories in this monorepo will cause performance issues. 🤔
I wouldn't expect it to, any more than have ~20 subdirs under src in a regular project structure.
FWIW, we have 160+ subprojects in our Polylith monorepo and LSP does okay with that...
Nice! I’ll roll with this change for a bit then! Thanks again, Sean!
Glad I was able to point you in the right direction -- I couldn't remember the config details, only that it was possible 🙂
(our codebase is about 146k lines, spread across those 160+ subprojects, BTW)