Fork me on GitHub
#calva
<
2024-01-31
>
Max18:01:09

Would it be possible to have actions that create bindings (move to let, extract fn, etc) either prompt for a binding name or put 2 cursors highlighting the binding def and use? Every time I use one I have to go change the binding name by hand afterwards

pez18:01:24

The clojure-lsp command for extracting a function (not the refactoring version) prompts for a function name. I have that bound to a keyboard shortcut. Not sure this is what you are asking for, though. 😀

Max18:01:58

I usually access that through the code action (from clicking on the lightbulb)

Max18:01:12

It doesn’t promote there

pez19:01:28

It’s only on the command, afaik.

Max19:01:10

Is that the kind of thing that can be changed?

pez19:01:09

I don’t know, tbh. It’s a clojure-lsp feature, so if it is changed there it will change in Calva.

👍 1
JAtkins22:01:12

I'm currently trying to make a hover snippet, and it's not going well. Here's what I got so far:

"calva.customREPLHoverSnippets": [
        {
            "name": "eval thing on hover",
            "snippet": "\"I'm making more hover items\""
        },
    ]
I assume this would eval in my repl session (I see nothing in the calva repl or nrepl logging) and add the string I'm making more hover items to the hover list. Even after reloading VSCode I don't see any extra hover content though. This is in my settings.json fwiw.

JAtkins22:01:57

Curiously I get a docstring when I put the snippet in the workspace settings json, not the user settings json

pez22:01:16

This could be a bug with how we merge this setting. @U02EMBDU2JU do you see a reason why it wouldn’t work with user settings?

Lukas Domagala22:01:32

No. I’ve run into that myself and ran the scenario through the debugger and couldn’t figure it out. If I remember correctly, it works in the test project, so I thought my setup might be weird. I’ve put it into config.edn instead. If it works in workspace setting but not in the user settings it would explain why our test setup is fine and why my setup was broke 🙂

pez12:02:43

I guess the merge is a bit special since we have the edn config in the mix as well. Issue welcome, @U5P29DSUS!

JAtkins22:01:23

Has anyone written a utility for repl commands to resolve the full name of a symbol? i.e. convert $current-form, which may be ::namespaced/keyword, to :the.actual.namespace/keyword? Currently making my own based on ns-aliases, but if it's built in that'd be great.

👀 1
JAtkins23:01:58

#?(:clj
   (defn realize-symbol
     [ns-str symbol-str]
     (let [[_ kw? ns_ name_ :as match] (re-matches #"^(\:\:)?([^:]+)\/(.+)$" symbol-str)
           actual-ns-str (when ns_ (or (some-> ns-str (symbol) (ns-aliases) (get (symbol ns_)) (ns-name) (str))
                                       ns_))]
       (cond (not ns_) (read-string symbol-str)
             kw? (keyword actual-ns-str name_)
             :else (symbol actual-ns-str name_)))))