There'a certain asymmetry given these 3 functions:
Given those 3, one could expect cider-connect-clojurescript to exist too. But it doesn't!
The thing is, I'd like to connect to a clojurescript nrepl session started outside emacs (e.g. from a terminal, lein figwheel with piggieback middleware). This doesn't seem like an unusual need?
So, if I M-x cider-connect and enter the nrepl address of a running clojurescipt nrepl session (started by figwheel), CIDER will connect, but autocompletions will be for clojure rather than clojurescript.
IOW, cider internally is not cljs-aware when running cider-connect.
What do you think?
Cheers - Victor
Makes sense to me. Probably this function should be just a combination of the existing function + setting the REPL type to ClojureScript.
Awesome to hear!
setting the REPL type to ClojureScript.
Is there a function for this right now? (without having to fiddle with CIDER internals)
I too am looking for a way to set the connection type to clojurescript! I often start my cljs-repl from a clj-repl.
Update: by reading cider code I managed to find a way to update the buffer connection type. Would like to know if there is a better way to do it though. With the cljs-repl as active buffer:
(setq-local cider-repl-type "cljs")
I would be interested in this too; @yannvanhalewyn how do you evaluate the setq-local function on the repl? C-x C-e invokes clojure fn, instead of emacs
@razzmatazz C-:. Sorry for ignoring this trivial ticker for a while but the past few months have been extremely busy for me.
@razzmatazz In cider mode you can still use M-:, or M-x "eval-expression". If you do this a lot you can add your own helper function to your emacs config:
(defun cider-make-cljs-repl ()
"Changes the connection type of the repl buffer at point to CLJS."
(interactive)
(setq-local cider-repl-type "cljs"))
I'm happy to help with a solution here, if there's coding to be done. Something like this would be a good way to contribute....
@jmckitrick There's certainly a bit of coding to be done. We need two simply functions - cider-connect-clojurescript and perhaps one more interactive command to just change the REPL type (similar to what @yannvanhalewyn suggested).
(defun cider-make-cljs-repl () "Change the repl to CLJS mode." (interactive) (setq cider-repl-type "cljs")) (defun cider-connect-clojurescript () "Connect to a clojurescript repl." (interactive) (cider-connect) (cider-make-cljs-repl))
Would this do the trick?
Actually, a simple test plan would be best. I'll try that locally, and open a PR if it works. So @vemv @yannvanhalewyn @razzmatazz if you'd add one here, I'll try it locally and tweak my 'patch' accordingly, simple though it may be.
I'd suggest adding a more generic function - e.g. cider-repl-set-type and it could be used them to change a REPL type in both directions. Interactively it would prompt you to chose the type, but called from Elisp it would take the type as param.
馃憤 for this feature. I'm trying to connect figwheel repl using piggieback middleware.
Missing clojurescript connect function confused me :)
So more like:
(defun cider-repl-set-type [type] "REPL `type' should be either \"clj\" or \"cljs\"." (interactive "s") (setq cider-repl-type type)) (defun cider-connect-clojurescript () "Connect to a clojurescript repl." (interactive) (cider-connect) (cider-repl-set-type "cljs"))
@bbatsov Do you want a PR or can this just be copied into someone鈥檚 existing branch?
I've implemented this myself, as there were some nuances you hadn't taken into account (e.g. that you might not be in the right buffer when trying to set the repl type).
Try what I've added in master and me know if it works.
Update: by reading cider code I managed to find a way to update the buffer connection type. Would like to know if there is a better way to do it though. With the cljs-repl as active buffer:
@yannvanhalewyn Now there's also a function in CIDER itself - cider-repl-set-type.
Most helpful comment
So more like: