Skip to main content

NEML2 Language Support

VS Code extension providing language support for NEML2 input files.

Features

  • Completion — type names for type = assignments, and option names with inline type hints inside typed blocks
  • Hover documentation — docstrings for types and options shown on hover
  • Format on save — re-indents the document consistently via the nmhit formatter
  • Inspect model — a 🔬 CodeLens above every [model] block under [Models] (and a matching NEML2: Inspect Model palette command) runs neml2-inspect on the current buffer and renders the model's inputs, outputs, parameters, and buffers in a side-panel webview. Requires neml2 ≥ 3.0.2; on older builds the lens is silently hidden and the rest of the extension keeps working.
  • User extensions — set neml2.load to a list of .py files, package directories, or dotted module names; each entry is forwarded as --load to neml2-syntax and neml2-inspect so custom @register_native classes appear alongside the built-in ones in completions, hovers, and Inspect.

Requirements

A Python environment with the neml2-langserv package installed:

pip install neml2-langserv

That single install pulls in everything the language server needs — neml2 (≥ 3.0.2) for the type/option metadata and the inspect feature, nmhit (≥ 0.2.2) for the formatter, and pygls for the LSP transport.

The extension runs the server with whichever Python interpreter is selected in the Python extension. If neml2-langserv is not installed in that interpreter on first activation, the extension prompts you to install it.

Setup

NEML2 input files share the .i extension with MOOSE input files. To tell the extension that a file is a NEML2 input, add the following as the first line:

# neml2

Files without this marker are treated as MOOSE input (or plain text) and the NEML2 language server will not activate for them.

Format on save

Enable the built-in VS Code setting to auto-format on save:

// .vscode/settings.json
{
  "[neml2]": {
    "editor.formatOnSave": true
  }
}

Inspect a model

With neml2 ≥ 3.0.2 installed, a 🔬 Inspect model CodeLens appears above each [name] sub-block under [Models]. Click it to open a side-panel webview listing the model's inputs, outputs, parameters, and buffers (with their tensor types, dtypes, and device tags) for the current buffer — unsaved edits are picked up automatically.

The same action is available from the command palette as NEML2: Inspect Model, which prompts you to pick a model.

To hide the lenses (the palette command stays available), set:

// settings.json
{
  "neml2.inspect.codeLens.enabled": false
}

Loading user extensions

If your input files reference @register_native types defined outside the neml2 package (e.g. project-specific models), tell the language server to import them at startup so completions, hovers, and Inspect resolve those types. Add an entry per extension to neml2.load — each is either a filesystem path to a .py file or a package directory, or a dotted module name on the active interpreter's sys.path:

// .vscode/settings.json
{
  "neml2.load": [
    "${workspaceFolder}/extensions/my_models.py",
    "my_project.neml2_ext"
  ]
}

The list is forwarded one-to-one as --load arguments to both neml2-syntax (driving completions/hovers) and neml2-inspect (driving the Inspect Model panel). Entries import in the order given, so a later module may depend on names registered by an earlier one. Changing the setting reloads the in-process syntax catalog automatically.

MOOSE compatibility

This extension does not claim the .i extension globally, so existing MOOSE workflows are unaffected. Only files whose first line matches # neml2 (optionally followed by other text) are switched to the neml2 language mode.

Metadata

Release files for neml2-langserv 0.3.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for neml2-langserv 0.3.3
File Size Uploaded
neml2_langserv-0.3.3.tar.gz 15.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for neml2-langserv 0.3.3
File Interpreter ABI Platform
neml2_langserv-0.3.3-py3-none-any.whl Python 3 none any Details

Total release size: 30.9 kB

Release files / neml2_langserv-0.3.3.tar.gz

Download URL neml2_langserv-0.3.3.tar.gz
Size 15.2 kB
Tags Source
SHA-256 checksum
How to use checksums
87c6ecd8ba544f2cf596edbaf29e884c906e8bae56680ebb41285adfa18a7019
BLAKE2b-256 checksum
How to use checksums
ad4d741324749ec379de57b4dbdc3e59852a60b54906c32d3c32405fa92227d2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jul 1, 2026.

Transparency log

Release files / neml2_langserv-0.3.3-py3-none-any.whl

Download URL neml2_langserv-0.3.3-py3-none-any.whl
Size 15.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a1a40f12a04c5ab16a71a4f95ccb15bf094d4c40eefab8f100055c2c5f8c32eb
BLAKE2b-256 checksum
How to use checksums
f2d86e21af2647fc0b955495d5d48135191c72ece0d52863dd14b1ab30f2cc0a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jul 1, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.3.3 This release

2 release files

0.3.2

2 release files

0.3.1

2 release files

0.3.0

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.2

2 release files

0.1.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page