Fork me on GitHub
#lsp
<
2022-08-11
>
sheluchin22:08:36

I'm getting unexpected behaviour renaming keywords:

(let [{:foo/keys [bar]} {:fo|o/bar 1}]
  bar)
produces:
(let [{:foo/keys [baz]} {:foo/baz 1}]
  bar)
where I expect the bar inside the let body to also be renamed to baz to keep things consistent.
:server-version "2022.07.24-18.25.43",                                                                                                                                                        
 :clj-kondo-version "2022.06.23-SNAPSHOT",
I think maybe I'm hitting https://github.com/clojure-lsp/clojure-lsp/issues/978.

jacob.maine01:08:29

When clj-kondo parses {:foo/keys [bar], it emits two https://github.com/clj-kondo/clj-kondo/tree/master/analysis elements for bar, a “keyword” and a “local”. That is, that bar is both a keyword usage and a local definition. When you invoke rename from another keyword, clojure-lsp finds all the matching keywords and renames them. That’s why {:foo/keys [bar]} becomes {:foo/keys [baz]}. But you’re right, since bar is also a local definition, it would make sense to rename the local usages too. Would you open an issue in github for this?

☝️ 2
sheluchin09:08:52

Thanks for the explanation, @U07M2C8TT. Sure, I'd be happy to create an issue to track this. I will have it up sometime later today and will leave drop the link here for reference.