NetStacksNetStacks

Language Support (LSP)

Python diagnostics, completion, hover and go-to-definition through the built-in Pyrefly language server, custom language servers, and YANG/XML/JSON formatting.

Overview

NetStacks can connect the workspace editor to a language server (LSP) for richer editing. Language servers provide:

  • Diagnostics (errors and warnings underlined in the code)
  • Autocomplete
  • Hover documentation
  • Go to definition

One language server is built in: Pyrefly for Python. You can add any other language server that speaks LSP over standard input/output.

Where It Works

  • Standalone desktop app: in the workspace editor and in the Python Engine script editor.
  • Enterprise mode and the web terminal: not available. Language servers run in the local agent, which is not part of a Controller deployment. Editors show a banner saying the language server isn't available in Enterprise Mode yet, and basic syntax highlighting still works.
  • Remote workspaces: language servers run on your own computer, not the remote server, so they don't work reliably with remote files.

Language servers are not attached to Docs editors or the SFTP file editor.

Python with Pyrefly

Pyrefly (version 1.0.0) handles .py and .pyi files. It is downloaded the first time you need it rather than shipped with the app.

  1. Open a Python file in a workspace. A banner asks Get rich Pyrefly language features?
  2. Click Install. NetStacks downloads Pyrefly from PyPI, checks it against a pinned SHA-256 checksum, extracts it and runs a quick test. Progress shows as Downloading, Verifying, Extracting and Verifying binary.
  3. When it finishes, diagnostics and completion start working in the open file.

Skip hides the banner for now; Don't ask again stops it appearing. You can still install Pyrefly later from Settings → Workspaces → Language Features. If the download fails, use Retry.

Pyrefly is available for macOS (Intel and Apple silicon), Linux (x86_64 and arm64) and Windows (x86_64 and arm64). It is installed in the NetStacks data folder under lsp/pyrefly/.

Settings → Language Features

Open Settings → Workspaces and expand Language Features. Servers are grouped under Built-in and Custom. Each row shows the name, language, file extensions and a status (for example installed, not-installed, installing or disabled).

ButtonWhat it does
InstallDownload a built-in server (Pyrefly)
Uninstall / RemoveRemove a downloaded server, or delete a custom one
EditChange a server's settings
Disable / EnableTurn a server off or on without removing it

Add a Custom Language Server

Install the language server on your computer first (for example gopls for Go). Then:

  1. In Language Features, click + Add Language Server.
  2. Fill in the fields (see the table below).
  3. Click Test connection. The test must pass before you can save.
  4. Click Save.
FieldExampleNotes
Plugin IDgoplsShort unique ID
Display NameGo (gopls)Shown in the list
Monaco Language IDgoMust match the language the editor uses for the file (see File Types and Highlighting)
File Extensions (comma-separated).goFiles this server handles
CommandgoplsRun exactly as entered; use a full path if needed
Args (space-separated)serveArguments that start the server in stdio mode
The language ID must match
The editor only knows the languages in its extension list. If you add a server for a language the editor shows as plain text, the server never attaches. For example, there is no separate language for network configs: .cfg files are treated as ini.

YANG, XML and JSON

These work without a language server, in every Monaco editor in the app (including enterprise mode):

  • YANG (.yang): syntax highlighting and a formatter that re-indents by brace depth while keeping strings and comments as they are.
  • XML: Monaco's highlighting plus a formatter (2-space indent).
  • JSON: Monaco's built-in validation and formatting.

Run Format Document from the editor's right-click menu or the Monaco command palette (F1).

For Cisco and Junos configuration highlighting, see Network CLI Highlighting.

Troubleshooting

  • No banner and no Python features: check that Pyrefly is installed and enabled in Language Features, and that you did not choose Don't ask again before installing.
  • Install fails: the download needs access to files.pythonhosted.org. Check your proxy or firewall, then click Retry.
  • Custom server test fails: run the same command and arguments in a terminal to confirm it starts, and use the full path to the binary if it is not on the app's PATH.