Fork me on GitHub
#calva
<
2022-06-02
>
orestis04:06:26

Not sure if this has been discussed before, I arrived at my computer being warm to the touch, and I found a few rogue clojure-lsp + Electron processes consuming CPU. I very often "Reload Window" to fix the buggy neovim plugin, but it seems this might be leaving processes hanging? The only way to fix was to manually kill the rogue lsp process, and then disabling/enabling Calva to fix the Electron issue.

orestis04:06:41

I will keep an eye on this in the future, and see if I can deduce a pattern

seancorfield04:06:59

I have run into this occasionally but I have not been able to figure out what causes it... I only tend to Reload Window when I need to update extensions... but I keep VS Code running for days (sometimes weeks) and reload a few times a week...

orestis04:06:37

One curious thing I found is having 3 electron processes with a copy of clojure-lsp each under it. Under normal circumstances there's a top level Electron process with a single Clojure-lsp.

pez05:06:37

Not seen this. But also haven't been on the look. I reload window tens and more times a day, so if this is the cause I have a good chance to see it.

orestis06:06:37

Does your laptop have fans @U0ETXRFEW? Mine doesn't so the only tell is actually that it's getting warm. When it's docked on my desk I don't really notice. I noticed this morning as I flipped the screen on and it felt unusually warm.

pez06:06:05

Yes, it has fans. I've only ever heard them run once, since I got the machine. I have the computer on my lap all the time and it never goes warm. Right now I have 9 VS Code windows I open. I see tons of Electron processes. But they are all grouped under 9 main Electron processes. I see 10 clojure-lsp processes running, 9 of which are grouped under each main Electron process. The 10th is owned directly by Code, has a total of 0 CPU time and consumes only 273Kb of memory. My computer is rather freshly rebooted (some 2 weeks ago) and I restarted VS Code yesterday (after having run it w/o restart since the computer reboot). I very seldom restart VS Code. Only to upgrade it.

pez06:06:21

