This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-12-06
Channels
- # adventofcode (54)
- # announcements (3)
- # babashka (34)
- # beginners (38)
- # calva (27)
- # cherry (5)
- # clj-kondo (34)
- # clojure (26)
- # clojure-bay-area (4)
- # clojure-berlin (3)
- # clojure-europe (26)
- # clojure-india (6)
- # clojure-nl (1)
- # clojure-norway (54)
- # clojure-uk (2)
- # conjure (3)
- # cursive (4)
- # data-science (1)
- # emacs (6)
- # events (4)
- # fulcro (2)
- # hugsql (6)
- # hyperfiddle (38)
- # lsp (3)
- # matrix (1)
- # membrane (5)
- # off-topic (27)
- # re-frame (3)
- # releases (1)
- # sci (8)
- # shadow-cljs (34)
- # squint (132)
Why Calva is struggling with handle formatting hash-maps that contains namespaced keywords? Even if they were commented.
For example,
{:foo {:bar ::baz
:batman :foz}}
If you read the formatting docs, it says that the format and align command uses an old version of cljfmt that was patched to do the vertical alignment and that it is unsupported -- so I suspect the "old version of cljfmt that was patched" predates the more common usage of namespaced keywords that came in with Spec in Clojure 1.9 (despite it being supported for ages before that).
Ok, I've done some research on this. Basically, the answer is here https://calva.io/formatting/#about-aligning-associative-forms
There is a PR on cljfmt about fixing alignment. https://github.com/weavejester/cljfmt/pull/299 As late as Oct 20, James Reeves says it is hight on hist priority list.
Cross post from beginners...
Today I re-cloned a project in a new directory, hopped into Calva, and tried to start a Leiningen+Shadow REPL, but I got some errors about JS things not found. Well, I had neglected to "npm install" before using Calva; there was no node_modules. Can I configure the "npm install" to be done automatically?
Maybe there is some extension that does this. Calva does not have any such extension points. Though, there is custom command line for jack-in. So you if you use that you can do whatever you like.
Hello! Can anyone help me with this error?
Request workspace/executeCommand failed.
Message: Internal error
Code: -32603
[object Object]
It occurs when I try to add a require via quick fix suggestion.I don’t know what it could be about. I saw that @U9A1RLFNV filed a similar issue https://github.com/BetterThanTomorrow/calva/issues/2354 Maybe @UKFSJSM38 knows what Code: -32603 could mean?
I'm not sure if those are related, aside from being internal clojure-lsp errors. I suspect the issue I filed is something Calva is doing wrong, but I'm not sure.
@U05H1PF60G1 You might find more info in the clojure-lsp server logs that could help @UKFSJSM38 to troubleshoot.
@U0ETXRFEW Our facilities for helping the user open the log file or see its path seem to be broken, at least for me on MacOS. I created this related issue: https://github.com/BetterThanTomorrow/calva/issues/2364.
2023-12-06T19:22:28.758Z INFO [clojure-lsp.handlers:475] - :code-actions 87ms
2023-12-06T19:22:28.877Z INFO [clojure-lsp.handlers:475] - :code-actions 3ms
2023-12-06T19:22:29.070Z INFO [clojure-lsp.handlers:502] - :semantic-tokens-full 1ms
2023-12-06T19:22:29.739Z INFO [clojure-lsp.handlers:385] - :clojuredocs-raw 0ms
2023-12-06T19:22:29.739Z INFO [clojure-lsp.handlers:385] - :clojuredocs-raw 0ms
2023-12-06T19:22:29.937Z INFO [clojure-lsp.handlers:475] - :code-actions 1ms
2023-12-06T19:22:30.099Z INFO [clojure-lsp.handlers:302] - :document-highlight 0ms
2023-12-06T19:22:30.362Z INFO [clojure-lsp.handlers:475] - :code-actions 1ms
2023-12-06T19:22:32.580Z ERROR [clojure-lsp.server:55] - Error receiving message: Internal error (-32603)
{:id 6808, :method "workspace/executeCommand"}
com.oracle.svm.core.posix.thread.PosixPlatformThreads.pthreadStartRoutine PosixPlatformThreads.java: 211
com.oracle.svm.core.thread.PlatformThreads.threadStartRoutine PlatformThreads.java: 832
java.lang.Thread.run Thread.java: 1583
java.lang.Thread.runWith Thread.java: 1596
java.util.concurrent.ThreadPoolExecutor$Worker.run ThreadPoolExecutor.java: 642
java.util.concurrent.ThreadPoolExecutor.runWorker ThreadPoolExecutor.java: 1144
java.util.concurrent.CompletableFuture$AsyncSupply.run CompletableFuture.java: 1768
promesa.util.Supplier/get util.cljc: 34
promesa.exec/wrap-bindings/fn exec.cljc: 163
clojure-lsp.server/fn/fn server.clj: 396
clojure-lsp.handlers/execute-command handlers.clj: 422
clojure-lsp.handlers/refactor handlers.clj: 397
clojure-lsp.feature.refactor/call-refactor refactor.clj: 194
...
clojure-lsp.feature.refactor/fn refactor.clj: 37
clojure.core/apply core.clj: 671
...
clojure-lsp.feature.add-missing-libspec/add-require-suggestion add_missing_libspec.clj: 493
clojure-lsp.feature.add-missing-libspec/add-known-alias add_missing_libspec.clj: 255
clojure-lsp.feature.add-missing-libspec/add-to-namespace add_missing_libspec.clj: 241
clojure-lsp.feature.add-missing-libspec/add-to-namespace* add_missing_libspec.clj: 124
rewrite-clj.zip.subedit/subzip subedit.cljc: 76
java.lang.AssertionError: Assert failed: could not create subzipper.
zloc'
2023-12-06T19:22:32.588Z INFO [clojure-lsp.handlers:475] - :code-actions 6ms
Thank you. Here are the clojure-lsp logs. I'm using via wsl (ubuntu).https://github.com/clj-commons/rewrite-clj/blob/main/src/rewrite_clj/zip/subedit.cljc#L76 It's failing on this line. Maybe @UE21H2HHD can help.
Is it hard to add a feature to sort map keys or sequence values alphabetically in the code? Example:
Sort sequence:
have:
:exclusions [d a c b]
want:
:exclusions [a b c d]
Sort map keys:
have:
:deps {d _d
a _a
c _c
b _b}
want:
:deps {a _a
b _b
c _c
d _d}
I gave deps.edn situations as examples but it applies to many more situations and the most annoying part is when values or keys are multiline, so I can’t resort to sorting lines.I don’t think it’s too hard. But maybe we should check with #CPABC1H61 if they think it belongs there first.
I don’t know if you know, but you can move map key value pairs with alt+up/down
. For manual sorting.
If it's a small map, I tend to reorder manually with alt+up/down
since it knows to move pairs not individual items.
If it's a larger map, I temporarily add a newline before the first key and after the last value and use the Sort Lines
command, then tab
to restore formatting.
In theory you could also wrap the map like so:
(into (sorted-map) '{d _d
a _a
c _c
b _b})|
(Cursor at |
)
Then do ctrl+alt+c r
, (evaluate and replace with result).I think that in practice, you might run into issues with pretty printing and namespaced keys stuff.
That already exists in clojure-lsp, a command/code action called Sort clauses: https://clojure-lsp.io/features/#clojure-lsp-extra-commands
Haha, indeed. I just tried it. In Calva this shows up as quick-fixes. Sort map, etcetera.
This is awesome! I didn’t know Quick Fixes existed!
I guess a nice to have in Calva would be to sort a selected portion of a map or a vector as sometimes things are organized by themes but should be sorted within the theme. Current workaround would be to temporarily wrap selected portion in a map, or a vector, sort it, and then remove the temporary wrapping.