Fork me on GitHub
#portal
<
2022-01-14
>
Jakub Holý (HolyJak)10:01:49

Thank you but I'm on Calva. I intend to study your magic one day :)

pez11:01:53

@holyjak You can setup a custom command in Calva with @seancorfield's code. It's a bit uglier because JSON doesn't allow multiline strings (@domagala.lukas is looking at allowing the commands to be specified in EDN) but anyway.

Lukas Domagala11:01:47

@holyjak my calva version, mostly stolen from @seancorfield :

"calva.customREPLCommandSnippets": [
        {
            "name": "Add libs",
            "snippet": "((requiring-resolve 'clojure.tools.deps.alpha.repl/add-libs) '{$selection})"
        },
        {
            "name": "Start Portal",
            "key": "p",
            "snippet": "(do (ns dev) (def portal ((requiring-resolve 'portal.api/open) {:portal.launcher/window-title (System/getProperty \"user.dir\")})) (try (let [r! (requiring-resolve 'portal.runtime/register!) html (fn [url] (with-meta [:div {:style {:background :white}} [:portal.viewer/html (slurp url)]] {:portal.viewer/default :portal.viewer/hiccup}))] (run! (fn [[k f]] (r! f {:name k})) {'dev/->file (requiring-resolve ') 'dev/->html html 'dev/->map (partial into {}) 'dev/->set (partial into #{}) 'dev/->vector (partial into [])})) (catch Throwable _)) (add-tap (requiring-resolve 'portal.api/submit)))"
        }
    ]

Lukas Domagala11:01:27

we are currently working on a PR that lets tools like portal have calva snippets included and auto-loaded, which will make it even easier.

🤯 2