Norns REPL (VSCode Extension)

Norns REPL

This is a very simple extension that allows you to interact with Norns in a VSCode terminal, much like you would from the Maiden web interface.

Demo

The extension connects to Matron on Norns using a websocket. Lua code entered in the terminal is sent to Matron when you press return, and the results are printed in the terminal. There is basic support for command history using the up/down arrows.

Please file any bugs you find as a GitHub Issue!

Commands

nornsREPL.matron.connect

  • Connect to the Matron REPL at the configured Norns host and port
  • Command Palette: “Norns REPL: Connect to Matron…”

nornsREPL.matron.send

  • Send a command to the Matron REPL at the configured Norns host and port
  • Command Palette: “Norns REPL: Send Command to Matron…”

nornsREPL.crone.connect

  • Connect to the Crone REPL at the configured Norns host and port
  • Command Palette: “Norns REPL: Connect to Crone…”

nornsREPL.crone.send

  • Send a command to the Crone REPL at the configured Norns host and port
  • Command Palette: “Norns REPL: Send Command to Crone…”

nornsREPL.script.reload

  • Reload the current script using norns.script.load(norns.state.script)
  • Command Palette: “Norns REPL: Reload Script”

nornsREPL.sleep

  • Put Norns to sleep using norns.shutdown()
  • Command Palette: “Norns REPL: Sleep”

Configuration

nornsREPL.host

  • Norns hostname to connect to
  • Default: norns.local

nornsREPL.matron.port

  • Matron websocket port to connect to
  • Default: 5555

nornsREPL.crone.port

  • Crone websocket port to connect to
  • Default: 5556

nornsREPL.maxHistory

  • Maximum number of previous commands to store in history
  • Default: 100

1.4.0

Dedicated commands for reloading the current script and shutting down Norns, as well as commands for sending arbitrary one-off messages to Matron/Crone. These can be used to set up custom tasks that communicate with Norns like so:

// tasks.json
{
  "version": "2.0.0",
  "tasks": [
    {
      "label": "Play Note",
      "command": "${command:nornsREPL.matron.send}",
      "args": ["engine.hz(440)"]
    }
  ]
}

1.5.0 (Latest Version)

Live coding for Matron/Crone:

  • When connected to the Matron REPL and editing a Lua file, you can send the current selection to Matron with Ctrl + Enter
  • When connected to the Crone REPL and editing a Supercollider file, you can send the current selection to Crone with Ctrl + Enter
  • If no text is selected, then Ctrl + Enter will instead send the current line to the respective REPL
  • On macOS, all Ctrl + Enter keybindings are instead mapped to Cmd + Enter
55 Likes

Instant install. Thank you!

3 Likes

whoa! been talking to some people about this… and now, here it is. thank you so much for sharing.

3 Likes

wow, this is great! many thanks

2 Likes

Pushed up a new version. You can now navigate the prompt using the arrow keys and insert/delete at the current cursor position.

4 Likes

One more small update to add a Crone REPL command :slight_smile:

1 Like

Pushed up another update with some more commands. See the original post for more information.

I also added support for ;restart and ;install commands in Matron, and made some fixes to the command prompt.

Enjoy!

6 Likes

:clap: This is great! Thanks for sharing :grinning:

2 Likes

Gosh nice and surely helpful for many. I need to get my Emacs act together.

2 Likes

this is so great, vscode is one of my go-to editors :man_technologist:

I’m wondering- is it possible to do a nornsREPL.crone.send of the current line in the editor or a current selection in the editor? I.e. I’ve been live coding with maiden and it’s nice to be able to just press Ctl+Enter or something similar to send code to maiden right in vscode (similar to SuperCollider ide). I tried looking into this for vscode and it seemed complicated and couldn’t figure it out

3 Likes

yeeeeeeee nice job! :peacock:

1 Like

Just published 1.5.0 with live coding for both Matron/Crone:

  • When connected to the Matron REPL and editing a Lua file, you can send the current selection to Matron with Ctrl + Enter

  • When connected to the Crone REPL and editing a Supercollider file, you can send the current selection to Crone with Ctrl + Enter

  • If no text is selected, then Ctrl + Enter will instead send the current line to the respective REPL

  • On macOS, all Ctrl + Enter keybindings are instead mapped to Cmd + Enter

Great suggestion!

3 Likes

cool!!! thank you thank you thank you @midouest ! that is so cool. the patch you wrote is way more involved than I thought - your solution is very clever and concise! can’t wait to integrate this into my wip live coding norns script! ah you made my day!

1 Like

Just playing with the ctrl/cmd+Enter shortcut - this is brilliant!

2 Likes

I am sure I’m doing something wrong but when I try to connect to crone I get this error popup:

**Command 'Norns REPL: Connect to Crone...' resulted in an error (Running the contributed command: 'nornsREPL.crone.connect' failed.)**

EDIT: I figured it out after realizing the norns repl cli needed to be running before this extension would work. :stuck_out_tongue: