Requirements: IntelliJ IDEA Ultimate + Cursive.
You can optimize the ergonomics of using Firework's print-and-return macros by setting up some REPL Commands. These commands can be bound to the shortcut of your choosing and will execute the wrapping and unwrapping of the form which is selected. Note, the form must be visually selected in order for these commands to perform the action.
The Toggle Fireworks command below, for example, would transform:
(+ 1 1)
into
(? (+ 1 1))
Conversely, it would transform (? (+ 1 1)) into (+ 1 1).
If the ? symbol is selected within an existing wrapped form, the Toggle Fireworks
command will toggle the symbol to !? (silent version of ?), and vice-versa.
The Toggle Tap command below, for example, would transform:
(+ 1 1)
into
(?> (+ 1 1))
Conversely, it would transform (?> (+ 1 1)) into (+ 1 1).
If the ?> symbol is selected within an existing wrapped form, the Toggle Fireworks Tap>
command will toggle the symbol to !?> (silent version of ?>), and vice-versa.
REPL Commands can be configured in:
Settings > Languages and Frameworks > Clojure > REPL Commands.
To set up a Toggle Fireworks REPL Command:
(do (let [qf (quote ~selected-form)]
(if (list? qf)
(if (contains? #{'!? '? '?> '!?>} (first qf))
(second qf)
(list '? qf))
(case qf
? '!?
!? '?
?> '!?>
!?> '?>
(list '? qf)))))

To set up a Toggle Fireworks Tap REPL Command,
repeat the above 4 steps, giving the command the name Toggle Fireworks Tap, and use the following code for the Execute command option in the Execution section:
(do (let [qf (quote ~selected-form)]
(if (list? qf)
(if (contains? #{'!? '? '?> '!?>} (first qf))
(second qf)
(list '?> qf))
(case qf
? '!?
!? '?
?> '!?>
!?> '?>
(list '?> qf)))))
Go to Settings > Keymap, and search for Toggle Fireworks in the search bar on the right side in the Keymap section:

Right-click on each command and assign it a shortcut:

Can you improve this documentation?Edit on GitHub
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |