This package provides an Emacs major mode for editing Noir code. It is derived from rust-mode and inherits the syntax highlighting mechanisms provided there with appropriate modifications. Mnemonic key bindings for running nargo commands in a compilation buffer are provided.
(straight-use-package
'(noir-mode :type git :host github :repo "ax0/noir-mode"))
Assuming this repository has been cloned to /path/to/noir-mode and rust-mode is installed, place the following in your init.el file:
(add-to-list 'load-path "/path/to/noir-mode")
(load "noir-mode")
The following key bindings are meant to be mnemonic, being derived from either the command or its action:
| Key binding | Command | Mnemonic (if applicable) |
|---|---|---|
| C-c C-n C-c | nargo-check |
|
| C-c C-n C-s | nargo-codegen-verifier |
Generate Solidity verifier |
| C-c C-n C-b | nargo-compile |
Build program |
| C-c C-n C-x | nargo-execute |
Execute program |
| C-c C-n C-i | nargo-info |
|
| C-c C-n C-p | nargo-prove |
|
| C-c C-n C-t | nargo-test |
|
| C-c C-n C-v | nargo-verify |
The noir-mode customisation group is provided and contains the following user-customisable variables:
| Variable | Description | Default value |
|---|---|---|
nargo-bin |
Path to Nargo executable | nargo |
nargo-allow-warnings |
Nargo flag for warning if unused variables are present | nil |
nargo-show-output |
Nargo flag for showing output of println statements |
nil |
nargo-show-ssa |
Nargo flag for showing SSA IR | nil |
These variables may be toggled in the usual manner via M-x customize-group.
nargo colours its output via ANSI escape sequences, which are not parsed by compilation-mode by default. Two solutions to this would be
- Using the following code:
(require ansi-color) (add-hook 'compilation-filter-hook 'ansi-color-compilation-filter) - Installing the
fancy-compilationpackage.