Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

There's no cider-connect-clojurescript function #1976

Closed
vemv opened this issue Apr 17, 2017 · 16 comments
Closed

There's no cider-connect-clojurescript function #1976

vemv opened this issue Apr 17, 2017 · 16 comments

Comments

@vemv
Copy link
Member

vemv commented Apr 17, 2017

There'a certain asymmetry given these 3 functions:

  • cider-connect
  • cider-jack
  • cider-jack-in-clojurescript

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

@bbatsov
Copy link
Member

bbatsov commented Apr 17, 2017

Makes sense to me. Probably this function should be just a combination of the existing function + setting the REPL type to ClojureScript.

@vemv
Copy link
Member Author

vemv commented Apr 17, 2017

Awesome to hear!

setting the REPL type to ClojureScript.

Is there a function for this right now? (without having to fiddle with CIDER internals)

@yannvanhalewyn
Copy link

yannvanhalewyn commented Jun 19, 2017

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")

@razzmatazz
Copy link

razzmatazz commented Jul 9, 2017

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

@bbatsov
Copy link
Member

bbatsov commented Jul 10, 2017

@razzmatazz C-:. Sorry for ignoring this trivial ticker for a while but the past few months have been extremely busy for me.

@yannvanhalewyn
Copy link

yannvanhalewyn commented Jul 10, 2017

@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"))

@jmckitrick
Copy link
Contributor

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....

@bbatsov
Copy link
Member

bbatsov commented Dec 29, 2017

@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).

@jmckitrick
Copy link
Contributor

(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?

@jmckitrick
Copy link
Contributor

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.

@bbatsov
Copy link
Member

bbatsov commented Jan 2, 2018

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.

@antonzhyliuk
Copy link

👍 for this feature. I'm trying to connect figwheel repl using piggieback middleware.
Missing clojurescript connect function confused me :)

@jmckitrick
Copy link
Contributor

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"))

@jmckitrick
Copy link
Contributor

@bbatsov Do you want a PR or can this just be copied into someone’s existing branch?

@bbatsov
Copy link
Member

bbatsov commented Jan 15, 2018

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.

@bbatsov
Copy link
Member

bbatsov commented Jan 15, 2018

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants