Fork me on GitHub

When I add an end-of-line comment, I’m sort of used to the cursor hopping to the comment-column. Is there a way to do this in calva? I looked at cljfmt but didn’t see anything obvious. I had this behavior in emacs years ago, and in Cursive recently. So if I type

(async/>!! tea-channel :cup-of-tea-5) ;
It would turn into
(async/>!! tea-channel :cup-of-tea-5)              ; 
with the semicolon on a predefined column, out of the way. The comments would line up nicely in the same column. Not a big deal, just wondering if I missed something.


It's funny, that was always something I hated about Emacs doing that and I much prefer Calva's approach of putting the end of line comment exactly where I type it!


There is something to be said about that. What I’d really prefer is something like M-x ; to add an end-of-line (“margin”) comment, so it wouldn’t jump over all the time. It’s not really a high priority though, even for me I tend to have comments at the top of blocks. While learning though, I use the end-of-line comments as notes to myself.


There is no way to do that in Calva, that I’m aware.


I was exploring the and found that F12 (Goto Definition) lists two definition points for some functions. There are two points are for the same function, one is the line above the function and the other is line with the function defn itself. So far I’ve only seen it in this codebase, so it could be something there, like using .cljc. Or is this something I’ve done wrong?


Here I hit F12 on the (add-messages) call and got two add-messages listed, but they’re both the same function.


You’d have to be on add-messages on core.clj:291. It happens with lots of functions, but not all of them.


Do you have a repl connected when you go to definition?


If not, then that is clojure-lsp returning results, I think.




I just opened the project without doing anything to start a repl. I saw the double method problem. Then I looked for processes starting with “lein”, I found one (quite long path) and killed it. The double method problem went away! Then I started a repl myself, and the problem still isn’t there.


So maybe this is indeed a repl that calva uses? Is that what you mean by clojure-lsp?


In any case, I’ll try to cut it down to a reproducible test case


It does say

Calva is utilizing cider-nrepl and clojure-lsp to create this VS Code experience.
  nREPL dependencies configured:
    nrepl: 0.8.3
    cider-nrepl: 0.26.0
    cider/piggieback: 0.5.2
 clojure-lsp version configured: latest
in the Output window when starting.


I changed the file into a .clj (from .cljc) and F12 works now, without other changes. Even with the behind-the-scenes repl running. This makes calva work amazingly well, not as clunky as before. If I rename the file back to .cljc the problem comes back. It doesn’t happen at first, only after I see the “Connected to nREPL.” message popup. So maybe this is something to do with clojure-lsp and .cljc files?


@U9A1RLFNV Got it, I can easily reproduce it with this small archive: just one project.clj and one core.clj file. Just open it, wait for all of calva to be ready, open core.clj, stand on (doubleme) and hit F12. The popup will show up.


Hmm I can’t reproduce it. I just tried with that project and my cursor goes to the definition of doubleme and no popup appears.


You are not starting a repl, right? What do you mean by “wait for all of Calva to be ready”? Do you mean including waiting for clojure-lsp to finish starting (a startup message appears in the status bar while it’s starting)?


What’s your OS?


Actually, what might be best to know is what clojure-lsp is returning. Info on how to see the messages is here:


If you want, with the message logging enabled, reproduce the issue and then copy the logs and paste them into a new issue on GitHub, explaining the problem there too. We can continue troubleshooting there.


“wait for all of Calva to be ready” = I noticed three phases: 1) nothing happens when I hit F12, 2) when I hit F12 it goes directly to the function without a popup, and then 3) eventually a popup gets in the way when I hit F12. The whole process takes maybe 3 minutes on my old system

👍 1

OS = OS X, Big Sur


I’ll check into viewing the logs and create an issue

👍 1

Doh! Again! I had the Clojure extension installed.


Aha! Glad you found the issue!


Does Calva take over the Match Bracket functionality of vscode? I've put the following in settings.json

"workbench.colorCustomizations": {
      "editorBracketMatch.background": "#f008",
      "editorBracketMatch.border": "#f00"
And I see the new colors in say a JSON file, but in CLJ files I see something more subtle.


Maybe you can get away with setting calva.highlight.matchBracketStyle to null (I haven’t tried). See for the settings available:


Doesn't seem to work. No worries, no big deal, if I ahve some time I might try to submit a patch 🙂


It’s probably that bracket matching is made unconditionally. We should add a setting for that, I think.

Michael W14:12:25

I have added a .clj-kondo/config.edn to my repo, but calva does not seem to read it for linting. The forms I added to be linted as def or defn are still showing problems in calva. Is there a special way to get calva to read my clj-kondo config?


You might need to reload the VS Code window, I’m not sure how dynamic this is. Do you know @U9A1RLFNV, @UKFSJSM38?)


Probably the deps need to be re-scanned


if your lint-as applies to an external library

Michael W14:12:38

Restarting everything from scratch I still see lint problems I would expect to be resolved from my config. Any way to see output from clojure-lsp on what config it is using for clj-kondo?


You can also try to lint from the command line to see if that works


yes, use server-info command, there is a vscode command for that


changing kondo config for your project code should work, it's not needed a restart

Michael W14:12:14

I have defsc-form set to lint as defn, and that seems to work, I don't have the line under the name, but I would expect it to see the AccountForm there as a resolved symbol, since it should think it's a function name, right?


yes, sounds lke a wrong kondo config, could you paster you config?

Michael W14:12:11

 {mount.core/defstate                                      clojure.core/def                                             
  com.fulcrologic.fulcro.components/defsc                  clojure.core/defn                                            
  com.fulcrologic.rad.form/defsc-form                      clojure.core/defn                                                       clojure.core/defn                                            
  com.fulcrologic.fulcro.routing.dynamic-routing/defrouter clojure.core/defn                                            
  com.fulcrologic.rad.authorization/defauthenticator       clojure.core/defn}} 

Michael W14:12:28

that's in .clj-kondo/config.edn in the repo.


you should receive this automatically into your .clj-kondo folder


if you're using the newest fulcro version


and then add :config-paths ["com.fulcrologic/fulcro"] to your config

☝️ 1

can you show what is in your .clj-kondo folder with:

ls -la .clj-kondo


@U04V15CAJ maybe this is a reason to auto consider imported config paths right? we were talking about that some other day

Michael W14:12:44

λ tree
├── com.fulcrologic
│   └── fulcro
│       ├── com
│       │   └── fulcrologic
│       │       └── fulcro
│       │           └── clj_kondo_hooks.clj
│       └── config.edn
├── com.wsscode
│   ├── async
│   │   └── config.edn
│   └── pathom
│       └── config.edn
└── config.edn

Michael W14:12:08

I've just set :config-paths and am restarting everything to see if it makes a difference


yes, so adding the above to your config should fix all linting issues with fulcro

Michael W14:12:49

Still the same thing, AccountForm from my screenshot still shows as an unresolved symbol.

Michael W14:12:20

λ cat .clj-kondo/config.edn
{:config-paths ["com.fulcrologic/fulcro"]}


@U0522TWDA Do you know what's going on here?


is that com.fulcrologic.rad.form/defsc-form?

Michael W14:12:39

It's also happening the same for com.fulcrologic.fulcro.components.defsc a bit further down from that screenshot.


then somehow your config isn't being used. you can make a repro repository for this problem

Jakub Holý (HolyJak)14:12:36

that is weird because it works just fine on other projects such as - could you try that one? Also, does it also fail when linting from CLI? Running clj-kondo --lint . in this repos gives some warnings about unsued imports but that is all. Defsc works fine

Jakub Holý (HolyJak)14:12:46

So I would suggest: 1. Try running kondo from the CLI as I did above; if that still errors => 2. Check out the backendless repo and run kondo from CLI there

Michael W14:12:13

Running from the CLI seems to work ok, I am not getting the warning about AccountForm as in my screenshot.

🎉 1

BTW @UAB2NMK25 instead of restarting you can do any change to the file to clojure-lsp re-lint that file with kondo after you change the kondo config, insted of restarting it.

