/noir-mode

Emacs major mode for Aztec's Noir ZK DSL

Primary LanguageEmacs LispGNU General Public License v3.0GPL-3.0

noir-mode

Introduction

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.

Installation

Straight.el

(straight-use-package
 '(noir-mode :type git :host github :repo "ax0/noir-mode"))

Manual

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

Key bindings

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

Customisation group

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.

Quality of life improvements

Colour output

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-compilation package.