diff --git a/CHANGELOG.md b/CHANGELOG.md index 1c30e8750..821ddef59 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,13 +5,17 @@ ### New features - [#3359](https://github.com/clojure-emacs/cider/pull/3359): Add customizable default connection params +- [#3828](https://github.com/clojure-emacs/cider/issues/3828): Inspector: diff mode. +- [#3828](https://github.com/clojure-emacs/cider/issues/3828): Inspector: sorting maps by keys. ### Changes -- Bump the injected `cider-nrepl` to [0.56.0](https://github.com/clojure-emacs/cider-nrepl/blob/master/CHANGELOG.md#0560-2025-05-29). +- Bump the injected `cider-nrepl` to [0.57.0](https://github.com/clojure-emacs/cider-nrepl/blob/master/CHANGELOG.md#0570-2025-06-29). - [cider-nrepl#941](https://github.com/clojure-emacs/cider-nrepl/pull/941): Stop vendoring Fipp dependency. - [cider-nrepl#943](https://github.com/clojure-emacs/cider-nrepl/pull/943): Reduce debugger instrumentation bytecode footprint. - [orchard#342](https://github.com/clojure-emacs/orchard/pull/342): Inspector: add hexdump view mode. + - [orchard#349](https://github.com/clojure-emacs/orchard/pull/349): Inspector: add ability to sort maps by key. + - [orchard#350](https://github.com/clojure-emacs/orchard/pull/350): Inspector: add diff mode and `orchard.inspect/diff`. - [#3816](https://github.com/clojure-emacs/cider/issues/3816): **(Breaking)** Remove enrich-classpath support from cider-jack-in. - [#3817](https://github.com/clojure-emacs/cider/issues/3817): Enable `cider-download-java-sources` by default. diff --git a/cider-inspector.el b/cider-inspector.el index 2a325eaca..73feaf808 100644 --- a/cider-inspector.el +++ b/cider-inspector.el @@ -84,6 +84,16 @@ The max depth can be also changed interactively within the inspector." :type 'boolean :package-version '(cider . "1.18.0")) +(defcustom cider-inspector-sort-maps nil + "When true, sort inspected maps by keys." + :type 'boolean + :package-version '(cider . "1.19.0")) + +(defcustom cider-inspector-only-diff nil + "When true and inspecting a diff result, only display values that differ." + :type 'boolean + :package-version '(cider . "1.19.0")) + (defcustom cider-inspector-skip-uninteresting t "Controls whether to skip over uninteresting values in the inspector. Only applies to navigation with `cider-inspector-prev-inspectable-object' @@ -147,6 +157,8 @@ Can be turned to nil once the user sees and acknowledges the feature." (define-key map [(shift tab)] #'cider-inspector-previous-inspectable-object) (define-key map "p" #'cider-inspector-previous-inspectable-object) (define-key map "P" #'cider-inspector-toggle-pretty-print) + (define-key map "S" #'cider-inspector-toggle-sort-maps) + (define-key map "D" #'cider-inspector-toggle-only-diff) (define-key map (kbd "C-c C-p") #'cider-inspector-print-current-value) (define-key map ":" #'cider-inspect-expr-from-inspector) (define-key map "f" #'forward-char) @@ -185,6 +197,16 @@ Can be turned to nil once the user sees and acknowledges the feature." (setq-local sesman-system 'CIDER) (visual-line-mode 1)) +(defun cider-inspector--highlight-diff-tags () + "Apply face to #± using overlays. +We use overlays here because font-locking doesn't seem to work for this." + (save-excursion + (goto-char (point-min)) + (while (search-forward "#±" nil t) + (let ((overlay (make-overlay (match-beginning 0) (match-end 0)))) + (overlay-put overlay 'face 'font-lock-warning-face) + (overlay-put overlay 'priority 100))))) + ;;;###autoload (defun cider-inspect-last-sexp () "Inspect the result of the the expression preceding point." @@ -354,9 +376,23 @@ MAX-NESTED-DEPTH is the new value." (defun cider-inspector-toggle-pretty-print () "Toggle the pretty printing of values in the inspector." (interactive) - (let ((result (cider-nrepl-send-sync-request `("op" "inspect-toggle-pretty-print")))) - (when (nrepl-dict-get result "value") - (cider-inspector--render-value result)))) + (customize-set-variable 'cider-inspector-pretty-print (not cider-inspector-pretty-print)) + (cider-inspector--refresh-with-opts + "pretty-print" (if cider-inspector-pretty-print "true" "false"))) + +(defun cider-inspector-toggle-sort-maps () + "Toggle the sorting of maps in the inspector." + (interactive) + (customize-set-variable 'cider-inspector-sort-maps (not cider-inspector-sort-maps)) + (cider-inspector--refresh-with-opts + "sort-maps" (if cider-inspector-sort-maps "true" "false"))) + +(defun cider-inspector-toggle-only-diff () + "Toggle the display of only differing values when inspecting diff results." + (interactive) + (customize-set-variable 'cider-inspector-only-diff (not cider-inspector-only-diff)) + (cider-inspector--refresh-with-opts + "only-diff" (if cider-inspector-only-diff "true" "false"))) (defun cider-inspector-toggle-view-mode () "Toggle the view mode of the inspector between normal and object view mode." @@ -454,8 +490,9 @@ MAX-COLL-SIZE if non nil." `("max-nested-depth" ,cider-inspector-max-nested-depth)) ,@(when cider-inspector-display-analytics-hint `("display-analytics-hint" "true")) - ,@(when cider-inspector-pretty-print - `("pretty-print" "true")))) + "pretty-print" ,(if cider-inspector-pretty-print "true" "false") + "sort-maps" ,(if cider-inspector-sort-maps "true" "false") + "only-diff" ,(if cider-inspector-only-diff "true" "false"))) (cider-nrepl-send-sync-request))) (declare-function cider-set-buffer-ns "cider-mode") @@ -522,7 +559,8 @@ from stack), `:next-inspectable' (move point to next inspectable object)." "Render ELEMENTS." (setq cider-inspector-looking-at-java-p nil) (dolist (el elements) - (cider-inspector-render-el* el))) + (cider-inspector-render-el* el)) + (cider-inspector--highlight-diff-tags)) (defconst cider--inspector-java-headers ;; NOTE "--- Static fields:" "--- Instance fields:" are for objects, diff --git a/cider.el b/cider.el index 10fe34d5a..230a068d7 100644 --- a/cider.el +++ b/cider.el @@ -549,7 +549,7 @@ the artifact.") Used when `cider-jack-in-auto-inject-clojure' is set to `latest'.") -(defconst cider-required-middleware-version "0.56.0" +(defconst cider-required-middleware-version "0.57.0" "The CIDER nREPL version that's known to work properly with CIDER.") (defcustom cider-injected-middleware-version cider-required-middleware-version diff --git a/dev/docker-sample-project/project.clj b/dev/docker-sample-project/project.clj index c9bde05a4..0536ae090 100644 --- a/dev/docker-sample-project/project.clj +++ b/dev/docker-sample-project/project.clj @@ -2,4 +2,4 @@ :dependencies [[org.clojure/clojure "1.11.1"] [clj-http "3.12.3"]] :source-paths ["src"] - :plugins [[cider/cider-nrepl "0.56.0"]]) + :plugins [[cider/cider-nrepl "0.57.0"]]) diff --git a/dev/tramp-sample-project/project.clj b/dev/tramp-sample-project/project.clj index 2033564ca..fb17b81ba 100644 --- a/dev/tramp-sample-project/project.clj +++ b/dev/tramp-sample-project/project.clj @@ -2,5 +2,5 @@ :dependencies [[org.clojure/clojure "1.11.1"] [clj-http "3.12.3"]] :source-paths ["src"] - :plugins [[cider/cider-nrepl "0.56.0"] + :plugins [[cider/cider-nrepl "0.57.0"] [refactor-nrepl "3.9.0"]]) diff --git a/doc/modules/ROOT/pages/basics/middleware_setup.adoc b/doc/modules/ROOT/pages/basics/middleware_setup.adoc index 7c2e00d74..f210fcf04 100644 --- a/doc/modules/ROOT/pages/basics/middleware_setup.adoc +++ b/doc/modules/ROOT/pages/basics/middleware_setup.adoc @@ -20,14 +20,14 @@ Use the convenient plugin for defaults, either in your project's [source,clojure] ---- -:plugins [[cider/cider-nrepl "0.56.0"]] +:plugins [[cider/cider-nrepl "0.57.0"]] ---- A minimal `profiles.clj` for CIDER would be: [source,clojure] ---- -{:repl {:plugins [[cider/cider-nrepl "0.56.0"]]}} +{:repl {:plugins [[cider/cider-nrepl "0.57.0"]]}} ---- WARNING: Be careful not to place this in the `:user` profile, as this way CIDER's @@ -43,11 +43,11 @@ run `cider-connect` or `cider-connect-cljs`. [source,clojure] ---- - :cider-clj {:extra-deps {cider/cider-nrepl {:mvn/version "0.56.0"}} + :cider-clj {:extra-deps {cider/cider-nrepl {:mvn/version "0.57.0"}} :main-opts ["-m" "nrepl.cmdline" "--middleware" "[cider.nrepl/cider-middleware]"]} :cider-cljs {:extra-deps {org.clojure/clojurescript {:mvn/version "1.10.339"} - cider/cider-nrepl {:mvn/version "0.56.0"} + cider/cider-nrepl {:mvn/version "0.57.0"} cider/piggieback {:mvn/version "0.6.0"}} :main-opts ["-m" "nrepl.cmdline" "--middleware" "[cider.nrepl/cider-middleware,cider.piggieback/wrap-cljs-repl]"]} @@ -66,7 +66,7 @@ NOTE: Make sure you're using https://github.com/clojurephant/clojurephant[Clojur ---- dependencies { devImplementation 'nrepl:nrepl:1.3.1' - devImplementation 'cider:cider-nrepl:0.56.0' + devImplementation 'cider:cider-nrepl:0.57.0' } tasks.named('clojureRepl') { diff --git a/doc/modules/ROOT/pages/basics/up_and_running.adoc b/doc/modules/ROOT/pages/basics/up_and_running.adoc index e6e82cf63..bae36f36c 100644 --- a/doc/modules/ROOT/pages/basics/up_and_running.adoc +++ b/doc/modules/ROOT/pages/basics/up_and_running.adoc @@ -72,7 +72,7 @@ simple - CIDER passes the extra dependencies and nREPL configuration to your build tool in the command it runs to start the nREPL server. Here's how this looks for `tools.deps`: - $ clojure -Sdeps '{:deps {nrepl {:mvn/version "1.3.1"} cider/cider-nrepl {:mvn/version "0.56.0"}}}' -m nrepl.cmdline --middleware '["cider.nrepl/cider-middleware"]' + $ clojure -Sdeps '{:deps {nrepl {:mvn/version "1.3.1"} cider/cider-nrepl {:mvn/version "0.57.0"}}}' -m nrepl.cmdline --middleware '["cider.nrepl/cider-middleware"]' TIP: If you don't want `cider-jack-in` to inject dependencies automatically, set `cider-inject-dependencies-at-jack-in` to `nil`. Note that you'll have to setup @@ -332,7 +332,7 @@ It is also possible for plain `clj`, although the command is somewhat longer: [source,sh] ---- -$ clj -Sdeps '{:deps {cider/cider-nrepl {:mvn/version "0.56.0"}}}' -m nrepl.cmdline --middleware "[cider.nrepl/cider-middleware]" +$ clj -Sdeps '{:deps {cider/cider-nrepl {:mvn/version "0.57.0"}}}' -m nrepl.cmdline --middleware "[cider.nrepl/cider-middleware]" ---- Alternatively, you can start nREPL either manually or using the facilities @@ -466,7 +466,7 @@ The command tunnels as well the remote port 12345 to local machine on port 12345 ---- ssh -t -L 12345:localhost:12345 MY_REMOTE_SERVER \ devcontainer exec --workspace-folder /home/me/my-clj-code \ - "clojure -Sdeps '{:deps {nrepl/nrepl {:mvn/version \"1.3.1\"} cider/cider-nrepl {:mvn/version \"0.56.0\"}}}' -m nrepl.cmdline -p 12345 -b 0.0.0.0 --middleware '[\"cider.nrepl/cider-middleware\"]' " + "clojure -Sdeps '{:deps {nrepl/nrepl {:mvn/version \"1.3.1\"} cider/cider-nrepl {:mvn/version \"0.57.0\"}}}' -m nrepl.cmdline -p 12345 -b 0.0.0.0 --middleware '[\"cider.nrepl/cider-middleware\"]' " ---- For this to work, we need as well to configure `devcontainer.json` with a snippet that exposes port `12345` from the container to the (remote) host: diff --git a/doc/modules/ROOT/pages/cljs/shadow-cljs.adoc b/doc/modules/ROOT/pages/cljs/shadow-cljs.adoc index 9ebaae442..ae55ba1cd 100644 --- a/doc/modules/ROOT/pages/cljs/shadow-cljs.adoc +++ b/doc/modules/ROOT/pages/cljs/shadow-cljs.adoc @@ -62,7 +62,7 @@ And connect to it with `cider-connect`. ...For that to work, `shadow-cljs.edn` contents like the following are assumed: ```clj - :dependencies [[cider/cider-nrepl "0.56.0"] ;; mandatory (unless it's inherited from deps.edn or otherwise present in the classpath of shadow-cljs's JVM process) + :dependencies [[cider/cider-nrepl "0.57.0"] ;; mandatory (unless it's inherited from deps.edn or otherwise present in the classpath of shadow-cljs's JVM process) [refactor-nrepl/refactor-nrepl "3.9.0"]] ;; refactor-nrepl is optional :nrepl {:middleware [cider.nrepl/cider-middleware ;; it's advisable to explicitly add this middleware. It's automatically added by shadow-cljs (if available in the classpath), unless `:nrepl {:cider false}` diff --git a/doc/modules/ROOT/pages/cljs/up_and_running.adoc b/doc/modules/ROOT/pages/cljs/up_and_running.adoc index 688420146..d39df8b1f 100644 --- a/doc/modules/ROOT/pages/cljs/up_and_running.adoc +++ b/doc/modules/ROOT/pages/cljs/up_and_running.adoc @@ -52,7 +52,7 @@ or in `build.gradle`: ---- dependencies { devImplementation 'nrepl:nrepl:1.3.1' - devImplementation 'cider:cider-nrepl:0.56.0' + devImplementation 'cider:cider-nrepl:0.57.0' devImplementation 'cider:cider-piggieback:0.5.3' } diff --git a/doc/modules/ROOT/pages/debugging/inspector.adoc b/doc/modules/ROOT/pages/debugging/inspector.adoc index 6c40aaeca..304361d82 100644 --- a/doc/modules/ROOT/pages/debugging/inspector.adoc +++ b/doc/modules/ROOT/pages/debugging/inspector.adoc @@ -85,6 +85,14 @@ You'll have access to additional keybindings in the inspector buffer | `cider-inspector-toggle-pretty-print` | Toggle the pretty printing of values in the inspector. You can set the `cider-inspector-pretty-print` customization option to `t`, if you always want values to be be pretty printed. +| kbd:[S] +| `cider-inspector-toggle-sort-maps` +| Toggle the sorting of maps by key in the inspector. You can set the `cider-inspector-sort-maps` customization option to `t` if you always want maps to be displayed sorted. + +| kbd:[D] +| `cider-inspector-toggle-only-diff` +| When inspecting a diff result, toggle only displaying the differing values. You can set the `cider-inspector-only-diff` customization option to `t` if you always want to only show the diff instead of all values. + | kbd:[d] | `cider-inspector-def-current-val` | Defines a var in the REPL namespace with current inspector value. If you tend to always choose the same name(s), you may want to set the `cider-inspector-preferred-var-names` customization option.