Michael W14:12:06

So it's like the calva/clojure-lsp is not reading my config.edn


yeah, do you do need to make a change to a file to trigger linting


Also, make sure you are using a correct project root


Have you opened the correct directory in VSCode and not a parent directory of your project? This is a common problem

Michael W14:12:14

Yeah I start it with 'code .' from the top level directory of the repo


and .clj-kondo is also in the top level dir of the repo?


I'm running out of ideas but you can still follow Jakub's suggestion of trying the demo repo


@UAB2NMK25 can you make a simple repro where we can see and debug the code?

Michael W14:12:30

Yeah I think I can just put this entire repo up, I'm barely into it but my intention is to release under MIT.


just release without a README, then nobody will use it ;)

😂 3
Michael W14:12:06

I can't do much with it till tonight, I can't work on it during work hours, I'll get a repo up tonight and update this thread.

Michael W14:12:33

The minimalist-fulcro-template-backendless repo lints correctly.

Michael W17:12:38

Ok so it appears this template I used as a base puts everything under src/dev and src/main. If I add a config.edn to src/main/.clj-kondo it is picked up for the files under src/main. With that extra main directory it seems clojure-lsp is restricting clj-kondo in some way so it does not use the config from the base of the repo.


yes, I think we could improve that on clojure-lsp side, but for now it's only possible having a config.edn on the project-root

Michael W17:12:28

That is the template I used, and when I load up a clone it is doing the same thing for me here.


@UAB2NMK25 I can't see any .clj-kondo/config.edn on this template with the :config-paths @U04V15CAJ mentioned

Michael W17:12:34

Yes I added those in .clj-kondo/config.edn


IMO we should add to this template as well c/c @U0522TWDA

👍 1
Michael W17:12:57

If I add a :lint-as to src/main/.clj-kondo/config.edn then it works, but anything in main does not get the clj-kondo config from the root of the repo.

Michael W17:12:52

On my app I swapped datomic for xtdb and have that working well, everything is great except the linting.


what is the project root? it should be on <repo>/.clj-kondo/config.edn


why do you add src/main/.clj-kondo?

Michael W17:12:28

I just tried it to see if it solved the problem

Michael W17:12:35

How do I see the project root?

Michael W17:12:23

I opened vscode in the root of the repo, the root of the repo is the top of the tree in my explorer

Michael W17:12:34

I think clojure-lsp added src/main/.clj-kondo, that directory existed and I just added the config.edn with a lint for defstate to test.


so it's correct, now the config should go on <repo>/.clj-kondo/config.edn


if clojure-lsp added that folder, is because it was setted as project root


clojure-lsp creates a .clj-kondo folder if not exists in the specified project-root sent by the client (calva), that sends the root opened on vscode

Michael W17:12:10

Ok so at some point I must have opened vscodium in that directory

Michael W17:12:31

I deleted src/main/.clj-kondo and src/main/.lsp and it's working now.

👍 1

I can't see why it was not working because of the presence of those folders on src/main :thinking_face:

Michael W17:12:39

Yeah that's tricky

Michael W17:12:03

I just made sure I only have 1 .lsp and 1 .clj-kondo in the whole repo tree and it's working now.


Currently, Calva does not explicitly send the root to clojure-lsp. But maybe we should. We keep a notion of projectRoot that is mostly used for the REPL things. I’m not sure if this is the right root to use. As we fall back on the folder root we would anyway be sending src/main if vscode was opened there.

Michael W17:12:45

It's really easy to open vscode in the wrong dir from a terminal and if that stops the config from working it's confusing.

Samuel McHugh15:12:40

Looks like there has been a lot of discussion recently. Just wanted to heads up that for me the latest release of Calva doesn’t automatically create balanced parens. That is to say that typing ( produces ( whereas before it would have produced () .


It’s probably your settings that was borked by the previous release. Check the User settings json file and remove anything like

From the [clojure] scope. That should give you back the defaults.

Samuel McHugh15:12:16

that did it thanks!

🙏 1
Pepijn de Vos10:12:30

Huh what happened?