RunMat
GitHub

Language Server Protocol (LSP)

runmat-lsp provides editor services for MATLAB/RunMat source: diagnostics, hover documentation, completion, signature help, semantic highlighting, go-to-definition, references, symbols, and formatting.

The server analyzes documents with the same lexer, parser, HIR lowering, static analysis, builtin metadata, and VM compile checks used elsewhere in RunMat. It does not run user code or create an execution session.

Editor Surface

CapabilitySource of information
Error diagnosticsSyntax errors, HIR lowering errors, VM compile errors, and error-severity static-analysis diagnostics.
Warning and information diagnosticsShape analysis, MIR analysis, and non-blocking semantic diagnostics.
Semantic highlightingLexer tokens plus semantic roles for functions, parameters, variables, namespaces, and builtins.
HoverInferred variable kinds/types, global variables, builtin docs, and builtin constants.
CompletionGlobals, local variables, document functions, builtins, and constants.
Signature helpBuiltin descriptors and user-defined function signatures.
Go to definition and referencesLocal bindings, document functions, and project functions when the project can be discovered.
Outline and workspace symbolsUser-defined functions from open documents and project files.
FormattingConservative whitespace cleanup.

Analysis Flow

Loading diagram...

Analysis preserves partial results when a document is invalid. A syntax error can still leave token information available for highlighting and ranges, and a compile error can still point to the relevant source span without execution.

Capability Coverage

FeatureNative LSPWASM exportsNotes
Incremental document syncYesOpen/change document callsNative sync is incremental; WASM stores complete text per URI.
DiagnosticsYesYesSyntax, HIR lowering, VM compile, and semantic lint diagnostics.
HoverYesYesLocal variables, globals, builtins, and builtin constants.
CompletionYesYesGlobals, function locals, document functions, builtins, and constants.
Signature helpYesYesBuiltin descriptors and user-defined function signatures.
Semantic tokensYesYesKeywords, functions, variables, parameters, namespaces, strings, numbers, operators, comments.
Go to definitionYesYesSame-document symbols plus project functions when project discovery is available.
ReferencesYesYesSame-document references plus project functions when project discovery is available.
Document symbolsYesYesFunction symbols with signature details.
Workspace symbolsYesYesOpen documents and discovered project files, filtered by query on native LSP.
FormattingYesYesWhitespace normalization only: trailing whitespace, newline normalization, and blank-line collapse.
Rename, code actions, inlay hintsNoNoThese capabilities are not advertised by the server.

Runtime Scope

The LSP compiles far enough to answer editor requests, but it does not create a RunMatSession, mutate workspace state, invoke user functions, or evaluate runtime side effects. Its checks are static:

  • Parser compatibility follows the configured language mode (runmat, matlab, or strict).
  • HIR lowering resolves bindings, calls, imports, and project-visible symbols.
  • Static analysis contributes shape and MIR diagnostics.
  • VM compilation catches bytecode-level compile errors before execution.
  • Builtin metadata drives editor documentation instead of duplicating handwritten LSP-only references.

This keeps editor feedback aligned with runtime semantics while keeping idle analysis side-effect free.

Page Map

PagePurpose
Diagnostics & HighlightingError, warning, status, and semantic-token behavior.
Editor FeaturesHover, completion, signature help, navigation, symbols, formatting, and native/WASM host behavior.

For compiler internals, see Compilation Pipeline. For execution after compilation, see VM Interpreter & Bytecode. For browser embedding, see WASM & TypeScript/JavaScript.