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

[Fix #2466] Make generic cider ops use any available nrepl connection #2467

Merged
merged 1 commit into from
Oct 8, 2018

Conversation

kommen
Copy link
Contributor

@kommen kommen commented Sep 30, 2018

This makes formatting code always use the clj repl type, which makes the cider-format-* commands work in cljs buffers even if there is no cljs repl active.

Fixes #2466

[This is my first contribution to cider, discussion & feedback very welcome]

@bbatsov
Copy link
Member

bbatsov commented Sep 30, 2018

[This is my first contribution to cider, discussion & feedback very welcome]

Congratulations! Thanks for the nicely executed PR! Hopefully it's going to be the first of many - we sure need more people to help out!

cider-client.el Outdated
@@ -533,7 +533,7 @@ The result entries are relative to the classpath."
"Perform nREPL \"format-code\" op with CODE."
(thread-first `("op" "format-code"
"code" ,code)
(cider-nrepl-send-sync-request)
(cider-nrepl-send-sync-request (cider-current-repl "clj"))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking at the other code in the file I think of two things:

  • what happens if you only have a cljs connection? Seems to me the formatting should still work, as it's not really clj or cljs specific
  • I see we're utilizing the same pattern for other ops as well, which means they would likely exhibit the same problem as the formatting issue

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what happens if you only have a cljs connection? Seems to me the formatting should still work, as it's not really clj or cljs specific

True. I didn't consider having just a cljs repl to be a thing.

So I guess "multi" would be the right thing to pass to cider-current-repl?

I see we're utilizing the same pattern for other ops as well, which means they would likely exhibit the same problem as the formatting issue

Perhaps, yes. I just investigate since I didn't run into any of those other issues yet.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just tested using (cider-current-repl "multi") and it does make it work with either an cljs or an clj repl active.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

re other ops: additionally to change other ops, utility functions like cider-nrepl-op-supported-p would also have to be changed.

@kommen
Copy link
Contributor Author

kommen commented Sep 30, 2018

@bbatsov would you prefer closing this PR in favor of a more thorough one addressing this in a general fashion for all ops?

@bbatsov
Copy link
Member

bbatsov commented Sep 30, 2018

We'll certainly need a generic solution for this, but I'll have to think a bit about what makes the most sense.

I think historically we sent all middleware evaluations to the Clojure REPL, as before 0.18 it wasn't possible to have just a ClojureScript REPL. @vspinu What do you think about this?

@vspinu
Copy link
Contributor

vspinu commented Oct 5, 2018

Sorry for the late reply (I am on vacation atm). I think any connection would do for the purpose of format and other generic ops. Hence "multi" seems like the right approach. Unfortunately in the context of cider-current-repl "multi" is a misnomer, maybe we could have "any" as a synonym here.

@bbatsov
Copy link
Member

bbatsov commented Oct 5, 2018

Hence "multi" seems like the right approach. Unfortunately in the context of cider-current-repl "multi" is a misnomer, maybe we could have "any" as a synonym here.

I like this!

@kommen
Copy link
Contributor Author

kommen commented Oct 7, 2018

@bbatsov @vspinu I've pushed an attempt to as you suggested. As eval uses it's connection selection, it seemed safe to me to just adjust the cider-nrepl-send-sync-request, cider-nrepl-send-request and cider-nrepl-send-unhandled-request functions.

What do you think?

@kommen kommen changed the title [Fix #2466] Always use clj repl type for formatting code [Fix #2466] Make generic cider ops use any available nrepl connection Oct 7, 2018
@kommen kommen force-pushed the fix-2466 branch 3 times, most recently from 2d7c8f3 to fdd1c2c Compare October 8, 2018 07:28
@@ -153,7 +153,7 @@ REQUEST is a pair list of the form (\"op\" \"operation\" \"par1-name\"
\"par1\" ... ).
If CONNECTION is provided dispatch to that connection instead of
the current connection. Return the id of the sent message."
(nrepl-send-request request callback (or connection (cider-current-repl))))
(nrepl-send-request request callback (or connection (cider-current-repl "any"))))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems to me we should assume "any" by default.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually forget about this.

@bbatsov
Copy link
Member

bbatsov commented Oct 8, 2018

Looks good to me overall. Just add some entry in the changelog for this.

…pl connection

Make "any" a synonym of "multi" for `cider-current-repl`, which makes
it more clear any avaiable nrepl connection can be used.

This allows ops for like documentatation browser to work, even if only a repl
for a different type of repl is connected. For example, when formatting a .cljs
buffer, a connected "clj" repl will suffice.

Cider eval uses a separate repl connection selection, which lets it unaffacted
by these changes.
@kommen
Copy link
Contributor Author

kommen commented Oct 8, 2018

@bbatsov thanks, I've added the changelog entry

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

Successfully merging this pull request may close these issues.

None yet

3 participants