### Minimal Figwheel-main Leiningen Project Configuration Source: https://github.com/clojure-emacs/cider/blob/master/doc/modules/ROOT/pages/cljs/figwheel.adoc Example minimal `project.clj` for Figwheel-main integration, excluding optional Piggieback setup. ```clojure (defproject example-project "0.1.0-SNAPSHOT" :dependencies [[org.clojure/clojure "1.10.1"]] :profiles {:dev {:dependencies [[org.clojure/clojurescript "1.10.339"] [com.bhauman/figwheel-main "0.2.3"]]}}) ``` -------------------------------- ### Start shadow-cljs Watch Source: https://github.com/clojure-emacs/cider/blob/master/doc/modules/ROOT/pages/cljs/shadow-cljs.adoc Manually start the shadow-cljs server watching a specific build. ```sh $ shadow-cljs watch app ``` -------------------------------- ### Install CIDER with use-package (latest) Source: https://github.com/clojure-emacs/cider/blob/master/doc/modules/ROOT/pages/basics/installation.adoc Use the `use-package` macro to automatically install CIDER from the `master` branch. This ensures you have the latest development version. ```emacs-lisp (use-package cider :ensure t) ``` -------------------------------- ### Install CIDER via package-vc-install Source: https://github.com/clojure-emacs/cider/blob/master/doc/modules/ROOT/pages/faq.adoc Use this command in Emacs 29+ to install CIDER directly from the GitHub repository. ```text M-x package-vc-install https://github.com/clojure-emacs/cider ``` -------------------------------- ### Manual nREPL server startup command Source: https://github.com/clojure-emacs/cider/blob/master/doc/modules/ROOT/pages/basics/up_and_running.adoc Example of the command CIDER constructs when injecting dependencies for tools.deps projects. ```bash $ clojure -Sdeps '{:deps {nrepl {:mvn/version "1.7.0"} cider/cider-nrepl {:mvn/version "0.59.0"}}}' -m nrepl.cmdline --middleware '["cider.nrepl/cider-middleware"]' ``` -------------------------------- ### Start nREPL server using Leiningen Source: https://github.com/clojure-emacs/cider/blob/master/README.md Run this command in your project's terminal to start an nREPL server, typically used before connecting CIDER. ```shell lein repl ``` -------------------------------- ### Install Antora Source: https://github.com/clojure-emacs/cider/blob/master/doc/modules/ROOT/pages/contributing/docs.adoc Installs the Antora documentation generator using npm. Ensure Node.js is installed prior to running this command. ```shell $ npm install ``` -------------------------------- ### Install CIDER via package.el Source: https://github.com/clojure-emacs/cider/wiki/Installation Use this command to install CIDER directly from Emacs. Ensure your package list is refreshed if installation fails. ```emacs-lisp (unless (package-installed-p 'cider) (package-install 'cider)) ``` -------------------------------- ### Start Babashka nREPL Server Source: https://github.com/clojure-emacs/cider/blob/master/doc/modules/ROOT/pages/platforms/babashka.adoc Start the bundled nREPL server for Babashka. Connect to this server using CIDER's `cider-connect-clj` command. ```bash $ bb --nrepl-server ``` -------------------------------- ### Manual CIDER Installation Source: https://github.com/clojure-emacs/cider/wiki/Installation Manually install CIDER by adding it to your load path and requiring it. Ensure its dependencies like clojure-mode are also installed. ```emacs-lisp (add-to-list 'load-path "~/emacs.d/vendor") (require 'cider) ``` -------------------------------- ### Install CIDER with use-package (stable) Source: https://github.com/clojure-emacs/cider/blob/master/doc/modules/ROOT/pages/basics/installation.adoc Use the `use-package` macro to install stable releases of CIDER from MELPA Stable. This is a more conservative approach than installing from the master branch. ```emacs-lisp (use-package cider :ensure t :pin melpa-stable) ``` -------------------------------- ### Start nREPL server manually Source: https://github.com/clojure-emacs/cider/blob/master/doc/modules/ROOT/pages/basics/up_and_running.adoc Commands to start an nREPL server for Leiningen or plain Clojure CLI projects before connecting with CIDER. ```sh $ lein repl :headless ``` ```sh $ clj -Sdeps '{:deps {cider/cider-nrepl {:mvn/version "0.59.0"}}}' -m nrepl.cmdline --middleware "[cider.nrepl/cider-middleware]" ``` -------------------------------- ### Install JDK sources on Linux Source: https://github.com/clojure-emacs/cider/blob/master/doc/modules/ROOT/pages/troubleshooting.adoc Commands to install JDK source packages for navigation support on various Linux distributions. ```shell $ sudo apt install openjdk-21-source openjdk-21-doc ``` ```shell $ sudo dnf install java-21-openjdk-src java-21-openjdk-javadoc ``` ```shell $ guix package -i openjdk:jdk ``` -------------------------------- ### Launch nREPL server and CIDER client Source: https://github.com/clojure-emacs/cider/blob/master/README.md Open a project file and use this command to start an nREPL server with project dependencies loaded and connect CIDER to it. For Clojure(Script) buffers, this is bound to C-c C-x (C-)j. ```emacs-lisp M-x cider-jack-in ``` -------------------------------- ### Start Embedded nREPL with CIDER Handler Source: https://github.com/clojure-emacs/cider/blob/master/doc/modules/ROOT/pages/basics/middleware_setup.adoc Programmatically start an nREPL server using the CIDER-specific handler. ```clojure (ns my-app (:require [nrepl.server :as nrepl-server] [cider.nrepl :refer (cider-nrepl-handler)])) (defn -main [] (nrepl-server/start-server :port 7888 :handler cider-nrepl-handler)) ``` -------------------------------- ### Install CIDER using Emacs package-install Source: https://github.com/clojure-emacs/cider/blob/master/README.md Use this command within Emacs to install CIDER from a configured package repository. ```emacs-lisp M-x package-install RET cider RET ``` -------------------------------- ### Start Remote REPL Manually Source: https://github.com/clojure-emacs/cider/blob/master/dev/tramp-sample-project/README.md This command starts a headless REPL within the Docker container. It's an alternative to `cider-jack-in` for manual connection. ```shell cd /usr/src/app; lein repl :headless :host 0.0.0.0 :port 7888 ``` -------------------------------- ### Run Docker Image with Make Source: https://github.com/clojure-emacs/cider/blob/master/dev/tramp-sample-project/README.md Execute this command to start the Docker image for the Clojure project. This is a prerequisite for SSH connection. ```shell make run ``` -------------------------------- ### Configure 7-Zip for source lookup on Windows Source: https://github.com/clojure-emacs/cider/blob/master/doc/modules/ROOT/pages/caveats.adoc Add the 7-Zip installation directory to the Emacs exec-path to enable source lookup within .jar files. ```lisp (add-to-list 'exec-path "C:/Program Files/7-Zip") ``` -------------------------------- ### shadow-cljs.edn Configuration for nREPL Source: https://github.com/clojure-emacs/cider/blob/master/doc/modules/ROOT/pages/cljs/shadow-cljs.adoc Example shadow-cljs.edn configuration to include cider-nrepl and refactor-nrepl middleware for the nREPL server. ```clj :dependencies [[cider/cider-nrepl "0.59.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}` refactor-nrepl.middleware/wrap-refactor] ;; refactor-nrepl is optional :port 50655} ;; optional - if not specified, a random free port will be used ``` -------------------------------- ### Install CIDER on Gentoo Source: https://github.com/clojure-emacs/cider/wiki/Installation Commands to add necessary repositories and emerge CIDER on Gentoo Linux. Use the melpa overlay for the latest git version. ```bash layman -a gnu-elpa layman -a melpa-stable emerge -va app-emacs/cider ``` -------------------------------- ### Configure Antora Playbook for CIDER Modules Source: https://github.com/clojure-emacs/cider/blob/master/doc/modules/ROOT/pages/contributing/docs.adoc Example configuration for `antora-playbook.yml` specifying the repository URL, branch, and tags for building documentation. This is crucial for versioning and including specific releases. ```yaml - url: https://github.com/clojure-emacs/cider.git branches: master tags: ['v1.7.0', 'v1.8.0'] start_path: docs ``` -------------------------------- ### Start a remote devcontainer Source: https://github.com/clojure-emacs/cider/blob/master/doc/modules/ROOT/pages/basics/remote.adoc Use the devcontainer CLI to initiate a development container on a remote server. ```sh devcontainer up --workspace-folder /home/me/my-clj-code ``` -------------------------------- ### Configure CIDER to default to Krell REPL Source: https://github.com/clojure-emacs/cider/blob/master/doc/modules/ROOT/pages/cljs/krell.adoc Place this in a `.dir-locals.el` file in your project root to avoid prompts when starting a Krell REPL via `cider-jack-in-cljs`. ```clojure ((nil . ((cider-default-cljs-repl . krell)))) ``` -------------------------------- ### Run CIDER with Eldev Source: https://github.com/clojure-emacs/cider/blob/master/doc/modules/ROOT/pages/contributing/hacking.adoc Starts a clean Emacs process with CIDER and its dependencies loaded. ```shell eldev emacs ``` -------------------------------- ### Set initial REPL namespace Source: https://github.com/clojure-emacs/cider/blob/master/doc/modules/ROOT/pages/repl/configuration.adoc Configures the starting namespace for REPL sessions in Leiningen projects. ```clojure :repl-options {:init-ns 'my-ns} ``` -------------------------------- ### Custom REPL Initialization Namespace Source: https://github.com/clojure-emacs/cider/blob/master/doc/modules/ROOT/pages/cljs/shadow-cljs.adoc Namespace with a custom `cljs-repl` function to start and select a shadow-cljs build. ```clojure (ns user (:require [shadow.cljs.devtools.api :as shadow] [shadow.cljs.devtools.server :as server])) (defn cljs-repl "Connects to a given build-id. Defaults to `:app`." ([] (cljs-repl :app)) ([build-id] (server/start!) (shadow/watch build-id) (shadow/nrepl-select build-id))) ``` -------------------------------- ### deps.edn Configuration for shadow-cljs Source: https://github.com/clojure-emacs/cider/blob/master/doc/modules/ROOT/pages/cljs/shadow-cljs.adoc Example deps.edn configuration to include shadow-cljs as a dependency and set up a :dev alias. ```clj {:paths ["src"] :deps {... thheller/shadow-cljs {:mvn/version "2.15.6"} ... } :aliases {:dev {:extra-paths ["dev"]}}} ``` -------------------------------- ### Start nREPL server on Unix domain socket Source: https://github.com/clojure-emacs/cider/blob/master/doc/modules/ROOT/pages/basics/remote.adoc Launch an nREPL server listening on a socket file instead of a network port. ```sh $ clj -R:nREPL -m nrepl.cmdline --socket nrepl.sock ``` -------------------------------- ### Load CIDER from Source in .emacs Source: https://github.com/clojure-emacs/cider/blob/master/doc/modules/ROOT/pages/contributing/hacking.adoc Configures Emacs to load CIDER from a local directory instead of the installed package. ```lisp ;; load CIDER from its source code (add-to-list 'load-path "~/projects/cider/lisp") (load "cider-autoloads" t t) ``` -------------------------------- ### Connect to Remote REPL Source: https://github.com/clojure-emacs/cider/blob/master/dev/tramp-sample-project/README.md After starting a remote REPL manually, use this command in Emacs to connect to it. You will need to specify the host and port. ```emacs-lisp cider-connect ``` -------------------------------- ### Simple Indent Specifications Source: https://github.com/clojure-emacs/cider/blob/master/doc/modules/ROOT/pages/indent_spec.adoc Examples of basic indentation rules for common Clojure forms. ```clojure (do (something) ;; body (2-space indent) (quick)) ``` ```clojure (when-let [x (foo)] ;; position 0 — special arg (bar x)) ;; position 1+ — body ``` ```clojure (defn my-fn [x] ;; depth 0 — body-indented (inc x)) ;; depth 0 — body-indented ``` -------------------------------- ### Configure CIDER with use-package Source: https://github.com/clojure-emacs/cider/blob/master/doc/modules/ROOT/pages/faq.adoc Use this configuration in Emacs 30 to install a specific version of CIDER from GitHub. ```emacs-lisp (use-package cider :vc (:url "https://github.com/clojure-emacs/cider" :rev "v1.15.0") ) ``` -------------------------------- ### Example of a REPL handler exception Source: https://github.com/clojure-emacs/cider/blob/master/doc/modules/ROOT/pages/troubleshooting.adoc This shows an error caused by attempting to slurp a non-supported URL scheme in older CIDER versions. ```clojure user> (java.net.URI. "mailto:foo@bar.com") #object[java.net.URI 0x36966ca2 "mailto:foo@bar.com"]ERROR: Unhandled REPL handler exception processing message {:op slurp, :url mailto:foo@bar.com, :session 69c4d8e1-7bb4-45ad-8075-d21995fd50ab, :id 1579} java.net.UnknownServiceException: protocol doesn't support input at java.base/java.net.URLConnection.getInputStream(URLConnection.java:840) at cider.nrepl.middleware.slurp$slurp_url_to_content_PLUS_body.invokeStatic(slurp.clj:100) at cider.nrepl.middleware.slurp$slurp_url_to_content_PLUS_body.invoke(slurp.clj:82) at cider.nrepl.middleware.slurp$handle_slurp.invokeStatic(slurp.clj:117) at cider.nrepl.middleware.slurp$handle_slurp.invoke(slurp.clj:109) ``` -------------------------------- ### Start CIDER Jack-in Source: https://github.com/clojure-emacs/cider/blob/master/dev/tramp-sample-project/README.md After opening a file via TRAMP, use this command to initiate CIDER's jack-in process. You will be prompted for the SSH password. ```emacs-lisp cider-jack-in ``` -------------------------------- ### Define Indentation for `letfn` Macro with Tuple Format Source: https://github.com/clojure-emacs/cider/blob/master/doc/modules/ROOT/pages/config/indentation.adoc Example of a macro definition using the modern tuple format for `:style/indent`. This allows for more complex indentation rules, specifying indentation for different parts of the macro form. ```clojure (defmacro letfn "[DOCSTRING]" {:style/indent [[:block 1] [:inner 2 0]]} [fnspecs & body] ...cut for brevity...) ``` -------------------------------- ### Build Documentation Site Source: https://github.com/clojure-emacs/cider/blob/master/doc/modules/ROOT/pages/contributing/docs.adoc Clones the documentation repository and builds the site locally. After building, open `build/site/index.html` to preview. ```shell $ git clone https://github.com/clojure-emacs/docs.cider.mx $ cd docs.cider.mx $ make build ``` -------------------------------- ### Configure Launchpad for CIDER Source: https://github.com/clojure-emacs/cider/blob/master/doc/modules/ROOT/pages/basics/middleware_setup.adoc Use a babashka script to manage nREPL startup and middleware injection. ```clojure #!/usr/bin/env bb (require '[babashka.deps :as deps]) (deps/add-deps '{:deps {com.lambdaisland/launchpad {:mvn/version "RELEASE"}}}) (require '[lambdaisland.launchpad :as launchpad]) (launchpad/main {}) ``` ```clojure ;; ... as before ... (launchpad/main {:middleware [your.custom/nrepl-middleware]}) ``` -------------------------------- ### Run all tests Source: https://github.com/clojure-emacs/cider/blob/master/doc/modules/ROOT/pages/contributing/hacking.adoc Execute the full test suite using Eldev or Make. ```bash $ eldev[.bat] test --test-type all # Or: $ make test-all ``` -------------------------------- ### Run project linting Source: https://github.com/clojure-emacs/cider/blob/master/doc/modules/ROOT/pages/contributing/hacking.adoc Check coding standards and docstrings using Eldev or Make. ```bash $ eldev lint # Or: $ make lint ``` -------------------------------- ### Configure CIDER for Custom REPL Initialization Source: https://github.com/clojure-emacs/cider/blob/master/doc/modules/ROOT/pages/cljs/shadow-cljs.adoc Use this configuration in `.dir-locals.el` to integrate CIDER with a custom shadow-cljs REPL initialization form. ```elisp ((nil . ((cider-clojure-cli-aliases . ":dev") (cider-preferred-build-tool . clojure-cli) (cider-default-cljs-repl . custom) (cider-custom-cljs-repl-init-form . "(do (user/cljs-repl))") (eval . (progn (make-variable-buffer-local 'cider-jack-in-nrepl-middlewares) (add-to-list 'cider-jack-in-nrepl-middlewares "shadow.cljs.devtools.server.nrepl/middleware")))))) ``` -------------------------------- ### Configure default connection parameters in .dir-locals.el Source: https://github.com/clojure-emacs/cider/blob/master/doc/modules/ROOT/pages/basics/up_and_running.adoc Set project-specific default connection parameters to bypass prompts when connecting to JVM and shadow-cljs REPLs. ```lisp ((clojure-mode . ((cider-connect-default-params . (:host "localhost" :port 1234)) (cider-connect-default-cljs-params . (:host "localhost" :port 5678)) (cider-default-cljs-repl . shadow)))) ``` -------------------------------- ### Run unit tests Source: https://github.com/clojure-emacs/cider/blob/master/doc/modules/ROOT/pages/contributing/hacking.adoc Execute unit tests using Eldev or Make. ```bash $ eldev[.bat] test --test-type unit # Or: $ make test-unit ``` -------------------------------- ### Launch nREPL server and CIDER client with specified path Source: https://github.com/clojure-emacs/cider/blob/master/README.md Use this command with a prefix argument to specify the path to a Clojure project without needing to visit a file within it. ```emacs-lisp C-u M-x cider-jack-in ``` -------------------------------- ### View Leiningen test help Source: https://github.com/clojure-emacs/cider/blob/master/doc/modules/ROOT/pages/testing/running_tests.adoc Access documentation for Leiningen test selectors via the command line. ```sh $ lein help test ``` -------------------------------- ### Body-style method indentation Source: https://github.com/clojure-emacs/cider/blob/master/doc/modules/ROOT/pages/indent_spec.adoc Example of body-style indentation applied to a method definition. ```lisp (assoc [_ x] (.assoc pretty x 10)) ``` -------------------------------- ### Regular function indentation Source: https://github.com/clojure-emacs/cider/blob/master/doc/modules/ROOT/pages/indent_spec.adoc Example of standard internal indentation for a regular function form. ```lisp (assoc [_ x] (.assoc pretty x 10)) ``` -------------------------------- ### Run integration tests Source: https://github.com/clojure-emacs/cider/blob/master/doc/modules/ROOT/pages/contributing/hacking.adoc Execute integration tests using Eldev or Make. ```bash $ eldev[.bat] test --test-type integration # Or: $ make test-integration ``` -------------------------------- ### Example of non-instrumented map literal Source: https://github.com/clojure-emacs/cider/blob/master/doc/modules/ROOT/pages/debugging/debugger.adoc Large or complex map literals may not be instrumented by the debugger. ```clojure #dbg (count {:foo 2 :bar (inc 4) "foo" 6 "bar" 8 9 10 11 12 13 14 15 (inc 16) 17 (inc 18)}) ``` -------------------------------- ### Configure Piggieback REPL Middleware for Leiningen Source: https://github.com/clojure-emacs/cider/blob/master/doc/modules/ROOT/pages/cljs/figwheel.adoc Add this to your dev :repl-options. Not needed for `cider-jack-in-cljs`. ```clojure :nrepl-middleware [cider.piggieback/wrap-cljs-repl] ``` -------------------------------- ### Configure Piggieback Dependencies Source: https://github.com/clojure-emacs/cider/blob/master/doc/modules/ROOT/pages/cljs/up_and_running.adoc Add the necessary dependencies to your project configuration files. ```clojure ;; use whatever are the most recent versions here [cider/piggieback "0.6.1"] [org.clojure/clojure "1.12.0"] ``` -------------------------------- ### Compile project Source: https://github.com/clojure-emacs/cider/blob/master/doc/modules/ROOT/pages/contributing/hacking.adoc Compile the project and treat warnings as errors using Eldev. ```bash $ eldev -dtT compile --warnings-as-errors ``` -------------------------------- ### Compare macroexpand and macroexpand-all Source: https://github.com/clojure-emacs/cider/blob/master/doc/modules/ROOT/pages/debugging/macroexpansion.adoc Demonstrates how macroexpand-all recursively expands macros in argument positions, unlike macroexpand. ```clojure (macroexpand '(when a (when b c))) ;; => (if a (do (when b c))) ; inner when untouched (clojure.walk/macroexpand-all '(when a (when b c))) ;; => (if a (do (if b (do c)))) ; inner when expanded too ``` -------------------------------- ### Evaluate code in Weasel REPL Source: https://github.com/clojure-emacs/cider/blob/master/doc/modules/ROOT/pages/cljs/other_repls.adoc Example of evaluating a JavaScript alert within the connected Weasel REPL session. ```clojure cljs.user> (js/alert "Hello world!") ``` -------------------------------- ### Generate PDF with Tectonic Source: https://github.com/clojure-emacs/cider/blob/master/refcard/README.md Uses the Tectonic engine to compile the LaTeX source without requiring a full TeX installation. ```bash $ tectonic cider-refcard.tex ``` -------------------------------- ### Load REPL Utility Functions Source: https://github.com/clojure-emacs/cider/blob/master/doc/modules/ROOT/pages/repl/basic_usage.adoc The default code executed when a Clojure REPL starts to load standard utility functions. ```clojure (clojure.core/apply clojure.core/require clojure.main/repl-requires) ``` -------------------------------- ### Compare macroexpand-1 and macroexpand Source: https://github.com/clojure-emacs/cider/blob/master/doc/modules/ROOT/pages/debugging/macroexpansion.adoc Illustrates the difference between single-step expansion and recursive head-position expansion. ```clojure (defmacro unless [test & body] `(when (not ~test) ~@body)) (macroexpand-1 '(unless x a b)) ;; => (clojure.core/when (clojure.core/not x) a b) ; head is still `when', a macro (macroexpand '(unless x a b)) ;; => (if (clojure.core/not x) (do a b)) ; kept going: unless -> when -> if ``` -------------------------------- ### SSH into Docker Container Source: https://github.com/clojure-emacs/cider/blob/master/dev/tramp-sample-project/README.md This command establishes an SSH connection to the running Docker container. It's used for manually starting a REPL. ```shell make ssh ``` -------------------------------- ### Configure CIDER for shadow-cljs REPL Source: https://github.com/clojure-emacs/cider/blob/master/doc/modules/ROOT/pages/cljs/shadow-cljs.adoc Use this configuration in `.dir-locals.el` to set the default REPL type to shadow-cljs and specify build options. ```clojure ((nil . ((cider-default-cljs-repl . shadow) (cider-shadow-default-options . "") (cider-shadow-watched-builds . ("" ""))))) ``` -------------------------------- ### Rich Comment Block Example Source: https://github.com/clojure-emacs/cider/blob/master/doc/modules/ROOT/pages/usage/code_evaluation.adoc A standard Clojure rich comment block structure used by CIDER for documenting evaluation results. ```clojure (comment (add 1 2) ;; => 3 ) ``` -------------------------------- ### Configure Basilisp Command in basilisp.edn Source: https://github.com/clojure-emacs/cider/blob/master/doc/modules/ROOT/pages/platforms/basilisp.adoc This configuration snippet for `basilisp.edn` sets the `cider-basilisp-command` as a file-local variable, ensuring CIDER uses the specified executable path when jacking in from this project. ```clojure ;; Local Variables: ;; cider-basilisp-command: "c:/dev/venvs/312/Scripts/basilisp" ;; End: {} ``` -------------------------------- ### Inspect nREPL Message Log Source: https://github.com/clojure-emacs/cider/blob/master/doc/modules/ROOT/pages/troubleshooting.adoc Example format of request and response maps logged by CIDER when nREPL message logging is enabled. ```text (--> id "16" op "eval" session "eb3ef563-86ec-4d9e-9fa8-a56ce0e0f0b0" time-stamp "2020-03-15 16:01:42.963936000" code "(in-ns 'nrepl.completion)" ) (<-- id "16" session "eb3ef563-86ec-4d9e-9fa8-a56ce0e0f0b0" time-stamp "2020-03-15 16:01:43.027347000" ns "nrepl.completion" value "#namespace[nrepl.completion]" ) (<-- id "16" session "eb3ef563-86ec-4d9e-9fa8-a56ce0e0f0b0" time-stamp "2020-03-15 16:01:43.195358000" status ("done") ) ``` -------------------------------- ### Define Indentation for `with-in-str` Macro Source: https://github.com/clojure-emacs/cider/blob/master/doc/modules/ROOT/pages/config/indentation.adoc Example of a macro definition that includes an `:style/indent` hint. This hint is used by CIDER for dynamic indentation. ```clojure (defmacro with-in-str "[DOCSTRING]" {:style/indent 1} [s & body] ...cut for brevity...) ``` -------------------------------- ### Configure Leiningen for CIDER Source: https://github.com/clojure-emacs/cider/blob/master/doc/modules/ROOT/pages/basics/middleware_setup.adoc Add the cider-nrepl plugin to your project or profile. Avoid adding this to the :user profile to prevent unnecessary startup overhead. ```clojure :plugins [[cider/cider-nrepl "0.59.0"]] ``` ```clojure {:repl {:plugins [[cider/cider-nrepl "0.59.0"]]}} ``` -------------------------------- ### Pin CIDER to MELPA Stable Source: https://github.com/clojure-emacs/cider/wiki/Installation Configure Emacs to always use the MELPA Stable repository for CIDER. This ensures you get stable releases. ```emacs-lisp (add-to-list 'package-pinned-packages '(cider . "melpa-stable") t) ``` -------------------------------- ### Connect to Weasel REPL Source: https://github.com/clojure-emacs/cider/blob/master/doc/modules/ROOT/pages/cljs/other_repls.adoc Configure the ClojureScript namespace to connect to a Weasel REPL server. ```clojure (ns my.cljs.core (:require [weasel.repl :as repl])) (repl/connect "ws://localhost:9001") ``` -------------------------------- ### Pin CIDER to NonGNU ELPA Source: https://github.com/clojure-emacs/cider/blob/master/doc/modules/ROOT/pages/basics/installation.adoc Configure Emacs to use the NonGNU ELPA repository for CIDER. This ensures you install a stable version from a trusted source. ```emacs-lisp (add-to-list 'package-pinned-packages '(cider . "nongnu") t) ``` -------------------------------- ### Tunnel remote nREPL port to local machine Source: https://github.com/clojure-emacs/cider/blob/master/doc/modules/ROOT/pages/basics/remote.adoc Use SSH to tunnel the remote container port to the local machine while starting the nREPL server. ```sh 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.7.0\"} cider/cider-nrepl {:mvn/version \"0.59.0\"}}}' -m nrepl.cmdline -p 12345 -b 0.0.0.0 --middleware '[\"cider.nrepl/cider-middleware\"]' " ``` -------------------------------- ### Demonstrate macroexpand-1 behavior Source: https://github.com/clojure-emacs/cider/blob/master/doc/modules/ROOT/pages/debugging/macroexpansion.adoc Shows how macroexpand-1 performs a single step of expansion, leaving nested macros intact. ```clojure (macroexpand-1 '(cond a 1 :else 2)) ;; => (if a 1 (clojure.core/cond :else 2)) ; note the leftover cond ``` -------------------------------- ### Example of ineffective loop/recur breakpoint Source: https://github.com/clojure-emacs/cider/blob/master/doc/modules/ROOT/pages/debugging/debugger.adoc Breakpoints placed before forms containing recur may be ignored if the macro expansion moves recur out of the tail position. ```clojure (loop [i 0] #break (when (< i 10) (println i) (recur (inc i)))) ``` -------------------------------- ### Configure Macro Indentation with put-clojure-indent Source: https://github.com/clojure-emacs/cider/blob/master/doc/modules/ROOT/pages/config/indentation.adoc Teach clojure-mode how to indent a specific macro by adding this to your Emacs config. This example uses `put-clojure-indent` for the `with-in-str` macro. ```lisp (put-clojure-indent 'with-in-str '((:block 1))) ``` -------------------------------- ### Configure REPL Shortcut Dispatch Character Source: https://github.com/clojure-emacs/cider/blob/master/doc/modules/ROOT/pages/repl/keybindings.adoc Change the character used to trigger shortcut commands in the REPL. The default is ', but this example sets it to ';. This configuration is done using Emacs Lisp. ```lisp (setq cider-repl-shortcut-dispatch-char ?\;) ``` -------------------------------- ### List deprecated keybindings Source: https://github.com/clojure-emacs/cider/blob/master/doc/modules/ROOT/pages/usage/cider_mode.adoc Execute this command to view all currently deprecated keybindings and their recommended replacements. ```elisp M-x cider-list-deprecated-keybindings ``` -------------------------------- ### cider-load-buffer-and-switch-to-repl-buffer Source: https://github.com/clojure-emacs/cider/blob/master/doc/modules/ROOT/pages/usage/code_evaluation.adoc Loads the current buffer and switches to the relevant REPL buffer. ```APIDOC ## cider-load-buffer-and-switch-to-repl-buffer ### Description Loads (evaluates) the current buffer and switches to the relevant REPL buffer. Use a prefix argument to change the namespace of the REPL buffer to match the currently visited source file. ### Keybinding C-c M-z ```