Language server backing the NEML2 VS Code extension
Project description
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
nmhitformatter - Inspect model — a 🔬 CodeLens above every
[model]block under[Models](and a matchingNEML2: Inspect Modelpalette command) runsneml2-inspecton the current buffer and renders the model's inputs, outputs, parameters, and buffers in a side-panel webview. Requiresneml2 ≥ 3.0.2; on older builds the lens is silently hidden and the rest of the extension keeps working. - User extensions — set
neml2.loadto a list of.pyfiles, package directories, or dotted module names; each entry is forwarded as--loadtoneml2-syntaxandneml2-inspectso custom@register_nativeclasses 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.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file neml2_langserv-0.3.2.tar.gz.
File metadata
- Download URL: neml2_langserv-0.3.2.tar.gz
- Upload date:
- Size: 14.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7ce358b2a83832327af9a5a55dfd891e759f39fb3d3692b86d4b39e7761d6bd9
|
|
| MD5 |
0b50f564d652314975ee2a5861d5f545
|
|
| BLAKE2b-256 |
26142d9b77fb3f5fdf16106a4c0aff4a72e64eeccb739891ccc390d9b17633dd
|
Provenance
The following attestation bundles were made for neml2_langserv-0.3.2.tar.gz:
Publisher:
publish.yml on applied-material-modeling/neml2-langserv
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
neml2_langserv-0.3.2.tar.gz -
Subject digest:
7ce358b2a83832327af9a5a55dfd891e759f39fb3d3692b86d4b39e7761d6bd9 - Sigstore transparency entry: 2030261698
- Sigstore integration time:
-
Permalink:
applied-material-modeling/neml2-langserv@11d4a0451978e1d2bbb73562950de2556af4dc83 -
Branch / Tag:
refs/tags/v0.3.2 - Owner: https://github.com/applied-material-modeling
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@11d4a0451978e1d2bbb73562950de2556af4dc83 -
Trigger Event:
push
-
Statement type:
File details
Details for the file neml2_langserv-0.3.2-py3-none-any.whl.
File metadata
- Download URL: neml2_langserv-0.3.2-py3-none-any.whl
- Upload date:
- Size: 15.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7fd4ff61a720483b200965702c13b4f050a54fc3f76f6b83cb743634542b0cfc
|
|
| MD5 |
35d3c7b00cf7b4147b7ceaeed94ecbf5
|
|
| BLAKE2b-256 |
47f835f2872b34fb37dd02c8dd22b5ed96f55dd393a8b10fcb765291b373d7ef
|
Provenance
The following attestation bundles were made for neml2_langserv-0.3.2-py3-none-any.whl:
Publisher:
publish.yml on applied-material-modeling/neml2-langserv
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
neml2_langserv-0.3.2-py3-none-any.whl -
Subject digest:
7fd4ff61a720483b200965702c13b4f050a54fc3f76f6b83cb743634542b0cfc - Sigstore transparency entry: 2030261798
- Sigstore integration time:
-
Permalink:
applied-material-modeling/neml2-langserv@11d4a0451978e1d2bbb73562950de2556af4dc83 -
Branch / Tag:
refs/tags/v0.3.2 - Owner: https://github.com/applied-material-modeling
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@11d4a0451978e1d2bbb73562950de2556af4dc83 -
Trigger Event:
push
-
Statement type: