lsp

2025-09-09T14:30:25.661559Z

would there be interest in the "Restructure Keys" working for :strs and :syms?

borkdude 2025-09-09T14:33:33.258789Z

what does it do normally? (never used it)

2025-09-09T14:34:31.766649Z

if you have (let [{:keys [a b c]} foo] (some-call a b c)]), it'll change to (some-call (:a foo) (:b foo) (:c foo)), and there's a sister action that does the reverse called "destructure keys"

borkdude 2025-09-09T14:35:45.960639Z

ok cool

2025-09-09T14:37:02.956569Z

it only works with :keys but i ran into a situation where i wanted to switch from (let [{:strs [a b c]} foo] (some-call a b c)]) to (some-call (get foo "a") (get foo "b") (get foo "c"))

borkdude 2025-09-09T14:37:54.996099Z

makes sense. I don't think clj-kondo keeps track of strings though, so might not be as easy as keywords

2025-09-09T14:39:29.202149Z

ah good call

borkdude 2025-09-09T14:41:07.144439Z

I guess a workaround to this could be to let lsp first rename a (and others) to lsp_str$a etc. then let lsp rename :strs to :keys . Then do the Restructure Keys (but using get instead of keyword calls...) and then change back the :keys to :strs and the local names to a etc. But seems like a huge workaround

borkdude 2025-09-09T14:41:36.452299Z

no sorry, then remove the :keys

2025-09-09T14:42:49.156399Z

yeah, i'd have to look at it, but gotta make sure it's worthwhile first

ericdallo 2025-09-09T15:11:12.163239Z

this is funny, I just learned about :strs existence today, what are the odds of a question about it in the same day

ericdallo 2025-09-09T15:11:21.771829Z

but yeah, sounds nice

👍 1
2025-09-09T15:17:57.467529Z

yeah, there's :keys, :syms, and :strs for the 3 primary key types lol

borkdude 2025-09-09T15:18:15.011609Z

and clojuredart has :flds

😯 1
2025-09-09T15:19:27.975019Z

(let [{:keys [a b c]
       :syms [d e f]
       :strs [g h i]} {:a 1 :b 2 :c 3
                       'd 4 'e 5 'f 6
                       "g" 7 "h" 8 "i" 9}]
  [a b c d e f g h i])
; [1 2 3 4 5 6 7 8 9]

ericdallo 2025-09-09T15:19:31.141849Z

@nbtheduke do you have a minimal example of a initial code, then you apply the command/code action and the result

ericdallo 2025-09-09T15:19:34.959119Z

ah nice

borkdude 2025-09-09T15:22:16.119209Z

ah yeah it might not matter if it's a keyword or not, since this works via locals

borkdude 2025-09-09T15:22:24.158969Z

and those are tracked in kondo

ericdallo 2025-09-09T15:23:19.689439Z

yes, that's what I was thinking

ericdallo 2025-09-09T15:24:00.946559Z

@nbtheduke feel free to open a issue with a clear exampel of before and after applying the command, it should not be that hard to support that

👍 1
2025-09-09T18:51:51.187459Z

one quick question about design here... any reason to not have clojure.specs for (at least) clojure-lsp/db ns? I'd like to contribute for having them if it could be interesting for the project

ericdallo 2025-09-09T19:17:17.717009Z

clojure-lsp.db was always a internal thing, changing frequently, so it was never meant to be used externally. What we should do is have an adapter layer if we expose it, so we can maintain and avoid breaking changes, that layer may make sense have a spec