diff --git a/cider-connection.el b/cider-connection.el index dace07129..0a2854088 100644 --- a/cider-connection.el +++ b/cider-connection.el @@ -343,6 +343,14 @@ buffer." (when cider-auto-mode (cider-enable-on-existing-clojure-buffers)) + (setf cider-connection-capabilities + (append + (pcase (cider-runtime) + ('clojure '(clojure jvm-compilation-errors)) + ('babashka '(babashka jvm-compilation-errors)) + (_ '())) + (when (cider-clojurescript-present-p) '(cljs)))) + (run-hooks 'cider-connected-hook))))) (defun cider--disconnected-handler () @@ -437,6 +445,22 @@ about this buffer (like variable `cider-repl-type')." (plist-get nrepl-endpoint :host) (plist-get nrepl-endpoint :port)))))) +(defun cider-clojurescript-present-p () + "Return non nil when ClojureScript is present." + (nrepl-dict-get (cider-sync-tooling-eval "cljs.core/inc") "value")) + +(defvar-local cider-connection-capabilities '() + "A list of some of the capabilites of this connection buffer. +Aka what assumptions we make about the runtime. Aka stuff we needed to make explicit +in order for nbb to work. +This is more genaral than `cider-nrepl-op-supported-p' and `cider-library-present-p'. +But does not need to replace them.") + +(defun cider-connection-has-capability-p (capability) + "Return non nil when the cider connection has CAPABILITY." + (with-current-buffer (cider-current-repl) + (member capability cider-connection-capabilities))) + ;;; Connection Management Commands @@ -881,10 +905,13 @@ no linked session or there is no REPL of TYPE within the current session." (defun cider--match-repl-type (type buffer) "Return non-nil if TYPE matches BUFFER's REPL type." - (let ((buffer-repl-type (cider-repl-type buffer))) + (let ((buffer-repl-type (cider-repl-type buffer)) + (capabilities (buffer-local-value 'cider-connection-capabilities buffer))) (cond ((null buffer-repl-type) nil) ((or (null type) (eq type 'multi) (eq type 'any)) t) ((listp type) (member buffer-repl-type type)) + ((or (eq 'cljs type) (and (listp type) (member 'cljs type))) + (member 'cljs capabilities)) (t (string= type buffer-repl-type))))) (defun cider--get-host-from-session (session) diff --git a/cider-eval.el b/cider-eval.el index 97377e689..5d1b1e5bc 100644 --- a/cider-eval.el +++ b/cider-eval.el @@ -748,7 +748,9 @@ when `cider-auto-inspect-after-eval' is non-nil." (cider-emit-interactive-eval-output out)) (lambda (_buffer err) (cider-emit-interactive-eval-err-output err) - (unless cider-show-error-buffer + (when (or (not cider-show-error-buffer) + (not (cider-connection-has-capability-p 'jvm-compilation-errors))) + ;; Display errors as temporary overlays (let ((cider-result-use-clojure-font-lock nil)) (cider--display-interactive-eval-result diff --git a/cider.el b/cider.el index b79c89a0a..c931a2178 100644 --- a/cider.el +++ b/cider.el @@ -780,7 +780,7 @@ Generally you should not disable this unless you run into some faulty check." (defun cider-verify-clojurescript-is-present () "Check whether ClojureScript is present." - (unless (cider-library-present-p "cljs.core") + (unless (cider-clojurescript-present-p) (user-error "ClojureScript is not available. See https://docs.cider.mx/cider/basics/clojurescript for details"))) (defun cider-verify-piggieback-is-present ()