diff --git a/doc/modules/ROOT/assets/images/cider-cheatsheet-select-1.png b/doc/modules/ROOT/assets/images/cider-cheatsheet-select-1.png new file mode 100644 index 000000000..5562e2091 Binary files /dev/null and b/doc/modules/ROOT/assets/images/cider-cheatsheet-select-1.png differ diff --git a/doc/modules/ROOT/assets/images/cider-cheatsheet-select-2.png b/doc/modules/ROOT/assets/images/cider-cheatsheet-select-2.png new file mode 100644 index 000000000..b881666b9 Binary files /dev/null and b/doc/modules/ROOT/assets/images/cider-cheatsheet-select-2.png differ diff --git a/doc/modules/ROOT/assets/images/cider-cheatsheet-select-3.png b/doc/modules/ROOT/assets/images/cider-cheatsheet-select-3.png new file mode 100644 index 000000000..e9ed06f50 Binary files /dev/null and b/doc/modules/ROOT/assets/images/cider-cheatsheet-select-3.png differ diff --git a/doc/modules/ROOT/assets/images/cider-cheatsheet.png b/doc/modules/ROOT/assets/images/cider-cheatsheet.png new file mode 100644 index 000000000..f7250b294 Binary files /dev/null and b/doc/modules/ROOT/assets/images/cider-cheatsheet.png differ diff --git a/doc/modules/ROOT/pages/usage/misc_features.adoc b/doc/modules/ROOT/pages/usage/misc_features.adoc index 0378e8827..19da4de27 100644 --- a/doc/modules/ROOT/pages/usage/misc_features.adoc +++ b/doc/modules/ROOT/pages/usage/misc_features.adoc @@ -329,3 +329,23 @@ If you would prefer for it to have a lower precedence, you can change `cider-xre ---- TIP: See https://www.gnu.org/software/emacs/manual/html_node/elisp/Setting-Hooks.html[Setting Hooks] for more information about depth. + +== Cheatsheet + +There are two ways to access https://clojure.org/api/cheatsheet[Clojure cheatsheet] in CIDER. + +The first one is available through `cider-cheatsheet` command and displays the cheatsheet in a popup buffer. It is possible to change how the hierarchy is indented by customizing `cider-cheatsheet-indentation-function`. This is how it looks with two windows displaying the cheatsheet buffer side by side: + +image::cider-cheatsheet.png[Displaying cheatsheet in buffer] + +The second way is available through `cider-cheatsheet-select` command, which uses completions in the minibuffer to find a var in the cheatsheet. By default, it provides a multi-step selection process where you need to go section by section until you find the var. This is how it looks in the minibuffer: + +image::cider-cheatsheet-select-1.png[Selecting section in cheatsheet] + +image::cider-cheatsheet-select-2.png[Selecting var in cheatsheet] + +By customizing variable `cider-cheatsheet-select-path` or using a prefix argument when calling `cider-cheatsheet-select`, we can change the behavior of `cider-cheatsheet-select` so each candidate is represented as a full path to the var. This can be useful with fuzzy completion style and vertical candidates display, as in that case, we can search in any element of the path, possibly getting matches from multiple categories at the same time. We can change which string is used to separate elements of the path by customizing `cider-cheatsheet-select-path-separator`, but note that it can't contain characters present in elements of a path, such as `/` and `&`. This is how it looks with such a workflow: + +image::cider-cheatsheet-select-3.png[Selecting path in cheatsheet] + +It is also possible to control which function is used to show documentation by customizing `cider-cheatsheet-doc-function`. By default, it is set to `cider-doc-lookup` to show documentation using standard documentation facilities, but it can also be set to `cider-clojuredocs-lookup` to show documentation from ClojureDocs, or it can be set to a custom function that accepts the selected var as an argument.