I also have 11 java processes. 5 of which are under the Code Helper (Renderer) process running my work project, where I have five different shadow-cljs processes running. (It's a monorepo and I work with a library serving several of the projects there.)

orestis06:06:37

I just opened a new VSCode window, in a Node.js project. It shows up as a separate Electron process, which has a clojure-lsp child. It shouldn't have though, why is it starting a clojure-lsp process in a Node.js workspace? There's a clojure file buried within a subdirectory, could that be the case?

pez06:06:01

What kind of Clojure file is it?

pez06:06:29

Are you running latest Joyride?

orestis06:06:25

It has a .clj extension - but there's no deps.edn or anything like that on the workspace. Yes, I'm running the latest Joyride (I restarted VSCode this morning so presumably it's got the new versions). I can of course disable Calva and Joyride in the workspace...

pez06:06:58

You can disable clojure-lsp in the workspace.

orestis06:06:54

Hm, how can I do that? No worries though, this is a legacy pure JS project that I experimented in adding a browsertest in Clojure, but it never went anywhere, so I'm happy disabled Calva/Joyride inside that workspace.

pez06:06:59

It's Joyride starting Calva since yesterday. Or rather the user_activate.cljs script.

pez06:06:36

There's a setting for clojure-lsp auto-start.

pez06:06:33

Calva doesn't by itself autostart unless it find one of there:

"workspaceContains:**/project.clj",
    "workspaceContains:**/shadow-cljs.edn",
    "workspaceContains:**/deps.edn",

pez06:06:59

Or, when you open a Clojure file.

orestis06:06:03

Cool, so it's joyride that's starting Calva. One less mystery 😄 I'll keep an eye to see if this happens again.

pez06:06:44

It's the default user_activate.cljs script. <-important distinction.

orestis06:06:09

Ah. I'll see about that, I haven't had a chance to update my scripts to the new goodies.

pez06:06:14

Yesterday's change changed the activation scripts to be named user_activate.cljs and workspace_activate.cljs. So your activate.cljs files are not being run on startup, and you're running with the default user activation script. The workspace one is not installed automatically, but you can install it from the Joyride: Run Workspace Script... menu. Here in a workspace where I haven't done that and thus the old activate.cljs script there is demoted to a regular script.

Sakib12:06:09

I'm doing the exercise from http://clojurekoans.com/. How can jack-in, run the exercise and evaluate form?

zakkor13:06:02

I just lein koan run rather than jacking in

Sakib13:06:45

In that case I don't get a REPL. I want to do the exercise and also have a REPL so that I can play around.

Luke Johnson01:06:00

According to the https://github.com/functional-koans/clojure-koans, you can start your REPL like any other leiningen printed with lein repl. Then you can jack in with your editor of choice.

bringe01:06:22

If you want to use Calva for this and evaluate forms from the editor, you can clone the clojure-koans repo, then open it with VS Code, then run Calva’s jack-in command. Once connected you can evaluate forms from the editor. I’m not really familiar with clojure-koans, but trying to evaluate a whole form that uses the meditations macro does not work for me. I don’t know if there’s something that needs to be changed in the code to make that evaluation work. But you can evaluate the individual forms within the meditiations form.

skapoor13:06:32

Has anyone here used talon + https://github.com/cursorless-dev/cursorless with Calva for voice coding in Clojure?

Robert A. Randolph13:06:46

I have not used Cursorless, but I do use talon+calva and talon+emacs

skapoor13:06:17

Okay, I use Talon + Calva too but have only created a few custom commands so far. Plan to add more. Was exploring cursorless but it doesn't play very well.

Robert A. Randolph13:06:36

I find using a Vim mode to be extremely well suited to Talon personally

skapoor13:06:18

Okay.. any recommendation for a vim mode for VsCode? Found https://marketplace.visualstudio.com/items?itemName=vscodevim.vim but if there's something that you find works well with Calva.

Robert A. Randolph13:06:52

That's what I use, and I've changed nearly all my calva shortcuts so it works fairly well.

skapoor14:06:10

Cool, will check this out.

bringe01:06:49

I’m not a vim user but you might find this page in Calva’s docs useful: https://calva.io/vim/

olaf23:06:17

Hi, using Calva I found that the default indentation for functions call use 1 space instead of 2 spaces. I quickly passed the docs and read a bunch of issues but didn't find a way What it does by default is

(time-log
 (format "print time"))
instead of
(time-log
  (format "print time"))
Didn't find anything also in the Calva settings

seancorfield23:06:22

1 space is idiomatic Clojure so this seems right to me for function calls.

seancorfield23:06:01

(well, that and the next section)

olaf23:06:36

right, I think the entire team used some different config with Emacs 😞 How can I then disable automatic indentation, and just indent the single form?

Luke Johnson01:06:09

If all the code is formatted the same, it's likely your team uses a formatter like cljstyle to keep things consistent. Search the repo for cljstyle or cljfmt to get a better idea.

👍 1
pez04:06:02

There might be a cljfmt configuration in the project. If so you can use that with Calva.

pez06:06:59

Check out https://calva.io/formatting/ At the end of that page there is an example config that will format all function calls to 2 spaces. (It will also not care about ”hanging” indents and such, which might or might not be what is used in the team. The point is that you might be able to get Calva to format things according to the project's style.)

🙌 1
olaf06:06:06

Sorry, for the late reply. No there's no cljfmt configuration unfortunately. I will maybe ask the team about the formatting standard. Thanks @U0ETXRFEW!

pez06:06:07

Cool. I'm curious about what the project is using for standardizing formatting. Mostly for my orientation around what's in practice out there.

olaf06:06:22

ok I found a script with lein-cljfmt "0.6.4" inside and default configuration. Not sure if has been run recently. Most of them use doom emacs+cider so I suspect parinfer-rust to be the default for that

pez07:06:33

Wouldn't parinfer-rust also be configurable around the formatting to use? What do you mean with ”default configuration”? That there is no cljfmt config in the script, or that there is one? Is it a Leiniggen project? (If so, sometimes the cljfmt config is inside project.clj).

olaf05:06:01

Sorry, I missed your reply. I just found this script into the project

#!/bin/sh

export RUN_CMD_PROFILE="$(cat <<EOF
{
  :plugins [[lein-cljfmt "0.6.4"]]
  :cljfmt {

  }
}
EOF
)"

if [ -z "$1" ]; then
  cat "$RUN_CMD_DIR/desc"|tail +2
  exit 1
fi

exec lein with-profile +run cljfmt "[email protected]"
that's it. No other formatting configuration found 😐😞

olaf07:06:57

And yes is a Leiningen project