This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-05-27
Channels
- # announcements (3)
- # babashka (35)
- # babashka-sci-dev (42)
- # beginners (27)
- # calva (7)
- # clj-kondo (18)
- # cljs-dev (1)
- # clojure (40)
- # clojure-europe (141)
- # clojure-nl (1)
- # clojure-norway (6)
- # clojure-uk (40)
- # clojurescript (15)
- # community-development (4)
- # cursive (54)
- # events (1)
- # fulcro (8)
- # helix (5)
- # hyperfiddle (22)
- # introduce-yourself (6)
- # jobs (3)
- # joyride (26)
- # lsp (7)
- # music (1)
- # nbb (7)
- # off-topic (28)
- # pathom (120)
- # pedestal (3)
- # podcasts-discuss (2)
- # portal (2)
- # rdf (2)
- # releases (20)
- # rewrite-clj (9)
- # shadow-cljs (26)
- # spacemacs (1)
- # sql (13)
- # vim (10)
- # xtdb (63)
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
custom-commands
#js{:title "Select a custom command"})]
((.-fn command)))
@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
...
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.
Hm, or does that have to be matched statically with https://github.com/djblue/portal/blob/master/extension-vscode/package.json ?
Yes, but the command id still needs to be present in the extension manifest. Only the registration is dynamic. Afaiut.
See https://github.com/BetterThanTomorrow/calva/blob/dev/package.json#L2308 and some 300 lines for the crazy thing Calva does.
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
It seems that if I try to log things that are function
s 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
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!