Skip to content

Latest commit

 

History

History
48 lines (36 loc) · 1.99 KB

custom-commands.md

File metadata and controls

48 lines (36 loc) · 1.99 KB

Calva Doccumentation has Moved

calva.io

Running Custom REPL Commands

Calva supports configuration of custom command snippets that you can execute in the REPL at will. If your workflow has you repeatedly evaluate a particular piece of code, you can use the setting calva.customREPLCommandSnippets to configure it and then use the command Run Custom REPL Command to access it. The command will give you a menu with the snippets you have configured.

The calva.customREPLCommandSnippets is an object/dictionary with the following fields:

  • name: The name of the snippet as it will appear in the picker menu
  • snippet: The code that will be evaluated
  • ns: (optional) Namespace to evaluate the command in. If omitted the command will be executed in the namespace of the current editor.
  • replType: Which REPL window to use for the evaluation. Either "clj" or "cljs"

E.g. with these settings:

    "calva.customREPLCommandSnippets": [
        {
            "name": "Foo",
            "snippet": "(println :foo)",
            "ns": "acme.test.foo-test",
            "repl": "cljs"
        },
        {
            "name": "Bar",
            "snippet": "(println :bar)",
            "ns": "acme.test.bar-test",
            "repl": "clj"
        },
        {
            "name": "Refresh",
            "snippet": "(refresh)",
            "repl": "clj"
        }
    ]

You will get this menu.

image

The items are numbered for you so that you can choose them in predictable way. The default keyboard shortcut for the command is ctrl+alt+c, .. Which means that to execute the Refresh command, (refresh), in the clj REPL, you could do:

ctrl+alt+c, ., 3, ENTER.