Search code examples
clojurebootcider

Cider: how to run a comand on startup?


I have a web app project that uses boot and reloaded.repl.
It has the following piece of configuration:

(require
<...>
 '[reloaded.repl :refer [init start stop go reset]]
<...>)

I start it as boot dev, and do a (cider-connect <...>) to the instance - after a while a *cider-repl <stuff>* buffer appears.

The first command I want to run and always run is (go) in the Repl so that the dev server is ready. How can I configure Cider to invoke a command when the connection is ready?

I couldn't find anything in the documentation and searching for "cider startup", "cider run command when repl is ready" etc.


Solution

  • Combined with the idea of Rulle's answer, this works:

    
    (add-hook 'cider-connected-hook (lambda ()
                                      (cider-interactive-eval "(go)")))
    
    

    When evaluated in the scratch buffer, the (cider-interactive-eval "(go)") unhelpfully errors out with "No linked session", but when put in a hook, it works.