clojure-emacs / cider

The Clojure Interactive Development Environment that Rocks for Emacs
https://cider.mx
GNU General Public License v3.0
3.52k stars 643 forks source link

Current way of displaying cheatsheet is inconvenient #3678

Closed katomuso closed 1 month ago

katomuso commented 1 month ago

Initially, cheatsheet was designed to display the entire hierarchy in a single Helm buffer (as seen in the screenshot at https://github.com/clojure-emacs/clojure-cheatsheet), allowing the user to search through the entire cheatsheet at once. However, the current implementation using completing-read requires us to navigate one level of the hierarchy at a time. This is much less convenient because we need to know where the item we are looking for is located, and even if we do know, it takes additional steps to do so.

Instead of having multiple completions for each level of the hierarchy, we can represent the hierarchy in a flat view, so a single line will display the full path to an item, with the path elements separated by a specific separator. For example, lines might look like Collections > Maps > Change > clojure.core/assoc with > as the separator. Using a fuzzy completion style (such as the one provided by the orderless.el package), we will be able to search for any element within the path, potentially displaying matches from multiple sections at the same time, which is especially convenient when displaying completions vertically (for example, with the vertico.el package).

This can be implemented by transforming the hierarchy into an appropriate flat format that will be displayed using completing-read. When the user selects a line, we split it by the separator and get the last item, which is the symbol. Then, we show the documentation for it as usual. I can do this, but I'm not sure if it's better to implement it as a separate function that can be called alternatively to cider-cheatsheet (something like cider-cheatsheet-flat) or to alternate the behavior of cider-cheatsheet when a prefix argument is passed.

johngit22 commented 1 month ago

Thank you for the tidbits of information 😌

John Boyd

On Fri, May 24, 2024, 4:18 AM Kato Muso @.***> wrote:

Initially, cheatsheet was designed to display the entire hierarchy in a single Helm buffer (as seen in the screenshot at https://github.com/clojure-emacs/clojure-cheatsheet), allowing the user to search through the entire cheatsheet at once. However, the current implementation using completing-read requires us to navigate one level of the hierarchy at a time. This is much less convenient because we need to know where the item we are looking for is located, and even if we do know, it takes additional steps to do so.

Instead of having multiple completions for each level of the hierarchy, we can represent the hierarchy in a flat view, so a single line will display the full path to an item, with the path elements separated by a specific separator. For example, lines might look like Collections > Maps > Change

clojure.core/assoc with > as the separator. Using a fuzzy completion style (such as the one provided by the orderless.el package), we will be able to search for any element within the path, potentially displaying matches from multiple sections at the same time, which is especially convenient when displaying completions vertically (for example, with the vertico.el package).

This can be implemented by transforming the hierarchy into an appropriate flat format that will be displayed using completing-read. When the user selects a line, we split it by the separator and get the last item, which is the symbol. Then, we show the documentation for it as usual. I can do this, but I'm not sure if it's better to implement it as a separate function that can be called alternatively to cider-cheatsheet (something like cider-cheatsheet-flat) or to alternate the behavior of cider-cheatsheet when a prefix argument is passed.

— Reply to this email directly, view it on GitHub https://github.com/clojure-emacs/cider/issues/3678, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAYXHWKHKIRAPTAUHQYFZDDZD3ZVZAVCNFSM6AAAAABIHDL3BOVHI2DSMVQWIX3LMV43ASLTON2WKOZSGMYTINZTGM3DONY . You are receiving this because you are subscribed to this thread.Message ID: @.***>

bbatsov commented 1 month ago

Instead of having multiple completions for each level of the hierarchy, we can represent the hierarchy in a flat view, so a single line will display the full path to an item, with the path elements separated by a specific separator. For example, lines might look like Collections > Maps > Change > clojure.core/assoc with > as the separator. Using a fuzzy completion style (such as the one provided by the orderless.el package), we will be able to search for any element within the path, potentially displaying matches from multiple sections at the same time, which is especially convenient when displaying completions vertically (for example, with the vertico.el package).

I'd be fine with this. It's true that the current UI is a bit clunky with the separate section selection step.

katomuso commented 1 month ago

Good! I have some preliminary work done, now I just need to think about how to best implement it from a user interaction perspective.