Metadata-Version: 2.4
Name: neml2-langserv
Version: 0.2.0
Summary: Language server backing the NEML2 VS Code extension
Project-URL: Homepage, https://github.com/applied-material-modeling/neml2-langserv
Project-URL: Issues, https://github.com/applied-material-modeling/neml2-langserv/issues
Requires-Python: >=3.10
Description-Content-Type: text/markdown
Requires-Dist: pygls>=1.3
Requires-Dist: neml2>=2.1.4
Requires-Dist: nmhit>=0.1.2
Provides-Extra: dev
Requires-Dist: pytest; extra == "dev"
Requires-Dist: build; extra == "dev"

# NEML2 Language Support

VS Code extension providing language support for [NEML2](https://github.com/applied-material-modeling/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 ≥ 2.1.5`; on older builds the lens is silently hidden and the rest of the extension keeps working.

## Requirements

A Python environment with the [`neml2-langserv`](https://pypi.org/project/neml2-langserv/) package installed:

```
pip install neml2-langserv
```

That single install pulls in everything the language server needs — [`neml2`](https://pypi.org/project/neml2/) (≥ 2.1.4 for core features, ≥ 2.1.5 to enable the **Inspect model** lens) for the type/option metadata, [`nmhit`](https://pypi.org/project/nmhit/) (≥ 0.1.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](https://marketplace.visualstudio.com/items?itemName=ms-python.python). 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:

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

## Inspect a model

With `neml2 ≥ 2.1.5` 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:

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

## 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.
