Fork me on GitHub
#calva
<
2021-08-25
>
Artem04:08:00

Hi folks! I’m trying to set up a multi-root workspace with Calva, as suggested by the second option here: https://calva.io/workspace-layouts/. Jack-in works as advertised but clojure-lsp always runs for the topmost root regardless of which root I’m in or which root I’m jacked into. Is this expected behavior?

pez06:08:54

Can you describe your layout a bit more?

Artem13:08:29

Sure thing! I’m working with a monorepo that contains a bunch of different services and libraries. I started with an empty window and then added a bunch of project roots (each with its own project.clj) to the workspace. As a result, only the first project root that I added (fwiw it’s also first alphabetically) has a .lsp dir and whenever I look at the LSP status, it points to that root. I typically work on just one service at a time but often need to search other services sources so I hoped that I could keep them all in one window. I hope this helps with clarifying things a bit.

bringe03:08:09

Hmm, so what would you prefer happen? Would a command that tells clojure-lsp to run for a specific project suffice? Currently clojure-lsp is enabled by default and operates at the top level. I think it may be possible to, with some work, make it so that: a. Clojure-lsp can be set to not start up upon project opening b. A command allows you to specify a project root for clojure-lsp @UKFSJSM38 Does b (above) sound possible?

bringe03:08:15

For now, the only thing I know of that you can do to make clojure-lsp work for the project you want it to is to open only that project in a VS Code window. Then, you can open all the projects in another window to reference them. It may not be as convenient, but at least you'd have the clojure-lsp support in the project you're working in.

Artem04:08:21

Ideally clojure-lsp would support multiple projects in one session :) for example, Cursive has no problem with recursively finding all the projects in that repo and figuring out their dependencies, classpaths and such. Second best would be switching LSP root on jacking in. If I’m jacking into a project, it’s a clear signal that I’m working on it r/n. In addition to that, a separate command to start LSP would probably be useful, especially if someone does not use Calva’s jack-in

pez05:08:52

It's roughly 30/70 between jack-in/not-jack-in use.

pez05:08:31

We really do want clojure-lsp to be at service w/o the REPL. Can we help lsp by using a deps.edn at the top level that ”assembles” classpaths?

ericdallo12:08:22

ATM clojure-lsp doesn't support multiple workspaces/roots, not sure it'd be easy to add that support, but it works good for projects on project root like polylith, besides being one proccess only consuming resources, not multiple. So, I suggest plugin-in on the top-level with a deps.edn on the top-level (just like lein-monolith and polylith) with proper paths configured, this should make most things work

🙏 3
👍 3
bringe15:08:24

> Ideally clojure-lsp would support multiple projects in one session I should have been clear that it does not in my previous response, so my suggestions were in lieu of that. But yes, that is ideal. Hopefully Eric and Pez's suggestion works for you in the meantime.

ericdallo15:08:26

Yes, there is a issue for multi.root support, although It would need quite a refactor, it'd be a good addition

👍 12
Artem03:08:32

> open only that project in a VS Code window. Then, you can open all the projects in another window to reference them. yeah, this is what I’ve been doing. With the exception that for the latter I’m just running Cursive in parallel 🙂 That wastes a lot of RAM, but the search is much faster and nicer than in VS Code and there are some IDEA’s Git integration features that I haven’t found a good alternative to in VS Code yet.

Artem03:08:24

overall, I now prefer Calva to Cursive for several reasons: • performance/stability (Cursive feels very slow, freezes up regularly, and is constantly throwing errors in IDEA’s log) • clj-kondo integration. Our project is perpetually broken in Cursive due to many custom macros that don’t map onto defaults. With clj-kondo, I was able to add hooks for most of them and now I get correct usage and refactor behaviors. • Calva’s default formatting is our project’s formatting. Something I wasn’t able to match in Cursive with any amount of time spent tuning it. pretty happy with my setup already. Great job folks! 🙂

calva 21
❤️ 12
henrik4208:08:29

Hi. Im using "Calva: Connect to a Running REPL Server in the Project" with "deps.edn" project type. For the connection I always get "localhost:4005" as default. Is there a way to supply other/more options? Like "my-remote-docker-host:14005"?

pez08:08:40

localhost is pretty hardcoded in there. 😃 Please file an issue about it. Maybe one way to solve it would be if Calva just remember the last host used and offers that as a default?

Célio15:08:46

Does anyone have problems with Calva not picking up deps aliases from ~/.clojure/deps.edn? My aliases don’t show up in the list when I do jack-in (`ctrl-opt-c` ctrl-opt-j).

pez15:08:56

We all have that problem. 😃 Calva doesn’t read that file. (Maybe it should.) You can tell Calva about these aliases using the the (undocumented facepalm) setting calva.myCljAliases.

Célio15:08:17

I’m glad I’m not the only one having that issue 😅 Thanks so much, I’ll check that out.

Célio15:08:21

Yep, that solves the problem 🙌

👍 3
Pratik15:08:52

Do we have a load all files capability in calva? sometimes while repling in to remote server, I find it hard to do some debugging and find and load all the relevant files

pez15:08:04

The closest you can get is to load some files with a lot of requires.

Pratik16:08:16

ok, is it feasible to add this feature?

pez16:08:21

I don’t know, actually. Please file a feature request and we can assess the feasibility.

Pratik16:08:30

sure, I will file an issue, cider has this feature if I am not wrong

pez16:08:16

If it has then this is entirely feasible. 😃

pez16:08:16

New Calva release just out, friends! 2.0.210. It should fix the issues with starting full-stack REPLs deps.edn + shadow-cljs.

calva 15
🎉 15
Artem03:08:24

overall, I now prefer Calva to Cursive for several reasons: • performance/stability (Cursive feels very slow, freezes up regularly, and is constantly throwing errors in IDEA’s log) • clj-kondo integration. Our project is perpetually broken in Cursive due to many custom macros that don’t map onto defaults. With clj-kondo, I was able to add hooks for most of them and now I get correct usage and refactor behaviors. • Calva’s default formatting is our project’s formatting. Something I wasn’t able to match in Cursive with any amount of time spent tuning it. pretty happy with my setup already. Great job folks! 🙂

calva 21
❤️ 12