Fork me on GitHub
#emacs
<
2022-06-27
>
lukasz15:06:43

I have a big, big git repo with multiple Clojure projects. Is there a way to make projectile and clojure-lsp aware of the individual (sub) projects? Right now both use the root of the git repository as project root and that messes many things up. I found some documentation about how projectile discovers projects but it's not obvious how to configure it. My google-fu is failing me, and what I'm finding is not really helpful 😢

rolt15:06:07

you can put a .projectile file at the root of your subproject. For lsp it worked out of the box for me, my sub projects all have a project.clj file

lukasz15:06:37

I'd rather not store any special files in the repo, other people on my team use different editors - I thought project auto discovery can be configured somehow

rolt15:06:51

i think the git repo takes priority, but maybe it's configurable. Also you can just add the .projectile file to your global gitignore

lukasz15:06:48

Yeah, that could work. I've seen that that docs page and suggested changes didn't seem to work, but it might have been me doing something wrong - I'll give it another shot :thumbsup:

rolt16:06:54

even if you swaitch projectile-root-bottom-up and projectile-root-top-down ? what's your "project specific file" ?

ericdallo16:06:19

you can use lsp-workspace-folders-remove and lsp to remove and add a project

ericdallo16:06:43

fixing projectile is not enough if you have lsp-mode thinking your project root is still the mono-repo root, so you need to do this ☝️

lukasz16:06:29

90% of it is project.clj rest would be either package.json or Gemfile - all of them are part of projectile's default setup. And yeah, the order is (projectile-root-bottom-up projectile-root-local ...top-down....) I'll try the .projectile file approach

lukasz16:06:09

@UKFSJSM38 ah, I didn't realize that lsp doesn't rely on projectile, then again - wouldn't it scan for project.clj in the same fashion as projectile?

ericdallo16:06:35

lsp-mode always guess the project root and prompt with a suggestion, but you can manually choose a different folder

lukasz16:06:05

Must be something about my config because I only see a warning about 4000+ files being indexed :-)

ericdallo16:06:10

that's lsp file watchers warning which can be customized as well

ericdallo16:06:28

lsp-workspace-folders-remove and lsp should help with configuring properly

lukasz16:06:50

Thanks, I'll give it a go :thumbsup:

rolt16:06:49

you may have misread the doc: in your case you'd want projectile-root-local projectile-root-top-down projectile-root-bottom-up projectile-root-top-down-recurring but this may not play well with some other projects, so i'd use .dir-locals or .projectile anyway

lukasz17:06:30

oh, I'll try that later :thumbsup: thx

lukasz20:07:26

@U02F0C62TC1 ok, that did it for me, at least wrt projectile itself. Thanks!

Chris Clark17:08:00

I also have this problem in monorepos. I wrote up my solution, using way too many words, here: https://www.cfclrk.com/articles/projectile_root.html. I’d be interested in better ways to do this.