Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

LSP Features

LSP methods spice-lsp implements or plans to implement, organized by release phase. MVP ships only syntax sync and diagnostics; richer behavior accumulates in later versions.

Capability matrix

LSP method / featureMVPv0.2v0.3v0.4v0.5
initialize / initialized
shutdown / exit
textDocument/didOpen / didChange / didClose
textDocument/publishDiagnosticssyntax
Syntax diagnostics
Duplicate / undefined symbol diagnostics
Dangling node / floating net diagnostics
textDocument/documentSymbol
textDocument/definition / references
textDocument/completion
textDocument/hover (dialect reference)curated reference/
textDocument/hover (file-local)subcircuit pins, in-file models
textDocument/formatting
textDocument/didSave (re-lint)

Full specification of reference hover and net diagnostics: Dialect reference and net semantics.

MVP

Server capabilities

{
  "capabilities": {
    "textDocumentSync": {
      "openClose": true,
      "change": 2,
      "save": false
    }
  },
  "serverInfo": { "name": "spice-lsp", "version": "0.1.0" }
}

change: 2 is Incremental sync — the client sends edit ranges, not the full buffer every keystroke.

Diagnostics arrive via server-initiated textDocument/publishDiagnostics.

Syntax diagnostics

SourceExampleSeverity
Unclosed .subcktmissing .ends for subcircuit XError
Parse ERROR nodeunexpected tokenError
Missing CST childexpected node listError

v0.2 — Symbols and light semantics

Server capabilities

Adds outline and navigation on top of MVP sync:

{
  "capabilities": {
    "textDocumentSync": { "openClose": true, "change": 2 },
    "documentSymbolProvider": true,
    "definitionProvider": true,
    "referencesProvider": true
  }
}

Document symbols for outline / breadcrumbs:

Symbol kindSPICE construct
Namespace.subckt block
Class.model
Variable.param
FieldInstance line

Navigation: go to definition and find references for subcircuits, models, and parameters. textDocument/references honors context.includeDeclaration (omit definition sites when the client passes false).

Diagnostics:

CodeExampleSeverity
spice/duplicate-nameduplicate component name 'R1'Warning
spice/unknown-modelmodel 'nfet' not definedWarning

Diagnostics from didChange are debounced (~150 ms) so rapid typing does not re-analyze on every keystroke. didOpen publishes immediately. Navigation handlers refresh the in-memory index on demand.

v0.3 — Completion and file-local hover

Completion contexts: element letters, directive names, in-scope model and subcircuit names, snippet templates for .tran / .subckt.

Hover (file-local only): subcircuit port order, parameters from .model / .subckt in the open buffer. No curated reference yet — that is v0.5.

Dialect selection (issue #16)

spiceLsp.dialect is hspice | ngspice | ltspice (default hspice). The VS Code command SPICE LSP: Set Dialect… and a status-bar item change it. The same dialect selects the reference corpus for hover and (later) completion docs.

Design: Multi-dialect support.

Hover

textDocument/hover resolves in order:

  1. Curated entry from reference/ for the active dialect (_shared fallback)
  2. File-local detail for .subckt / .model / .param symbols
  3. No hover

v0.4 — Formatting

Registers documentFormattingProvider. Formatter profiles may follow the active dialect later.

See Formatter.

v0.5 — Dialect reference hover and net connectivity

Reference-powered hover

When the cursor is on a directive, option, element keyword, or documented expression form, the server loads the matching entry from reference/<dialect>/ and returns markdown:

  • Summary and syntax
  • Parameter table with units
  • Examples and seeAlso links

You maintain this corpus over time; the LSP only indexes and renders it. Authoring guide: Dialect reference and net semantics.

Connectivity diagnostics

CodeExampleSeverity
spice/dangling-nodenode 'bias' is connected to only one device terminalWarning
spice/floating-netnet 'internal' has no DC path to groundWarning

Published alongside syntax diagnostics in publishDiagnostics. Configurable via spiceLsp.diagnostics.* settings.

Client configuration

SettingTypeDefaultAvailable
spiceLsp.dialectstring"hspice"dialect switch (see Multi-dialect design)
spiceLsp.diagnostics.danglingNodesbooleantruev0.5+
spiceLsp.diagnostics.floatingNetsbooleantruev0.5+
spiceLsp.groundNodesstring[]["0","gnd","GND"]v0.5+
spiceLsp.trace.serverstring"off"MVP+

Testing

Each phase adds integration tests for newly advertised capabilities. MVP priorities:

  1. initialize returns expected capabilities
  2. Open invalid document → diagnostics notification
  3. Edit → updated diagnostics

v0.2 adds:

  1. documentSymbol returns hierarchical outline for .subckt blocks

  2. definition on subcircuit reference jumps to .subckt definition

  3. references on subcircuit definition lists definition + usages; includeDeclaration: false omits the definition

  4. Semantic fixtures (duplicate-instance.cir, unknown-subckt.cir) produce warning codes

  5. Rapid didChange events coalesce into a single diagnostics publish after the debounce window

  6. (v0.5) Open semantic fixture → dangling / floating warnings; hover snapshot matches reference entry

See Demo and testing.