lsp

seancorfield 2025-10-21T18:19:04.879269Z

Looks like the nightly builds are broken -- Calva downloads but cannot start the nightly LSP: [Trace - 2:01:55 PM] Sending request 'initialize - (0)'. [Trace - 2:02:35 PM] Received response 'initialize - (0)' in 39918ms. Request failed: Internal error (-32603). [Error - 2:02:35 PM] Server initialization failed. Message: Internal error Code: -32603 [object Object] [Error - 2:02:35 PM] Clojure Language Client client: couldn't create connection to server. Message: Internal error Code: -32603 [object Object]

borkdude 2025-10-23T16:06:43.215019Z

https://github.com/clojure-lsp/clojure-lsp/pull/2142

seancorfield 2025-10-21T18:19:26.992809Z

I've reverted to latest instead and that works fine.

borkdude 2025-10-21T18:20:48.541509Z

any other stacktraces?

ericdallo 2025-10-21T18:20:57.648119Z

oh not really, there is a exception happening

ericdallo 2025-10-21T18:21:05.444509Z

it may be related with the clj-kondo bump, let me check the logs

borkdude 2025-10-21T18:21:16.189699Z

😨

ericdallo 2025-10-21T18:21:30.773719Z

clojure.lang.ArityException: Wrong number of args (3) passed to: clj-kondo.impl.config/ns-groups
java.util.concurrent.ExecutionException: clojure.lang.ArityException: Wrong number of args (3) passed to: clj-kondo.impl.config/ns-groups

borkdude 2025-10-21T18:21:42.980749Z

ah, from which file?

ericdallo 2025-10-21T18:21:48.739769Z

humm I recall we are calling that from clojure-lsp

borkdude 2025-10-21T18:22:03.771879Z

oh really. well, it's not a public function so I warned you ;)

ericdallo 2025-10-21T18:24:40.253559Z

this is a backwards compatible code for the unused-public-var linter

borkdude 2025-10-21T18:24:40.436089Z

I guess you can copy paste the old version.

ericdallo 2025-10-21T18:24:54.825109Z

let me check

borkdude 2025-10-21T18:25:07.622379Z

but note that I optimized this function so you may want to do the same

ericdallo 2025-10-21T18:25:42.080779Z

hum yeah, for now I will copy the previous one

ericdallo 2025-10-21T18:25:56.652649Z

doesn't look simple to optimize on lsp side

borkdude 2025-10-21T18:26:29.221029Z

copy the previous one. for the other function from clj-kondo.IMPL.config you can use the public API: clj-kondo.core/merge-configs

borkdude 2025-10-21T18:26:43.968349Z

;-)

ericdallo 2025-10-21T18:27:44.485649Z

done! testing local

borkdude 2025-10-21T18:29:17.656389Z

btw it's pretty easy to optimize using memoize, but I restricted memoization per run! invocation so you don't get any memory leaks

ericdallo 2025-10-21T18:29:38.747329Z

makes sense, I may optmize with a simple memoize too

ericdallo 2025-10-21T18:30:20.880449Z

Pushed the fix, should be available soon @seancorfield

👍🏻 1
borkdude 2025-10-21T18:32:31.301279Z

I don't know how many times setting-for-ns is called, but if it frequently then optimizing is certainly worth it

👍 1
borkdude 2025-10-21T18:33:45.900179Z

looks like it is called almost for every var

borkdude 2025-10-21T18:33:51.199319Z

in the unused-public-var linter

ericdallo 2025-10-21T18:34:01.400979Z

yes, indeed

borkdude 2025-10-21T18:36:36.814919Z

this is my version of re-find memoized:

:re-find-memo
                 ;; memoized version of re-find that takes a pattern string and a match string
                 ;; regex creation is cached
                 ;; matches on regex are cached
                 #_{:clj-kondo/ignore [:discouraged-var]}
                 (let [re-pattern-memo (memoize re-pattern)]
                   (memoize (fn [pattern-str file-str]
                              (re-find (re-pattern-memo pattern-str) file-str))))
Note that I cache both regex creation regex matching. Also note that re-find-memo takes two strings rather than a regex + string

borkdude 2025-10-21T18:37:55.520509Z

and then I use this version of re-find in ns-groups. which is why I needed the extra argument

ericdallo 2025-10-21T18:39:14.716299Z

interesting

borkdude 2025-10-21T18:39:49.087449Z

you could define a global version of this, but I'm fearing that it will eat up memory over time

borkdude 2025-10-21T18:40:24.719669Z

or you could just factor our the usage of ns-groups from your functions so you only call it once per namespace or so

