Liking cljdoc? Tell your friends :D

Using Fireworks with IntelliJ IDEA + Cursive

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.


Setting up the commands


REPL Commands can be configured in:
Settings > Languages and Frameworks > Clojure > REPL Commands.


To set up a Toggle Fireworks REPL Command:


  1. Add new command in the Global Commands list, naming it Toggle Fireworks

  1. Paste the following into the code window of the Execute command option in the Execution section of the REPL Commands settings panel:
(do (let [qf (quote ~selected-form)]
       (if (list? qf)
         (if (contains? #{'!? '? '?> '!?>} (first qf))
           (second qf)
           (list '? qf))
         (case qf
           ?   '!?
           !?  '?
           ?>  '!?>
           !?> '?>
           (list '? qf)))))

  1. Configure all the other options in this settings panel to match screenshot below.

  1. Finally, click on the Apply button at the bottom right of the Settings panel.


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)))))


Setting up keybindings

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

Keyboard shortcuts
Ctrl+kJump to recent docs
Move to previous article
Move to next article
Ctrl+/Jump to the search field
× close