-
-
Notifications
You must be signed in to change notification settings - Fork 645
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
Allow connecting to nbb via connect-clj (#3061) #3272
Conversation
b37988b
to
fa2032a
Compare
Don't merge I need to figure out a better way for checking "cljs present". |
7df9d1e
to
f75f017
Compare
This is for nbb, scittle, joyride. Better support for "pain" repls, support "cljs" without setup. we want to 1. connect with a plain client 2. make any assumptions explicit 3. connect cljs buffers with those plain repls 1. Check for cider middleware being present, before using it (already being done) 2. Check for cider-library-present-p, before relying on anything in the runtime 3. Make assumptions about the runtime explicit My suggestion is =cider-connection-capabilities=. Currently, there was an implicit assumption about the compilation error format. =cider-connection-capabilities= Is my suggestion for 2. =cider-repls= Now returns cljs, if the repl capabilities include 'cljs This way we can make a "plain" clj client, upgrade on connect with cljs capability and have it be connected in cljs buffers. This is more a concession / workaround the current repl-type setup. In the future we might get rid of repl-type? The only reason we have it, and creaating issue 3., is because we want to be ergonomic about which buffer to use inside a given source buffer. I found that I am able to juggle multiple clients by swapping to the buffer I want, thereby setting it active. This can be a user command. Can also make a modeline element that swaps between clj/cljs like calva. slack discussion: https://clojurians.slack.com/archives/C04CAKAGADU Format docstring Fix cljs check
f75f017
to
ed8ee40
Compare
You can also mark PRs as "Draft" to make this visually clear, btw. |
(if (cider-nrepl-op-supported-p "stacktrace") | ||
(cider-default-err-op-handler) | ||
(cider-default-err-eval-handler))) | ||
(cond ((cider-nrepl-op-supported-p "stacktrace") (cider-default-err-op-handler)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems to me this change won't result in anything different.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, actually the similar names confused me. Now I see the last branch is different.
cider-connection.el
Outdated
(defvar-local cider-connection-capabilities '() | ||
"A list of some of the capabilites of this connection buffer. | ||
Aka what assumptions we make about the runtime. | ||
This is more genaral than |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
general
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
cider-connection.el
Outdated
`cider-nrepl-op-supported-p' and `cider-library-present-p'. | ||
But does not need to replace them.") | ||
|
||
(defun cider-connection-has-capability-p (capability) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't this operate only on the current buffer? Probably it'd be nice to be able to pass a connection to it explicitly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
@@ -303,6 +303,7 @@ focused." | |||
(let* ((font-value (if cider-result-use-clojure-font-lock | |||
(cider-font-lock-as-clojure value) | |||
value)) | |||
(font-value (string-trim-right font-value)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't quite understand the purpose of this change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nbb errors always had a trailing newline and the I think the visual of the overlays is better without the newline.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Got it. This name font-value
confused me, as that's just value (which is potentially using font-locking). I was wondering why someone would be trimming the font-value. :D
@@ -778,9 +778,13 @@ Generally you should not disable this unless you run into some faulty check." | |||
:safe #'booleanp | |||
:package-version '(cider . "0.17.0")) | |||
|
|||
(defun cider-clojurescript-present-p () | |||
"Return non nil when ClojureScript is present." | |||
(nrepl-dict-get (cider-sync-tooling-eval "cljs.core/demunge") "value")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what's the advantage of this over the previous check?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#3255 Basically (require 'cljs.core)
did not work for nbb.
@@ -153,7 +153,8 @@ you'd like to use the default Emacs behavior use | |||
(make-obsolete-variable 'cider-repl-print-level 'cider-print-options "0.21") | |||
|
|||
(defvar cider-repl-require-repl-utils-code | |||
'((clj . "(clojure.core/apply clojure.core/require clojure.main/repl-requires)") | |||
'((clj . "(when-let [requires (resolve 'clojure.main/repl-requires)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You'll have to explain me the need for this change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When you currently connect to joyride it throws "cannot resolve symbol repl-requires". It was the same for an earlier version of nbb I basiclly want to make the clj
connection as un-assuming as possible.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should also document somewhere that such REPL automatic util requires are limited to Clojure and the hosted ClojureScript.
cider-connection.el
Outdated
`cider-nrepl-op-supported-p' and `cider-library-present-p'. | ||
But does not need to replace them.") | ||
|
||
(defun cider-connection-has-capability-p (connection-buffer capability) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can also swap the params if you want to make the connection optional (e.g. the current buffer or current-connection buffer by default).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok!
Overall I like how this is shaping up. Apart from my small remarks I think it'd be nice to document somewhere that you can use |
I added a doc in the docs |
Thanks for tackling this! 🙇♂️ |
@benjamin-asdf @bbatsov great to see this, thank you both! |
This is for nbb, scittle, joyride.
Better support for "pain" repls, support "cljs" without setup.
we want to
connect with a plain client
make any assumptions explicit
connect cljs buffers with those plain repls
Check for cider middleware being present, before using it (already being done)
Check for cider-library-present-p, before relying on anything in the runtime
Make assumptions about the runtime explicit
My suggestion is =cider-connection-capabilities=.
Currently, there was an implicit assumption about the compilation error format.
=cider-connection-capabilities=
Is my suggestion for 2.
=cider-repls=
Now returns cljs, if the repl capabilities include 'cljs This way we can make a "plain" clj client, upgrade on connect with cljs capability and have it be connected in cljs buffers.
This is more a concession / workaround the current repl-type setup.
In the future we might get rid of repl-type?
The only reason we have it, and creaating issue 3., is because we want to be ergonomic about which buffer to use inside a given source buffer.
I found that I am able to juggle multiple clients by swapping to the buffer I want, thereby setting it active.
This can be a user command. Can also make a modeline element that swaps between clj/cljs like calva.
slack discussion:
https://clojurians.slack.com/archives/C04CAKAGADU
This pr also includes a few less consequential fixes that made nbb, scittle and joyride work.
(there was an error in the default repl init form "no such var, repl requires" )
The commits are consistent with our contribution guideglines
You've added tests (if possible) to cover your change(s)
All tests are passing (
eldev test
)All code passes the linter (
eldev lint
) which is based onelisp-lint
and includesbyte-compilation,
checkdoc
,check-declare,
packaging metadata, indentation, and trailing whitespace checks.
I ran it but it is currently cluttered. I am still 90% certain I
fixed the ones I would be introducing.
If some warnings are ignored, please explain how to ignore.
You've updated the changelog (if adding/changing user-visible functionality)
You've updated the user manual (if adding/changing user-visible functionality)