borkdude 2025-10-21T18:40:53.941029Z

instead of per var

ericdallo 2025-10-21T18:42:25.088029Z

we could memoize per ns I guess, that's the best we could do without too many changes

borkdude 2025-10-21T20:32:19.670249Z

@ericdallo cljfmt has a new version + feature: https://mastodon.social/@weavejester/115414031176979588

dominicm 2025-10-21T20:43:49.311639Z

Eric already had a message about it in an issue 😄 machinations are underway.

ericdallo 2025-10-21T21:01:21.357619Z

Ah yeah, I was following that issue for some years hehe glad it was done! Will bump it

borkdude 2025-10-21T21:01:42.476999Z

which issue was it?

ericdallo 2025-10-21T21:02:30.898559Z

On mobile rn, but it was the vertical alignment feature

borkdude 2025-10-21T21:03:02.031179Z

https://github.com/weavejester/cljfmt/issues/36

ericdallo 2025-10-21T21:05:26.246989Z

It's not everyday you see a 11y issue fixed :) awesome

ericdallo 2025-10-21T21:06:45.206749Z

Ah yeah, that one too :)

ericdallo 2025-10-21T21:07:43.817379Z

@borkdude any plans for kondo release? Im thinking of cutting a new LSP one in the following days

borkdude 2025-10-21T21:09:08.281379Z

yeah, I want to work on some issues Thursday

👍 1
borkdude 2025-10-21T21:09:14.554659Z

and then doing a release probably

ericdallo 2025-10-21T22:09:29.983819Z

clojure-lsp Latest clojure-lsp nightly bumps cljfmt supporting vertical map/let alignments a feature asked for a long time! Kudos @weavejester Personally I'm don't like to vertical align hehe but it's good to have this option now!

🎉 4
ericdallo 2025-10-21T22:10:09.590039Z

@pez that may be a good addition to calva, I don't recall if calva has workarounds to make that feature work, if so, you can maybe consider relying on cljfmt only now 🙌

pez 2025-10-22T05:42:17.566639Z

I think this means we can get rid of the copy of an old fork of cljfmt we use in Calva for this today.

👍 1
weavejester 2025-10-22T17:27:28.758589Z

@pez, @ericdallo you may also be interested in the realign-form function that I've just added to cljfmt 0.15.2. This function will take a rewrite-clj parsed form and aligns the columns of just that structure - so it won't recurse down and align the children's columns as well. This could be potentially useful for a code action of some kind.

weavejester 2025-10-22T17:29:21.483489Z

As an example, if realign-form is called on this map:

{:x {:aaa 1
     :b 2}
 :yyy 3}
It'll realign to:
{:x   {:aaa 1
       :b 2}
 :yyy 3}
Note that the child map is not automatically aligned.

ericdallo 2025-10-22T17:29:27.440039Z

for sure! would be nice to have 2 code actions for that: • Align vertically this formDes-align vertically this form (?) the other way around

ericdallo 2025-10-22T17:30:14.088399Z

I see myself wanting the latter one personally, like see a vertically aligned code and want to change to not be aligned like that

weavejester 2025-10-22T17:31:50.089009Z

Ah, I didn't think of doing it the other way. I guess that's just a case of removing all non-indenting consecutive spaces. I'll add a unalign-form function tonight or tomorrow.

ericdallo 2025-10-22T17:38:08.242939Z

exactly! I mean, this whole vertical alignment feature is really polemic, each person has its own tastes, so I think we should give both options, align or not, convert or not

weavejester 2025-10-22T17:40:05.387399Z

I can honestly see myself using both. I tend to align into columns only when there won't be too much whitespace (i.e. when the key lengths are similar).

ericdallo 2025-10-22T17:43:03.307119Z

yeah, I can see how convenient it may be for some cases!

mpenet 2025-10-22T20:31:01.988899Z

:remove-multiple-non-indenting-spaces? does essentially that no?

👍 1
weavejester 2025-10-22T20:31:40.992779Z

Yes, but recursively.

mpenet 2025-10-22T20:31:43.467219Z

I am also not a fan of vertical alignment and I had great success normalizing codebases with that option :)

weavejester 2025-10-22T20:57:54.263079Z

Glad to hear it! In this case, unalign-form would be a non-recursive option for removing vertical alignment for a single form via a tool like Clojure LSP, Calva, CIDER, etc. The use case is for people who might want to align some forms but not others.

weavejester 2025-10-22T21:05:03.906489Z

And of course it turns out to be more difficult than I expected...

mpenet 2025-10-23T06:02:29.764919Z

oh right