Add AST-guided semantic token overrides in lucisv_server/src/tokens/instantiation.rs and cross-file overlay lookup in tokens.rs without changing the 14-type wire legend: - module/interface/extends names -> class (pkg:: prefixes -> namespace) - parameter-list # (never delays), .PARAM overrides and parameter values -> parameter - instance names (declarations, gate instances, bind lists, hierarchical uses) -> function - named port connections (.port, implicit .port, .*) -> property - port connection signals -> variable Enable editor.semanticHighlighting.enabled by default for [verilog] and [systemverilog] in editors/vscode/package.json and contribute semanticTokenScopes so every role renders with a distinct, non-white colour across VS Code themes. Add editors/vscode/semanticTokens_test.js (75 checks, passing under node --test). Rust tests/fmt/clippy deferred to Gitea CI (no cargo toolchain on this Windows host).
instantiation-highlighting
Goal
Give module and interface instantiations distinct, recognizable syntax colours instead of painting every part of an instantiation with the default variable foreground. Borrowing the roles other languages assign to constructor and component calls (C++, Rust, TypeScript/JSX), each syntactic piece of an instantiation takes its own semantic token class and theme-safe TextMate scope:
- Module / interface name (
uart_coreinuart_core #(...) u_uart (...),pkg::uart_corewithpkgasnamespace, and lonebindtargets) →class(entity.name.type.class). #sign and parameters (#before parameter port or override lists,.BAUD_DIVdot + parameter-port name,parameter/localparamsymbols, and unresolved constant identifiers inside#(...)) →parameter(keyword.control/constant.language/variable.parameter), sharing one colour that stays distinct from bracket-pair-coloured().- Instance name (
u_uart, gate instances,bindtarget instances, and uses ofSymbolKind::Instancesuch asu_uart.sig) →function(entity.name.function). - Port name (
.clk_idot + port name, implicit.clk_i, and wildcard.*in an instance's connection list) →property(entity.name.tag.css/entity.other.attribute-name/variable.other.property). - Port connection (
clkinside.clk_i(clk)or positional(clk)) →variable(support.variable/entity.other.attribute-name/variable.other.readwrite), keeping signal colouring consistent across the file and non-white in themes that leave barevariableuncoloured.
Assumptions
- The 14-type wire legend is unchanged. Every role above maps onto the
existing
SemanticTokenTypeindices (namespace,class,parameter,variable,property,function), sotoken_types().len() == 14andtoken_modifiers().len() == 1stay untouched on the wire. - AST spans decide instantiation structure; single-file + overlay semantics
decide expressions. A buffer opened before workspace indexing finishes, a
standalone file, or an instantiation of an unindexed vendor macro still
highlights its module name,
#,.PARAM, instance name, and.portfromDocument.treealone. Identifiers that resolve throughDocument.externalalso take their cross-fileSymbolKindinstead of degrading tovariable. - Parameter
#only, never delay#. Only the#introducing a parameter port list, parameter override list, or parameterizedDataTypereceivesHighlight::Parameter;#5and#(1:2:3)net, assignment, gate, and procedural delays remain unemitted punctuation. - Large-file fast path (
Document::large) stays lexer-only. Because the fast path builds no AST or symbol table, AST-driven#,., and.*tokens are emitted only by the full pipeline, alongside identifier refinement. - Editor defaults remain user-overridable. Setting
editor.semanticHighlighting.enabled = trueinconfigurationDefaultsfor[verilog]and[systemverilog]activates semantic tokens in themes whose ownsemanticHighlightingflag is unset orfalse, while any explicit user or workspace setting still wins.
Handshakes
- Consumed from
vlog_parser:SourceFile,Item/ItemKind,Module,Instantiation,Instance,Connections,Connection,BindDirective,GateInstantiation,ClassDecl,ClassExtends,DataType::params,ListElem,RawText,Token,TokenKind,TextRange. No parser changes. - Consumed from
vlog_semantic:Semantics,SymbolKind,ExternalResolutions::definition_of,Definition. No semantic changes. - Promised to LSP clients (
crates/lucisv_server/src/tokens.rs): identical 14-entrytoken_typeslegend and 1-entrytoken_modifierslegend; sorted, non-overlapping single-line UTF-16 tokens; exactfull/deltaround-trip. - Shared with
editors/vscode/package.json:contributes.semanticTokenScopeskeys forverilogandsystemverilogare a subset oftokens::token_types(), checked byeditors/vscode/semanticTokens_test.js.
Status / TODO
- Add
crates/lucisv_server/src/tokens/instantiation.rsfor AST-guided instantiation and parameter-header highlight overrides. - Update
crates/lucisv_server/src/tokens.rsto apply overrides, consultDocument.externalviadefinition_of, mapSymbolKind::InstancetoHighlight::Function, and add unit tests covering instantiation shapes, delay#exclusion, recovered entries, andlarge-file-modewindow agreement. - Configure
editor.semanticHighlighting.enabledandcontributes.semanticTokenScopesforverilogandsystemverilogineditors/vscode/package.json, with headless verification ineditors/vscode/semanticTokens_test.js(and.vscodeignoreexclusion). - Update
docs/features/lucisv-server/README.mdanddocs/features/large-file-mode/README.mdfor the refined mapping.
Work log
2026-11-17 — dev
- Audited
tokens.rs,editors/vscode/package.json, and VS Code theme scope tables across Dark Modern/Dark+, Light Modern/Light+, GitHub Dark, One Dark Pro, Monokai, and Visual Studio Dark. Found two root causes for flat white instantiations: (1)tokens.rsconsulted only single-fileSemantics(leaving external module names,.PARAMoverrides,.portnames, andSymbolKind::Instanceall onHighlight::Variable, and leaving#unemitted); (2)package.jsonneither defaultededitor.semanticHighlighting.enabledon nor mapped semantic token types to distinct TextMate scopes for themes wherevariable/parameter/propertycollapse to white or one shared colour. - Added
crates/lucisv_server/src/tokens/instantiation.rs(~280 total lines) and wiredcrates/lucisv_server/src/tokens.rswithout changing the 14-type wire legend:- Module/interface/
extendsnames →Highlight::Class(pkg::prefixes →Highlight::Namespace); - Parameter-list
#(headers, instantiations, parameterizedDataTypes, never delays),.PARAMoverrides (.+ name), and unresolved constant identifiers inside#(...)→Highlight::Parameter; SymbolKind::Instance,Instance.name_span, gate instances, andbindinstance lists →Highlight::Function;- Named port connections (
.+ name, implicit.name, wildcard.*), including recovered unfinished entries while typing →Highlight::Property; - Port connection expressions stay on
identifier_type(Highlight::Variablefor signals), now backed byExternalResolutions::definition_of.
- Module/interface/
- Added
editor.semanticHighlighting.enabled: trueunderconfigurationDefaultsandsemanticTokenScopesforverilogandsystemverilogineditors/vscode/package.json; addededitors/vscode/semanticTokens_test.js(75 checks, all green undernode) and listed it ineditors/vscode/.vscodeignore. - Cargo/Rust toolchain is not installed on this Windows host; Rust formatting
(
use_small_heuristics = "Max", ≤100 cols), clippy rules, and test invariants were audited manually for Gitea CI execution.