Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/noir-lang/noir/llms.txt

Use this file to discover all available pages before exploring further.

The Noir Language Server provides IDE features by implementing the Language Server Protocol (LSP). It consists of two components:
  • Server — the nargo lsp process that performs compilation and analysis.
  • Client — an editor plugin that communicates with the server and surfaces its results.

Language server

The server is bundled with Nargo. If Nargo is installed, nargo lsp is available. You can confirm it is present by running:
nargo --help
Look for lsp in the list of subcommands. The server is normally started automatically by the editor plugin and does not need to be launched manually. If you need to start it directly, run:
nargo lsp

Language client (VS Code)

Noir provides an official Language Client for Visual Studio Code via the vscode-noir extension.

Installation

Install the extension from the Visual Studio Marketplace.

Setup

1

Open your Noir project as the workspace root

Open the folder containing your Nargo.toml directly in VS Code. The LSP assumes the VS Code workspace root is the same as the Noir project root.
If you open a parent folder and your Noir project is a subfolder, LSP features may not work correctly. Always open your Noir project’s root folder directly.
2

Enable the LSP

The extension is active by default. If you have disabled it, open the extension settings and enable Noir: Enable LSP.
3

Verify the LSP is running

When the language server is running, you will see codelens buttons above functions in .nr files:Above .nr functions you will see inline codelens buttons for Compile, Execute, and Info actions. These let you compile, measure circuit size, and execute programs directly from the editor.You will also see your #[test] functions appear in the VS Code Testing panel (the beaker icon in the sidebar), where you can run and inspect individual tests.

Features

The Noir LSP provides the following editor features:
FeatureDescription
DiagnosticsErrors and warnings are shown inline as you edit.
Go-to-definitionNavigate to the definition of functions, types, and variables.
Hover documentationHover over identifiers to see their type signatures and doc comments.
Code completionSuggests completions for identifiers, fields, and methods.
CodelensInline action buttons for compiling, executing, and running tests.
Inlay hintsDisplay inferred types next to expressions.

Configuration

Open the vscode-noir extension settings (search for “Noir” in VS Code settings) to configure the following options:
SettingDescription
Noir: Enable LSPEnable or disable the language server. When enabled, the extension launches nargo lsp automatically.
Noir: Nargo FlagsAdditional flags appended when the extension calls nargo lsp. For example: --program-dir ./circuits.
Noir: Nargo PathAbsolute path to the nargo binary. Useful if nargo is not on the editor’s PATH.
Noir > Trace: ServerSet to messages or verbose to log LSP protocol messages between the client and server. Useful for diagnosing LSP issues.

Other editors

Any editor that supports LSP can be configured to use nargo lsp as a language server. The exact configuration format depends on the editor. The server is started by executing nargo lsp and communicating over standard input/output. Configure your editor’s LSP client to point to the nargo binary with the lsp subcommand.
Using nvim-lspconfig:
local lspconfig = require('lspconfig')
local configs = require('lspconfig.configs')

if not configs.noir then
  configs.noir = {
    default_config = {
      cmd = { 'nargo', 'lsp' },
      filetypes = { 'noir' },
      root_dir = lspconfig.util.root_pattern('Nargo.toml'),
    },
  }
end

lspconfig.noir.setup {}
Add the following to your languages.toml:
[[language]]
name = "noir"
language-servers = ["nargo-lsp"]

[language-server.nargo-lsp]
command = "nargo"
args = ["lsp"]

Shell completions

Nargo can generate shell completion scripts to improve CLI ergonomics:
nargo generate-completion-script zsh > ~/.zsh/completions/_nargo
Supported shells: bash, zsh, fish, powershell, elvish. See the Nargo CLI reference for details.

Build docs developers (and LLMs) love