Fork me on GitHub

Here's something I really enjoy:

(def custom-commands
  #js [#js {:label "Send Last Eval to Portal" :fn send-last-eval-to-portal}
       #js {:label "Evaluate top-level form to Portal" :fn send-toplevel-form-to-portal}
       #js {:label "Evaluate current form to Portal" :fn send-current-form-to-portal}
       #js {:label "Open Portal" :fn open-portal}
       #js {:label "Ensure Portal Open" :fn ensure-portal-open}
       #js {:label "Restart LSP" :fn restart-clojure-lsp}
       #js {:label "Say Hi" :fn #(info "Hi!")}])

(defn show-my-commands []
  (p/let [command (vscode/window.showQuickPick
                   #js{:title "Select a custom command"})]
    ((.-fn command)))


That yields:


@U04V70XH6 perhaps something for you, with all your custom commands. Sometimes it's nice to browse 🙂


This is wonderful! @U04V15CAJ and I have discussed if we should provide some way to config things like this. Solving it in user space is awesome for now. If we one day want to add it to Joyride we will have different approaches to learn from.


Well sure I'd like to not have a custom keybinding for this 🙂 The portal extension does something clever where it registers commands dynamically, so you can presumably eval the user/workspace activate scripts, and if I provide you with commands via an API, add them to the top-level command menu under Joyride:User...


I wonder what the portal extension does...


Calva does something for custom REPL command snippets, that I originally was planning to use for Joyride as well. In Calva we ”book bindings ahead”, a ton of them. Then the user can choose from those bindings when configuring snippets.


Yes, but the command id still needs to be present in the extension manifest. Only the registration is dynamic. Afaiut.


You beat me to it.


See and some 300 lines for the crazy thing Calva does.


Cool trick!


Before I employed that trick, what I did was to prefix commands automatically with the key. So then it would be almost like chord. If you add :key to your config structure there and prefix with it. Then you can use the shortcut you bind for bring up the menu, say cmd+f4, followed by typing the key, followed by enter. If the key is a, it becomes cmd+f4 a enter. Or the key slep for Send Last Eval to Portal, you would render it as slep: Send Last Eveal to Portal, and use it like cmd+f4 s l e p enter .


In fact with the fuzzy search you often won't need a key like slep. The same ”chord” will do it anyway.


Hey, @pez, a little help here if possible? I'm trying to make Clover play better with Joyride, but for some reason clover.exports is always nil. Do I need to do something special to export commands?


You need to return the api in the activate function. So something like

(defn activate [context]
  {:fn1 fn1
   :fn2 fn2})
I think should work.


WOW, something is REALLY WEIRD!


First is logging with prn, second is with console.log


Yeah, what could be going on there?


It seems that if I try to log things that are functions it does not work. And no matter what I do, it does not expose any exports 😞


Oh, wait... I got way sidetracked for the js/console.log issue that I forgot that I'm not exposing the ClojureScript code as the plug-in, I'm exposing a Javascript code that calls ClojureScript


And Javascript needs to use return facepalm


Been there. Done that. 😀


By the way, I have no idea on why console.log does not print the keys when the values are functions, but anyway, it's working now! Thanks for the help!

🙏 1