This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-12-06
Channels
- # adventofcode (106)
- # aleph (1)
- # announcements (1)
- # asami (14)
- # babashka (120)
- # beginners (54)
- # calva (106)
- # chlorine-clover (33)
- # clj-kondo (5)
- # cljdoc (3)
- # cljs-dev (3)
- # clojure (92)
- # clojure-android (1)
- # clojure-australia (2)
- # clojure-europe (24)
- # clojure-italy (3)
- # clojure-nl (5)
- # clojure-uk (16)
- # clojuredesign-podcast (1)
- # clojurescript (29)
- # code-reviews (58)
- # conjure (16)
- # core-logic (4)
- # cursive (9)
- # datalevin (2)
- # graphql (20)
- # gratitude (7)
- # jackdaw (11)
- # java (9)
- # jobs (2)
- # lsp (23)
- # minecraft (1)
- # missionary (28)
- # off-topic (5)
- # polylith (5)
- # react (1)
- # reagent (12)
- # releases (1)
- # remote-jobs (4)
- # reveal (7)
- # shadow-cljs (8)
- # slack-help (1)
- # tools-deps (11)
- # vim (6)
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.
I was exploring the https://github.com/unclebob/spacewar 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.
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.
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)?
Actually, what might be best to know is what clojure-lsp is returning. Info on how to see the messages is here: https://calva.io/clojure-lsp/#viewing-the-logs-between-the-client-and-server.
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
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: https://calva.io/highlight/
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.
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?)
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?
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?
{:lint-as
{mount.core/defstate clojure.core/def
com.fulcrologic.fulcro.components/defsc clojure.core/defn
com.fulcrologic.rad.form/defsc-form clojure.core/defn
com.fulcrologic.rad.report/defsc-report clojure.core/defn
com.fulcrologic.fulcro.routing.dynamic-routing/defrouter clojure.core/defn
com.fulcrologic.rad.authorization/defauthenticator clojure.core/defn}}
actually fulcro already has a clj-kondo config: https://github.com/fulcrologic/fulcro/blob/develop/src/clj-kondo/clj-kondo.exports/com.fulcrologic/fulcro/config.edn
@U04V15CAJ maybe this is a reason to auto consider imported config paths right? we were talking about that some other day
λ tree
.
├── com.fulcrologic
│ └── fulcro
│ ├── com
│ │ └── fulcrologic
│ │ └── fulcro
│ │ └── clj_kondo_hooks.clj
│ └── config.edn
├── com.wsscode
│ ├── async
│ │ └── config.edn
│ └── pathom
│ └── config.edn
└── config.edn
I've just set :config-paths and am restarting everything to see if it makes a difference
Still the same thing, AccountForm from my screenshot still shows as an unresolved symbol.
@U0522TWDA Do you know what's going on here?
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
that is weird because it works just fine on other projects such as https://github.com/holyjak/minimalist-fulcro-template-backendless - 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
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
Running from the CLI seems to work ok, I am not getting the warning about AccountForm as in my screenshot.
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.
Have you opened the correct directory in VSCode and not a parent directory of your project? This is a common problem
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?
Yeah I think I can just put this entire repo up, I'm barely into it but my intention is to release under MIT.
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.
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
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
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.
On my app I swapped datomic for xtdb and have that working well, everything is great except the linting.
I opened vscode in the root of the repo, the root of the repo is the top of the tree in my explorer
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.
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
I can't see why it was not working because of the presence of those folders on src/main :thinking_face:
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.
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.
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
"editor.formatOnType"
"editor.autoClosingBrackets"
"editor.autoClosingOvertype"
"editor.formatOnPaste"
From the [clojure]
scope. That should give you back the defaults.Huh what happened?