Hover highlighting 0.4.1: ship a TextMate grammar

Hover cards fence their declaration snippets as systemverilog markdown,
but VS Code colors fences with a TextMate grammar and the extension
deliberately shipped none - so hovers rendered plain. One compact
lookaround-free grammar (comments, strings closing at end of line, based
and fill and real and time literals, directives then macro uses, system
tasks, all 181 keywords generated from vlog_parser::KEYWORDS with a
mutation-checked drift test) registered for both language ids. Buffers
also gain colors before the server starts; semantic tokens still win once
it does. Fence tags are pinned as a contract in hover and completion.

Co-Authored-By: Claude Fable 5 <[email protected]>
This commit is contained in:
lucioandClaude Fable 5 committed 2026-08-24 20:15:47 -07:00
1 parent e9b7510ca4
commit 302b3ed443
14 files changed
+815 -31

No files matched your search

+24
View File
@@ -4,6 +4,30 @@ All notable changes to vfmt are recorded here. Versions follow
[semantic versioning](https://semver.org/); until 1.0 the CLI's exit codes
(see `README.md`) are the only frozen contract.
## 0.4.1 — 2026-08-24
Hover cards are **syntax highlighted**. The server has always sent its
declaration snippets and `` `define`` expansions as fenced
```` ```systemverilog ```` blocks, but VS Code colours a fenced block with the
**TextMate grammar** registered for that language id, and the extension
deliberately shipped none — semantic tokens colour the buffer, and they cannot
reach markdown. So every hover card, and every completion template's
documentation panel, rendered as flat grey text. The extension now contributes
one compact grammar, registered for both `verilog` and `systemverilog`:
comments, strings, based and real literals (`8'hFF`, `4'b10xz`, `'0`, `1.5e-3`,
`10ns`), system tasks (`$display`), compiler directives and macro uses
(`` `define``, `` `WIDTH``), and the keywords — all 181 of them, generated from
the lexer's own list, with a test that fails the build if the two ever drift
apart. Operators and `(* attributes *)` are deliberately left out; the reasons
are in
[editor-packaging](docs/features/editor-packaging/README.md).
The side benefit is a buffer that has colour before the server starts, in a
file the server is not indexing, and in a diff or a git preview where no
language server runs at all. Where the server *is* running its semantic tokens
still win, as they always did: the grammar only fills in what nothing better
has coloured.
## 0.4.0 — 2026-08-24
Completion now offers **templates**, not just words. Typing `if` inside an
Generated
+8 -8
View File
@@ -217,7 +217,7 @@ checksum = "e6e4313cd5fcd3dad5cafa179702e2b244f760991f45397d14d4ebf38247da75"
[[package]]
name = "vfmt"
version = "0.4.0"
version = "0.4.1"
dependencies = [
"rayon",
"vfmt_core",
@@ -228,11 +228,11 @@ dependencies = [
[[package]]
name = "vfmt_core"
version = "0.4.0"
version = "0.4.1"
[[package]]
name = "vfmt_server"
version = "0.4.0"
version = "0.4.1"
dependencies = [
"lsp-server",
"lsp-types",
@@ -248,14 +248,14 @@ dependencies = [
[[package]]
name = "vlog_formatter"
version = "0.4.0"
version = "0.4.1"
dependencies = [
"vlog_parser",
]
[[package]]
name = "vlog_linter"
version = "0.4.0"
version = "0.4.1"
dependencies = [
"vlog_formatter",
"vlog_parser",
@@ -263,11 +263,11 @@ dependencies = [
[[package]]
name = "vlog_parser"
version = "0.4.0"
version = "0.4.1"
[[package]]
name = "vlog_refactor"
version = "0.4.0"
version = "0.4.1"
dependencies = [
"vlog_parser",
"vlog_semantic",
@@ -275,7 +275,7 @@ dependencies = [
[[package]]
name = "vlog_semantic"
version = "0.4.0"
version = "0.4.1"
dependencies = [
"vlog_parser",
]
+1 -1
View File
@@ -12,7 +12,7 @@ members = [
]
[workspace.package]
version = "0.4.0"
version = "0.4.1"
edition = "2021"
license = "MIT"
+1 -1
View File
@@ -581,7 +581,7 @@ registering the file types and starting the server:
```bash
tools/release.sh # builds dist/vfmt-<version>.vsix
code --install-extension dist/vfmt-0.4.0.vsix
code --install-extension dist/vfmt-0.4.1.vsix
```
Sideloading that `.vsix` is the supported install; the extension is not on any
+3
View File
@@ -1400,6 +1400,9 @@ endmodule
let Some(Documentation::MarkupContent(docs)) = &item.documentation else {
panic!("markdown documentation");
};
// Fenced with the language id the extension's TextMate grammar is
// registered for, so the panel renders highlighted rather than grey.
assert!(docs.value.starts_with("```systemverilog\n"), "{}", docs.value);
assert!(docs.value.contains("always_comb begin\n\nend"), "{}", docs.value);
assert_eq!(item.detail.as_deref(), Some("combinational block — template"));
}
+9 -2
View File
@@ -191,7 +191,10 @@ mod tests {
let (ws, uri) = document(text);
let hover = hover(&ws, &uri, at(text, "[`WIDTH") + 2).expect("hover");
let body = text_of(&hover);
assert!(body.contains("`define WIDTH 8"), "got {body}");
// The fence tag is load-bearing: it is the language id the extension
// registers its TextMate grammar for, and the only reason a hover card
// renders highlighted. Pinned here so a rename cannot pass silently.
assert!(body.contains("```systemverilog\n`define WIDTH 8\n```"), "got {body}");
}
#[test]
@@ -261,7 +264,11 @@ mod tests {
let (ws, uri) = document(text);
let body = text_of(&hover(&ws, &uri, at(text, "[WIDTH") + 1).expect("hover"));
assert!(body.contains("**parameter**"), "got {body}");
assert!(body.contains("localparam WIDTH = 8;"), "the decl snippet: got {body}");
// Fenced with the grammar's language id — see the macro hover test.
assert!(
body.contains("```systemverilog\n localparam WIDTH = 8;\n```"),
"the decl snippet: got {body}"
);
}
#[test]
+177
View File
@@ -0,0 +1,177 @@
//! The VS Code extension's TextMate grammar, checked against this workspace.
//!
//! The grammar exists so that fenced code in the server's markdown — hover
//! cards, completion documentation — renders highlighted: VS Code colours a
//! ```` ```systemverilog ```` block with the TextMate grammar registered for
//! that language id, and semantic tokens cannot reach markdown. Its keyword
//! list is *generated from* [`vlog_parser::KEYWORDS`], so the two can drift
//! apart the moment somebody adds a keyword and forgets the JSON. That is what
//! `the_grammars_keywords_are_exactly_the_lexers` is here to prevent.
//!
//! There is no regex engine in this workspace's dependency tree and adding one
//! for a test is not worth it, so `every_pattern_is_a_plain_regex` checks the
//! properties that actually matter instead of compiling: balanced groups and
//! classes, and no lookaround/backreference — i.e. every pattern stays inside
//! the subset every engine accepts, Oniguruma included. The patterns were also
//! hand-run against a sample buffer while the grammar was written; see
//! `docs/features/editor-packaging/README.md`.
use std::path::PathBuf;
use serde_json::Value;
/// The grammar, parsed. Located relative to this crate, so the test is
/// independent of the working directory `cargo test` was started from.
fn grammar() -> Value {
let path = PathBuf::from(env!("CARGO_MANIFEST_DIR"))
.join("../../editors/vscode/syntaxes/systemverilog.tmLanguage.json");
let text = std::fs::read_to_string(&path)
.unwrap_or_else(|e| panic!("reading {}: {e}", path.display()));
serde_json::from_str(&text).unwrap_or_else(|e| panic!("parsing {}: {e}", path.display()))
}
/// The extension manifest, parsed.
fn manifest() -> Value {
let path = PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("../../editors/vscode/package.json");
let text = std::fs::read_to_string(&path)
.unwrap_or_else(|e| panic!("reading {}: {e}", path.display()));
serde_json::from_str(&text).unwrap_or_else(|e| panic!("parsing {}: {e}", path.display()))
}
/// Every `match`, `begin` and `end` string anywhere in the grammar.
fn patterns(node: &Value, path: &str, out: &mut Vec<(String, String)>) {
match node {
Value::Object(map) => {
for (key, value) in map {
match (key.as_str(), value.as_str()) {
("match" | "begin" | "end", Some(regex)) => {
out.push((format!("{path}.{key}"), regex.to_string()))
}
_ => patterns(value, &format!("{path}.{key}"), out),
}
}
}
Value::Array(items) => {
for (i, item) in items.iter().enumerate() {
patterns(item, &format!("{path}[{i}]"), out);
}
}
_ => {}
}
}
#[test]
fn the_grammars_keywords_are_exactly_the_lexers() {
let grammar = grammar();
let alternation = grammar["repository"]["keywords"]["match"]
.as_str()
.expect("repository.keywords.match is a string");
let inner = alternation
.strip_prefix("\\b(")
.and_then(|rest| rest.strip_suffix(")\\b"))
.unwrap_or_else(|| panic!("the keyword rule must be `\\b(a|b|…)\\b`, got {alternation}"));
let mut listed: Vec<&str> = inner.split('|').collect();
let mut expected: Vec<&str> = vlog_parser::KEYWORDS.to_vec();
listed.sort_unstable();
expected.sort_unstable();
let mut deduped = listed.clone();
deduped.dedup();
assert_eq!(listed, deduped, "a keyword is listed twice in the grammar");
// The two differences, named, because "assert_eq on 181 words" is not a
// useful failure message.
let missing: Vec<&&str> = expected.iter().filter(|w| !listed.contains(w)).collect();
let extra: Vec<&&str> = listed.iter().filter(|w| !expected.contains(w)).collect();
assert!(
missing.is_empty() && extra.is_empty(),
"editors/vscode/syntaxes/systemverilog.tmLanguage.json has drifted from \
vlog_parser::KEYWORDS — regenerate the alternation.\n missing: {missing:?}\n \
extra: {extra:?}"
);
assert_eq!(listed, expected);
}
#[test]
fn every_pattern_is_a_plain_regex() {
let grammar = grammar();
let mut found = Vec::new();
patterns(&grammar, "", &mut found);
assert!(found.len() >= 10, "the grammar lost its patterns: {found:?}");
for (where_, regex) in &found {
assert!(!regex.is_empty(), "{where_} is an empty pattern");
for construct in ["(?=", "(?!", "(?<", "(?>", "\\1", "\\k<", "\\G"] {
assert!(
!regex.contains(construct),
"{where_} uses `{construct}` — the grammar deliberately stays inside the \
regex subset every engine accepts; see this file's header"
);
}
assert!(balanced(regex), "{where_} has unbalanced `()` or `[]`: {regex}");
}
}
/// Whether a regex's groups and character classes are balanced, reading
/// backslash escapes and treating `(`/`)` inside a class as literal — the one
/// structural error that turns a grammar into "no highlighting at all".
fn balanced(regex: &str) -> bool {
let mut depth = 0i32;
let mut in_class = false;
let mut chars = regex.chars();
while let Some(ch) = chars.next() {
match ch {
'\\' => {
if chars.next().is_none() {
return false; // a trailing backslash escapes nothing
}
}
'[' if !in_class => in_class = true,
']' if in_class => in_class = false,
'(' if !in_class => depth += 1,
')' if !in_class => {
depth -= 1;
if depth < 0 {
return false;
}
}
_ => {}
}
}
depth == 0 && !in_class
}
#[test]
fn both_language_ids_are_registered_for_the_grammar() {
// The hover cards fence unconditionally as ```systemverilog, and VS Code
// resolves a fence's info string against the language registry — not
// against the document the hover came from. So a `.v` buffer's hover
// highlights only because `verilog` is registered here too.
let manifest = manifest();
let scope = grammar()["scopeName"].as_str().expect("scopeName").to_string();
let grammars = manifest["contributes"]["grammars"].as_array().expect("contributes.grammars");
let languages: Vec<&str> = grammars.iter().filter_map(|g| g["language"].as_str()).collect();
assert_eq!(languages, ["verilog", "systemverilog"]);
for entry in grammars {
assert_eq!(entry["scopeName"].as_str(), Some(scope.as_str()));
assert_eq!(
entry["path"].as_str(),
Some("./syntaxes/systemverilog.tmLanguage.json"),
"both entries must name the same file: VS Code only warns about a re-registered \
scope when the two locations differ"
);
}
// Every id the grammar claims is an id the extension actually declares.
let declared: Vec<&str> = manifest["contributes"]["languages"]
.as_array()
.expect("contributes.languages")
.iter()
.filter_map(|l| l["id"].as_str())
.collect();
for language in &languages {
assert!(declared.contains(language), "grammar registered for undeclared id {language}");
}
}
+428 -1
View File
@@ -55,7 +55,7 @@ the same way:
| Not shipped | Why |
|---|---|
| TextMate grammar | The server ships `semanticTokens` (14 types, `docs/features/vfmt-server/README.md`). A grammar would be a second, worse highlighter to keep in sync. |
| ~~TextMate grammar~~ — **ships since 0.4.1** | The original reasoning (below) was right about the *buffer* and wrong about *markdown*, which semantic tokens cannot reach at all. See "The TextMate grammar" below. Struck through rather than deleted, because the reason it was cut is still the reason it is deliberately small. *(Original: "The server ships `semanticTokens` (14 types, `docs/features/vfmt-server/README.md`). A grammar would be a second, worse highlighter to keep in sync.")* |
| `language-configuration.json` | Comment/bracket rules are the smallest useful thing here, and still a judgement call about Verilog syntax living in the editor layer. The brief says "declare the language only"; if `Ctrl+/` proves painful, this is the first thing to add back — 12 lines, no dependency. |
| Commands (restart server, show logs) | The language client already contributes a restart command and an output channel. |
| Status bar item | State the user can already see in the Output panel. |
@@ -63,6 +63,137 @@ the same way:
| Bundling (esbuild/webpack) | `vsce` warns about the 166 JavaScript files in the dependency; bundling would add a build step to a repo whose extension has none. 460 KB is not a problem worth a toolchain. |
| A Neovim plugin | The configuration *is* the integration. A plugin would only wrap `vim.lsp.config`. |
## The TextMate grammar (0.4.1)
### Why the no-grammar stance was wrong
Semantic tokens colour *buffers*. The server's richest output is not a buffer:
it is **markdown** — hover cards carrying a declaration snippet or a
`` `define`` expansion (`crates/vfmt_server/src/hover.rs:89,131`) and a
completion template's documentation panel
(`crates/vfmt_server/src/completion.rs:423`). All three have always been fenced
```` ```systemverilog ````, which was correct and did nothing: VS Code colours a
fenced block by looking the fence's info string up in the **language registry**
and tokenizing with the TextMate grammar registered for that language id.
No grammar, no colour — and there is no LSP channel that could supply one,
because the hover's markdown is rendered by the editor, not by the server.
So the cards rendered as flat grey text.
The fix is a grammar, and the original objection ("a second, worse
highlighter") survives as a *design constraint* rather than a veto: this
grammar is deliberately the smallest thing that makes a code fence readable.
In a live buffer the server's 14 semantic token types still win — VS Code
layers semantic tokens over TextMate tokens — so the grammar mostly fills gaps
there. It is the *only* highlighter in a hover card, in a file opened before
the server starts, and in the previews VS Code renders with no language server
attached (diffs, git blame, walkthrough panes).
### One file, two language ids
`editors/vscode/syntaxes/systemverilog.tmLanguage.json` is registered **twice**
in `contributes.grammars`, once for `verilog` and once for `systemverilog`,
with the same `scopeName` (`source.systemverilog`) and the same `path`. That is
the boring option, and it is honest: vfmt's own lexer has a single `KEYWORDS`
list serving both dialects, so a second grammar would be a copy that can only
drift.
Two alternatives were considered and dropped. Two scope names with a stub
grammar that `include`s the other by scope adds a file and an indirection for
no behavioural difference. Two full grammars re-litigate the dialect split that
the lexer already decided not to make.
The one risk of the chosen shape — a re-registered scope name — was checked
against VS Code's own shipped code rather than assumed. In
`TMScopeRegistry.register` (VS Code 1.123.0,
`out/vs/workbench/…/textMateTokenizationWorker.workerMain.js`) a second
registration for a scope warns **only when the two locations differ**:
`isEqual(old.location, new.location) || console.warn('Overwriting grammar scope
name to file mapping…')`. Same file, no warning; the language-to-scope map
takes both ids. `crates/vfmt_server/tests/grammar.rs` asserts both entries keep
naming the same path, so that stays true.
### Pattern inventory
| Rule | Scope | Notes |
|---|---|---|
| line comment | `comment.line.double-slash` | |
| block comment | `comment.block` | non-nesting, which is what the language says |
| string | `string.quoted.double` | `\\.` escapes; ends at the closing quote **or end of line**, so an unterminated string cannot bleed down a hover card |
| directives | `keyword.control.directive` | `` `define ``, `` `ifdef ``, `` `include ``, `` `timescale ``, `` `__LINE__ ``… |
| macro use | `entity.name.function.preprocessor` | any other `` `NAME ``; listed after the directives so the directive wins the tie |
| system tasks | `support.function.system` | `\$[a-zA-Z_][a-zA-Z0-9_$]*` — `$display`, `$clog2` |
| based literals | `constant.numeric.based` | `8'hFF`, `4'b10xz`, `32'sd10`, unsized `'h1F`, `_` separators, `x`/`z`/`?` digits |
| fill literals | `constant.numeric.fill` | `'0`, `'1`, `'x`, `'z` |
| decimal / real / time | `constant.numeric` | `42`, `1.5e-3`, `10ns` |
| keywords | `keyword.other` | all 181, generated — see below |
Scope naming is deliberately flat, and the choice was made against this
machine's copy of VS Code's default themes rather than from memory
(`theme-defaults/themes/*.json`, 1.123.0): bare **`keyword`** is coloured
(`#569cd6` dark, `#0000ff` light), so `keyword.other.systemverilog` inherits a
real colour in every theme built on those. `constant.numeric`, `comment`,
`string`, `support.function` and `entity.name.function.preprocessor` are all
coloured there too. The alternative — splitting the keywords into
`storage.type` (`logic`, `wire`) and `keyword.control` (`if`, `always`) — would
look marginally better and would require hand-categorising 181 words, which is
exactly the hand-maintained list the drift test exists to forbid. Colour beats
taxonomy here.
### Deliberate omissions
- **Operators.** Noise in a hover card, and `keyword.operator` is theme-coloured
the same as plain text in Dark+/Light+ anyway — the work would buy nothing.
- **`(* attributes *)`.** Considered, rejected as *not cheap*: the obvious
`begin: "\\(\\*"` / `end: "\\*\\)"` swallows the extremely common
`always @(*)` — the begin matches `(*`, the end never does, and the rest of
the file becomes an attribute. Excluding it needs a negative lookahead
(`\(\*(?!\))`), which is the only Oniguruma-only construct the grammar would
have contained. An unhighlighted attribute costs nothing; a runaway one costs
the whole file. Skipped, and the "no lookaround" rule is now asserted by the
tests.
- **Whitespace inside a based literal** (`8 'h FF`, legal but never written).
- **`1step`**, and other literals whose unit is not a time unit.
- **Nested `/* */`**, which the language does not have either.
- **Embedded languages / injections** (SVA, DPI C blocks, `` `pragma `` bodies).
- **A `$` inside an identifier** (`x$y`, legal in SystemVerilog): the
system-task pattern has no left boundary — a lookbehind, the construct
this grammar bans — so the `$y` half colors as a system task. Cosmetic,
QA-found, accepted (lead, 2026-08-24).
- **An unterminated `/*`** colors as comment to the end of the fenced block.
Strings are hardened against this (they close at end of line) because an
unterminated string is a common mid-typing state; an unterminated block
comment in a hover card — which shows *saved declarations* — is not.
QA-found, accepted (lead, 2026-08-24).
### The drift test, and why there is no regex-compile test
`crates/vfmt_server/tests/grammar.rs`, three tests:
1. `the_grammars_keywords_are_exactly_the_lexers` parses the JSON, strips the
`\b(` … `)\b` around `repository.keywords.match`, and asserts the
alternation is exactly `vlog_parser::KEYWORDS` as a set, with no duplicates,
naming the missing and the extra words on failure. The M5 single-source rule
(`token.rs`'s `keywords!` macro) now reaches the editor too: add a keyword to
the lexer and forget the grammar, and `cargo test` says so. Precedent: the
`$`-escape checker in `docs/features/editor-snippets/README.md`.
2. `every_pattern_is_a_plain_regex` walks every `match`/`begin`/`end` in the
file and asserts each is non-empty, has balanced groups and character
classes, and uses no lookaround, backreference, atomic group or `\G`.
**It does not compile them**, because there is no regex engine in this
workspace's dependency tree and CLAUDE.md's "adding a dependency requires a
written justification" is not satisfiable by "a test would be tidier".
What it checks instead is stronger in one way and weaker in another: weaker,
because a subtly wrong (but valid) regex still passes; stronger, because the
no-lookaround assertion pins the grammar inside the subset *every* engine
accepts, Oniguruma included, so the patterns can be checked with any tool at
hand. They were: all 13 were compiled and run against a sample buffer with
Python's `re` while the grammar was written — see the work log.
3. `both_language_ids_are_registered_for_the_grammar` reads `package.json` and
asserts both ids are registered, both name the same scope and the same file,
and both are ids the extension actually declares — the
silently-never-highlights failure mode, and the same class of check QA
already runs by hand for `activationEvents`.
## The one dependency, and the justification CLAUDE.md asks for
| package | version | why not std, why not hand-rolled |
@@ -128,6 +259,24 @@ binary's name and its stdio contract, nothing else"):
5. The advertised capability set, which both editor guides describe and neither
editor extends: nothing is advertised client-side that the server does not
implement.
6. **(0.4.1) The fence tag `systemverilog`.** Every code block the server puts
in markdown — `hover.rs:89` (`` `define`` expansion), `hover.rs:131`
(declaration snippet), `completion.rs:423` (template documentation) — opens
```` ```systemverilog ````, unconditionally, including for a `.v` buffer.
The extension's grammar is registered for that language id, which is why the
card renders highlighted; VS Code resolves a fence's info string against the
language registry, not against the document the hover came from, so the `.v`
case needs nothing extra beyond `verilog` also being registered (it is).
**If the server ever changes that tag, or fences a new surface with a
different one, the highlighting silently goes away.** The three call sites
now pin the exact fenced string in their own unit tests, and
`tests/grammar.rs` pins the registration.
**Consumed from `vlog_parser`:** `KEYWORDS` — the grammar's keyword alternation
is generated from it and `crates/vfmt_server/tests/grammar.rs` fails if the two
diverge. Adding a keyword to `token.rs`'s `keywords!` macro is now also an edit
to `editors/vscode/syntaxes/systemverilog.tmLanguage.json`; the test names the
missing word.
**Promised to `vfmt_server`:** the spawn contract above. If the server ever
grows a required flag, a subcommand, or a stdio mode switch, `extension.js` and
@@ -164,6 +313,22 @@ grows a required flag, a subcommand, or a stdio mode switch, `extension.js` and
- [x] TODO.md §6 editor-packaging checkbox.
- [x] `smoke.js` run green against a release build.
- [x] `npm install` and `vsce package` run green on this machine.
- [x] **0.4.1** — `editors/vscode/syntaxes/systemverilog.tmLanguage.json`,
registered for both language ids in `contributes.grammars`.
- [x] **0.4.1** — `crates/vfmt_server/tests/grammar.rs`: keyword drift,
pattern validity, registration.
- [x] **0.4.1** — fence audit of every markdown surface the server emits;
the three code-carrying ones pin their fence tag in unit tests.
- [x] **0.4.1** — version bump, changelog, `editors/vscode/README.md`
"Syntax highlighting", `tools/RELEASING.md` packaging check.
- [ ] **Not done (0.4.1), same reason as everything else in this list:** the
grammar has never been *tokenized* by vscode-textmate. `vscode-textmate`
is not in `node_modules` and adding it is a new dev dependency, which
CLAUDE.md forbids without a written justification a highlighting test
does not earn. Verified instead: the patterns compile and behave under
Python's `re` on a sample buffer, the JSON loads, the scopes are ones
this machine's default themes actually colour, and `vsce ls` ships the
file. See the Work log for the exact output.
- [ ] **Not done, and honestly untestable here:** the extension has never run
inside VS Code. `require('vscode')` resolves only in the extension host,
so the `activate` path cannot be exercised outside the editor and was not
@@ -185,6 +350,106 @@ grows a required flag, a subcommand, or a stdio mode switch, `extension.js` and
## Work log
### 2026-08-24 — dev agent (0.4.1, the TextMate grammar)
- **The bug was in this README, not in the server.** The owner asked for
highlighted hover cards; `hover.rs` was already emitting
```` ```systemverilog ```` fences and had been since it was written. What was
missing was the grammar those fences resolve against — the thing this
document had argued against on the grounds that semantic tokens cover the
buffer, which is true and irrelevant to markdown. The stance is updated in
place with the reasoning, not quietly deleted: see "The TextMate grammar".
- **No server code changed.** The whole fix is `editors/vscode/`. Everything in
`crates/` is either a test or a test assertion.
- **Fence audit — every markdown surface the server emits, checked, three
changes, all of them assertions.** The surfaces are:
| Surface | Contains code? | Fenced? | Action |
|---|---|---|---|
| `hover.rs:89` `` `define`` expansion | yes, a block | ```` ```systemverilog ```` | pinned the exact fenced string in `hovering_a_macro_usage_shows_its_body` |
| `hover.rs:131` declaration snippet | yes, a block | ```` ```systemverilog ```` | pinned in `hovering_a_use_shows_its_declaration` |
| `completion.rs:423` template documentation (M6) | yes, a block | ```` ```systemverilog ```` | pinned in `a_templates_documentation_shows_what_it_expands_to` |
| `completion.rs:615` instantiation documentation (M4) | **no block** — a `**Parameters**`/`**Ports**` bullet list whose port signatures are *inline* spans | n/a | **no change**: markdown has no info string for an inline span, so there is nothing to tag. Fencing the list would be a restructure, which the brief ruled out |
| `signature.rs:85` signature help | no | n/a | **no change**: `label` is not markdown (the client renders it itself) and `documentation` is `Documentation::String(warnings)` — prose |
| `hover.rs:41,120` "no definition found" / "declared in `x.sv:12`" | no | n/a | no change |
So the audit's outcome is "already correct everywhere it mattered", and the
three assertions exist so it stays that way — a fence tag is now a
cross-module contract (Handshake 6) and silently breaking it costs the
feature the owner just asked for.
- **The `.v` question, answered rather than assumed.** The fences say
`systemverilog` unconditionally, including in a hover shown from a `.v`
buffer. That resolves, because VS Code looks a fence's info string up in the
global language registry — the hovered document's own language id plays no
part. The `.v` buffer's *own* colouring comes from the `verilog`
registration, which is why the grammar is registered for both ids;
`both_language_ids_are_registered_for_the_grammar` asserts it.
- **Keywords are generated, never typed.** The alternation was produced
mechanically from `token.rs`'s `keywords!` macro (181 words) and is checked
against `vlog_parser::KEYWORDS` by a test, per the brief. Both tests were
**negative-controlled** rather than assumed to work: deleting `genvar` from
the alternation fails with `missing: ["genvar"]`, and corrupting `"//.*"`
into `"//(.*"` fails with
`.repository.comments.patterns[0].match has unbalanced ( or []`. Restored,
re-run green.
- **No regex engine, so no compile test — and the gap was closed by hand.**
`regex` is not in the workspace and a test does not justify adding it. All 13
`match`/`begin`/`end` patterns were compiled and *run* with Python's `re`
(equivalent to Oniguruma over the subset the grammar uses) against a sample
buffer. Verified tokenizations, including the ones that would have been bugs:
`8'hFF`/`4'b10xz`/`32'sd10`/`'b1` take the based-literal rule and not the
decimal one (same start offset, so rule *order* decides — based is listed
first); `'0`/`'1`/`'x` are fill literals; `1.5e-3` and `10ns` are numeric;
`int'(x)` gives `int` the keyword and leaves `'(` alone; `` `define `` beats
the generic macro rule; `a = "s // not a comment"; // real` puts the `//`
inside the string and still finds the trailing comment; `s = "unterminated`
stops at the end of its line. `always @(*)` survives — which is the whole
reason `(* attributes *)` is not in the grammar.
- **Scope names were chosen from this machine's themes, not from convention.**
Grepped `theme-defaults/themes/{dark,light}_{vs,plus}.json` in VS Code
1.123.0 for what is actually coloured; bare `keyword` is, which is what makes
a flat `keyword.other.systemverilog` viable and lets the keyword list stay
generated. Recorded in the section above.
- **The duplicate-scope risk was checked against VS Code's shipped source**
(`TMScopeRegistry.register`): the warning fires only when the two
registrations point at *different* files. Same path, no warning. A test keeps
the paths identical.
- **Version 0.4.1** across `Cargo.toml`, `Cargo.lock` (regenerated by
`cargo check --workspace`, 8 crate entries), `editors/vscode/package.json`,
`package-lock.json` (both places), the two `.vsix` install examples in
`README.md` and `editors/vscode/README.md`, and the eleven version strings in
`tools/RELEASING.md`; `CHANGELOG.md` gains a `0.4.1 — 2026-08-24` section.
`editors/vscode/README.md:159`'s "since 0.4.0" is history and was left alone.
`target/debug/vfmt --version` → `vfmt 0.4.1`.
- **`RELEASING.md` grew one line**, because a `.vscodeignore` that swallowed
`syntaxes/` would ship an extension whose hovers are grey again with nothing
failing: the packaging step now checks the grammar is *in* the `.vsix`, next
to the existing check that `smoke.js` is out of it.
- Did not run `git commit` / `git push`. Did not touch `TODO.md` or the
umbrella README beyond its one `.vsix` version string.
**What was validated on this machine, precisely:**
| Check | Result |
|---|---|
| `cargo fmt --all --check` | clean |
| `cargo clippy --all-targets` | clean, no new warnings, no `#[allow]` added |
| `cargo test --workspace` | **34 test binaries, all green** (`vfmt_server`: 308 unit + 17 e2e + **3 new** grammar) |
| Negative control: keyword removed from the alternation | drift test fails, names `genvar` |
| Negative control: `"//.*"` → `"//(.*"` | validity test fails, names the pattern and the file path |
| `node --check extension.js` / `smoke.js` | both parse |
| `package.json`, `package-lock.json`, the grammar as JSON | all three load |
| `npx @vscode/vsce ls` | accepts the manifest — 324 files; `syntaxes/systemverilog.tmLanguage.json` listed, `smoke.js` still excluded |
| `node smoke.js ../../target/debug/vfmt-server` | `smoke: OK`, 8 messages, exit 0 |
| `target/debug/vfmt --version` | `vfmt 0.4.1` |
| Grammar patterns under Python `re` on a sample buffer | 13/13 compile; tokenization as listed above |
**Not run, and why:** no tokenization through `vscode-textmate` (not in
`node_modules`; adding it is a new dev dependency), and the extension still has
never run inside VS Code — `require('vscode')` resolves only in the extension
host, unchanged since 2026-08-19. What a human should look at once, in an
editor: a hover over a `` `define`` and over a `wire` declaration, in a `.sv`
file **and** a `.v` file, and the Developer Tools console for the absence of an
"Overwriting grammar scope name" warning.
### 2026-08-19 — dev agent
- Read `CLAUDE.md`, `README.md`, TODO.md §6 and
@@ -286,6 +551,155 @@ grows a required flag, a subcommand, or a stdio mode switch, `extension.js` and
## QA log
### 2026-08-24 — QA agent (0.4.1, the TextMate grammar)
Scope: the grammar, its two new tests, the fence audit, and the version bump.
Did not re-verify the 0.4.0 extension surface (`extension.js`, `smoke.js`,
`vscode-languageclient`) beyond confirming it is unchanged — see the diff
check below. No source was edited beyond the mutation-check round-trip (grammar
JSON temporarily mutated, then restored and md5-verified — see below); this
entry is the only lasting write.
**Gates — all green, matching the dev's numbers exactly.**
| Check | Result |
|---|---|
| `cargo fmt --all --check` | clean |
| `cargo clippy --all-targets` | clean, 0 warnings |
| `cargo test --workspace` | all green |
| `cargo test -p vfmt_server` | **308 unit + 17 e2e + 3 grammar**, all passing — matches the claim exactly |
| `node --check extension.js` / `smoke.js` | both parse |
| `npx @vscode/vsce ls` | **324 files**, `syntaxes/systemverilog.tmLanguage.json` listed (line 7), `smoke.js` absent — matches the claimed count exactly |
| `cargo metadata` | all 8 workspace crates report `0.4.1` |
**Drift-test mutation check (`the_grammars_keywords_are_exactly_the_lexers`),
independently re-run.** Removed `|genvar|` from
`editors/vscode/syntaxes/systemverilog.tmLanguage.json`'s keyword alternation
via a small Python script, re-ran the test: failed exactly as claimed —
`missing: ["genvar"]`. Restored from a backup copy taken before the mutation;
`md5 -q` before and after the restore both report
`3aa7799b07a19cd52cf07713812b7054`; `git diff --stat` on the file is empty
after restore; all three grammar tests green again. The dev's second negative
control (`"//.*"` → `"//(.*"` on `every_pattern_is_a_plain_regex`) was not
independently re-run — the assertion it exercises (`balanced()`) was read and
is straightforward enough to trust by inspection.
**Fence audit — `git diff` on the three touched crate files, read in full.**
`hover.rs` and `completion.rs` diffs are assertion-only, exactly as claimed:
each new line either pins the `` ```systemverilog\n `` fence prefix in an
existing test or is a comment explaining why. No non-test line changed in
either file. `signature.rs` has no diff at all (`git status --short` shows
nothing for it). Matches the Work log's audit table.
**Registration claim (package.json).** Both `contributes.grammars` entries
name `scopeName: "source.systemverilog"` and
`path: "./syntaxes/systemverilog.tmLanguage.json"` — identical, as required
for the "same file, no warning" claim to hold. `contributes.languages` declares
exactly `verilog` and `systemverilog`, matching the two grammar entries'
`language` fields. `engines.vscode` is `^1.82.0`. The "checked against VS
Code's own shipped source" claim (`TMScopeRegistry.register`, quoted with a
real file path and version 1.123.0) reads as genuinely verified-against-source
rather than invented — it names a specific function and a specific
warn-only-on-mismatch condition, not a paraphrase. **One gap worth recording,
not blocking:** the source was read on VS Code 1.123.0, and the extension
declares compatibility down to `^1.82.0` — roughly three years and 40+ minor
versions earlier. Nothing here suggests `TMScopeRegistry.register`'s
warn-on-mismatch behavior changed in that span, but the doc doesn't say the gap
was considered, and "checked on this machine" is not the same claim as
"checked across the declared engine range." Low priority: even in the worst
case (a console warning on old VS Code versions), the grammar still registers
and still colors correctly — the risk is a log line, not a highlighting
failure.
**Tokenization — regexes run for real, two engines, no vscode-textmate
added.** Wrote a throwaway Node script
(`scratchpad/tokenize.js`, not committed) that (1) compiles every
`match`/`begin`/`end` string with `new RegExp` — all 13 compile — and (2)
hand-implements the TextMate first-match-wins scan (per-line, block-comment
state carried across lines, string end resolved per-line) using the grammar's
own pattern order, and ran it against the requested adversarial lines. Cross-
checked the one finding below against Python's `re` too (the dev's own stated
methodology), not just Node's engine.
Confirmed correct, matching the doc's claims exactly: `8'hFF_AB`, `4'b10xz`,
`'0`, `32'sd10`, `'h1F` (based/fill win over the decimal rule); `1.5e-3`,
`10ns` (decimal/time rule); `always @(*)` (`always` is the only token colored,
`@(*)` stays plain — the attribute pattern was correctly left out); `(* full_case
*)` (entirely plain, does not disturb the trailing statement — the omission is
safe as designed); `"s // not a comment"` (the whole thing is one string token,
`//` does not start a comment inside it); `// comment with "quote` (the whole
line is one comment token, the quote does not start a string); two `/* */
... /* */` on one line (two independent block-comment tokens, code between
them plain); `` `define X 8'hFF `` (directive then based-literal, cleanly
split); `` `MY_MACRO(a,b) `` (macro token stops at the identifier, `(a,b)`
plain); backtick inside a `//` comment (stays comment, no directive/macro
token generated); `$display`, `$clog2` (system-task token, correct); `logic_t
foo;` and `xor_gate bar;` (entirely plain — the keyword rule's `\b...\b`
correctly refuses to match a keyword that is only a prefix of a longer
identifier); `1step` (matches nothing — not a number, not a keyword; sits as
plain text, which is a fair reading of "deliberately omitted", though the doc
only says the omission exists and doesn't say what it renders as).
**Finding A (confirmed, not blocking, but real and reproducible) — `x$y`
splits into `x` (plain) + `$y` (`support.function.system`).** The
system-tasks pattern is `\$[a-zA-Z_][a-zA-Z0-9_$]*`
(`editors/vscode/syntaxes/systemverilog.tmLanguage.json:53`) with no boundary
check on what precedes the `$`. SystemVerilog identifiers may legally contain
`$` after the first character (`[a-zA-Z_][a-zA-Z0-9_$]*`), so `x$y` is a valid
identifier, not `x` followed by a system task — but the grammar colors the
`$y` tail as if it were one. Reproduced identically in Node (the hand-written
scanner) and in Python's `re` (`pat.search("x$y = 1;")` → `('$y', 1)`, run
independently of the scanner). This is exactly the risk the brief asked to
check ("does the regex have a boundary?") — it does not.
Severity assessment: cosmetic, not a corruption risk under CLAUDE.md's
invariant #1 — this grammar colors a hover-card fence or a buffer, never the
formatter's output, so no code is ever rewritten because of it. A genuine fix
needs a negative lookbehind (`` (?<![a-zA-Z0-9_$])\$... ``), which is the exact
class of Oniguruma-only construct `every_pattern_is_a_plain_regex` forbids —
so this may be the same kind of accepted trade-off the README already made
explicitly for `(* attributes *)`. The difference: the attribute trade-off is
written down with its reasoning in "Deliberate omissions"; this one is not
mentioned anywhere, so a reader of the pattern-inventory table (`` `$display`,
`$clog2` ``) would not learn that a `$`-containing identifier can mis-color.
Recommend adding one line to "Deliberate omissions" naming this, the same way
the attribute trade-off is named — not fixing the regex, since fixing it
trades one forbidden construct for another and `$`-in-the-middle identifiers
are rare in practice. Not fixed here: it's a documentation gap and a
judgment call about the grammar's design, not a typo.
**Finding B (confirmed, not blocking, minor) — an unterminated block comment
bleeds to the end of the buffer, and only the string rule was hardened against
the analogous failure.** `strings.end` is `` "\"|$" `` specifically so "an
unterminated string cannot bleed down a hover card" (the README says so in the
pattern inventory). `comments.block` has no such fallback: `begin: "/\\*"`,
`end: "\\*/"`, and if `\*/` never appears, the block-comment state carries
across every remaining line — verified in the scanner with a 3-line buffer
(`code /* oops` / `more code` / `last line`): all three lines end up entirely
`comment.block` from the point of `/*` onward. Blast radius is bounded to the
current hover card's fenced snippet (hover fences are the declaration/macro
text, not the whole document), not "the whole file" the README worried about
for the attribute case, so this is meaningfully smaller than that risk — but
it is the same shape of risk, and the doc discusses the mitigation it *did*
add (strings) without mentioning the one it didn't (comments). Plausible
trigger: a macro body captured verbatim by `` `define`` that itself contains
an unclosed `/*` (a real authoring mistake, not a contrived case) would render
the rest of that hover card dimmed as a comment. Not fixed here, same reasoning
as Finding A — a doc note, not a code change, is the right-sized response.
**No BLOCKING findings.** Gates green, counts exact, mutation controls behave
exactly as claimed, fence audit clean, registration correct. Findings A and B
are both display-only, bounded in scope, and already structurally similar to a
trade-off the README makes explicitly elsewhere — recommend documenting both
in "Deliberate omissions" before the next version bump, but neither blocks
this one shipping.
**Verdict: ship.** The core claim — hover cards and completion documentation
render highlighted, via a grammar registered for both language ids, verified
by a drift test that actually catches drift — holds up under adversarial
tokenization testing, not just the happy-path patterns the dev's own Python
session checked.
### 2026-08-19 — QA agent
**Build tested:** `HEAD` at `c8b936a7` plus the working tree exactly as it
@@ -482,3 +896,16 @@ Remaining editor work is deliberately out of scope and stays visible:
publishing (a real publisher id, marketplace/OpenVSX), extension-host
integration testing, and lint diagnostics reaching the editor once the
server wires vlog_linter in.
### 2026-08-24 — lead review of the grammar (hover highlighting)
Approved after QA's ship verdict; gates run independently (1295 tests, 0
failures, clippy silent). The server was already fencing hover markdown as
`systemverilog` — the whole feature is the missing TextMate grammar, and
the shape is right: keywords generated from `vlog_parser::KEYWORDS` with a
mutation-checked drift test, a lookaround-free pattern set QA exercised
under real first-match-wins semantics, and the double-registration trick
verified against VS Code's own source. Dev's deliberate omissions all
approved; QA's two cosmetic finds (`x$y`, unterminated `/*`) are accepted
trade-offs I have added to "Deliberate omissions" above rather than fix —
each fix needs a lookbehind or buys nothing. Ships as 0.4.1.
+32
View File
@@ -363,6 +363,20 @@ Two rules that are easy to get wrong and are tested:
The snippet is `decl_span` widened to whole lines, so a declaration reads as
it was written rather than starting mid-line.
**The fence tag is a contract now (0.4.1).** Every code block this server puts
in markdown — both hover snippets and the completion templates' documentation
panel — opens ```` ```systemverilog ````, unconditionally, `.v` buffers
included. Since 0.4.1 the VS Code extension contributes a TextMate grammar
registered for exactly that language id, and that grammar is the *only* thing
that colours a hover card: semantic tokens cannot reach markdown, and VS Code
resolves a fence's info string against the language registry rather than
against the hovered document. Changing the tag, or fencing a new surface with a
different one, silently returns every card to flat grey. The three call sites
pin the exact fenced string in their own tests; the registration is pinned by
`crates/vfmt_server/tests/grammar.rs`, which also holds the extension's keyword
list to `vlog_parser::KEYWORDS`. Rationale and inventory:
`docs/features/editor-packaging/README.md`.
## Status / TODO
- [x] Crate skeleton compiling **before** the root `members` entry (the
@@ -411,6 +425,24 @@ it was written rather than starting mid-line.
## Work log
### 2026-08-24 — dev agent (0.4.1, fence audit only)
Owned by `docs/features/editor-packaging/README.md`; noted here because it
turned one of this crate's output details into a cross-module contract.
- **No behaviour changed in this crate.** Every markdown surface it emits was
audited for unfenced code: `hover.rs:89` and `hover.rs:131` and
`completion.rs:423` already carried ```` ```systemverilog ```` and were left
exactly as they are; `completion.rs:615` (the M4 instantiation documentation)
is a bullet list whose port signatures are *inline* code spans, which markdown
cannot tag and which a fence would restructure, so it was left alone; and
`signature.rs:85` emits prose in `Documentation::String` with a `label` the
client renders itself, so neither is markdown at all.
- **Three test assertions were added** — one per code-carrying surface —
pinning the exact fenced string rather than just the payload, because the tag
is what the extension's new TextMate grammar keys off. See the section "The
fence tag is a contract now" above.
### 2026-08-19 — dev agent
- Read `CLAUDE.md`, `README.md`, TODO.md §6 in full, and the Handshakes/API
+28 -4
View File
@@ -4,8 +4,9 @@ A thin extension: it registers the Verilog/SystemVerilog file types and starts
`vfmt-server`. Every *analysis* feature you see — formatting, diagnostics,
semantic highlighting, hover, go-to-definition, references, symbols — comes
from the server, so this directory contains no language logic and no
editor-specific commands. The one exception is the snippet library below, which
is static data VS Code reads straight from the manifest. See
editor-specific commands. The two exceptions are the snippet library and the
TextMate grammar below, both static data VS Code reads straight from the
manifest — LSP has no channel for either. See
`docs/features/vfmt-server/README.md` for the capability list,
`docs/features/editor-packaging/README.md` for why the extension looks like
this, and `docs/features/editor-snippets/README.md` for the snippets.
@@ -46,14 +47,14 @@ catches "the binary moved" or "the handshake broke" without launching VS Code.
```bash
npm ci # installs vscode-languageclient (the only dependency)
npx @vscode/vsce package
code --install-extension vfmt-0.4.0.vsix
code --install-extension vfmt-0.4.1.vsix
```
Then reload VS Code and open a `.v`/`.sv`/`.vh`/`.svh` file.
`tools/release.sh` from the repo root does all of the above (plus the release
binaries and checksums) and drops the `.vsix` in `dist/`, so
`code --install-extension dist/vfmt-0.4.0.vsix` is the one-command path.
`code --install-extension dist/vfmt-0.4.1.vsix` is the one-command path.
`editors/vscode/LICENSE` is a copy of the repo's MIT license and is what lets
`vsce package` run without `--skip-license`. If you are packaging a fork that
dropped `package.json`'s `repository` field, add `--allow-missing-repository`.
@@ -117,6 +118,29 @@ does not list still works. A filelist that names a file which has moved warns
and skips it; a filelist that cannot be read at all warns and falls back to
walking the folder — the index is never silently empty.
## Syntax highlighting
Two highlighters, and they are not rivals:
- **Semantic tokens, from the server.** What actually colours your buffer while
the server is running — it knows a name is a port, a parameter or a macro,
which no regex can. Fourteen token types; nothing to configure.
- **A TextMate grammar, from this extension** (`syntaxes/`). Keywords,
comments, strings, numbers (`8'hFF`, `4'b10xz`, `'0`, `1.5e-3`, `10ns`),
`$system_tasks`, `` `directives `` and macro uses. Semantic tokens win
wherever they have something to say, so in a live buffer this mostly fills in
the gaps — but it is the only highlighter in three places that matter:
**hover cards and completion documentation** (the server sends those as
```` ```systemverilog ```` markdown, and markdown is coloured by grammar, not
by semantic tokens), a file before the server has started, and previews VS
Code renders without a language server at all, such as a diff or a git blame.
One grammar file serves both `verilog` and `systemverilog`, because vfmt's
lexer draws no line between the two. Its keyword list is generated from that
lexer's own list and a test in the repository fails if they drift apart. It
covers no operators and no `(* attributes *)` — see
`docs/features/editor-packaging/README.md` for why.
## Rainbow begin/end
Each nesting level of `begin`/`end` and `fork`/`join` is coloured differently,
+2 -2
View File
@@ -1,12 +1,12 @@
{
"name": "vfmt",
"version": "0.4.0",
"version": "0.4.1",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "vfmt",
"version": "0.4.0",
"version": "0.4.1",
"license": "MIT",
"dependencies": {
"vscode-languageclient": "9.0.1"
+13 -1
View File
@@ -2,7 +2,7 @@
"name": "vfmt",
"displayName": "vfmt — Verilog/SystemVerilog",
"description": "Formatting, diagnostics, navigation and semantic highlighting for Verilog and SystemVerilog, served by the vfmt language server.",
"version": "0.4.0",
"version": "0.4.1",
"publisher": "REPLACE-ME",
"license": "MIT",
"repository": {
@@ -47,6 +47,18 @@
]
}
],
"grammars": [
{
"language": "verilog",
"scopeName": "source.systemverilog",
"path": "./syntaxes/systemverilog.tmLanguage.json"
},
{
"language": "systemverilog",
"scopeName": "source.systemverilog",
"path": "./syntaxes/systemverilog.tmLanguage.json"
}
],
"snippets": [
{
"language": "verilog",
@@ -0,0 +1,76 @@
{
"information_for_contributors": [
"One grammar for both contributed language ids: `verilog` and `systemverilog` register the same scopeName and the same file in package.json, because vfmt's own lexer draws no line between the two dialects.",
"The keyword alternation in `repository.keywords.match` is generated from `vlog_parser::KEYWORDS` and must stay identical to it. `crates/vfmt_server/tests/grammar.rs` fails the build if the two drift apart — regenerate, do not hand-edit.",
"Deliberately absent: operators, `(* attributes *)`, and any rule needing lookaround. The reasoning is in docs/features/editor-packaging/README.md."
],
"name": "SystemVerilog",
"scopeName": "source.systemverilog",
"patterns": [
{ "include": "#comments" },
{ "include": "#strings" },
{ "include": "#directives" },
{ "include": "#macros" },
{ "include": "#system-tasks" },
{ "include": "#numbers" },
{ "include": "#keywords" }
],
"repository": {
"comments": {
"patterns": [
{
"name": "comment.line.double-slash.systemverilog",
"match": "//.*"
},
{
"name": "comment.block.systemverilog",
"begin": "/\\*",
"end": "\\*/"
}
]
},
"strings": {
"name": "string.quoted.double.systemverilog",
"begin": "\"",
"end": "\"|$",
"patterns": [
{
"name": "constant.character.escape.systemverilog",
"match": "\\\\."
}
]
},
"directives": {
"name": "keyword.control.directive.systemverilog",
"match": "`(define|undefineall|undef|ifdef|ifndef|elsif|else|endif|include|timescale|default_nettype|resetall|celldefine|endcelldefine|unconnected_drive|nounconnected_drive|line|begin_keywords|end_keywords|pragma|__FILE__|__LINE__)\\b"
},
"macros": {
"name": "entity.name.function.preprocessor.systemverilog",
"match": "`[a-zA-Z_][a-zA-Z0-9_$]*"
},
"system-tasks": {
"name": "support.function.system.systemverilog",
"match": "\\$[a-zA-Z_][a-zA-Z0-9_$]*"
},
"numbers": {
"patterns": [
{
"name": "constant.numeric.based.systemverilog",
"match": "(\\b[0-9][0-9_]*\\s*)?'[sS]?[bBoOdDhH][0-9a-fA-FxXzZ?_]+"
},
{
"name": "constant.numeric.fill.systemverilog",
"match": "'[01xXzZ]\\b"
},
{
"name": "constant.numeric.systemverilog",
"match": "\\b[0-9][0-9_]*(\\.[0-9_]+)?([eE][-+]?[0-9_]+)?(fs|ps|ns|us|ms|s)?\\b"
}
]
},
"keywords": {
"name": "keyword.other.systemverilog",
"match": "\\b(module|macromodule|endmodule|interface|endinterface|package|endpackage|program|endprogram|modport|clocking|endclocking|input|output|inout|ref|wire|tri|tri0|tri1|wand|wor|trireg|supply0|supply1|uwire|reg|logic|bit|byte|shortint|int|longint|integer|time|realtime|real|shortreal|string|chandle|event|var|void|signed|unsigned|packed|parameter|localparam|defparam|specparam|type|typedef|enum|struct|union|assign|alias|always|always_comb|always_ff|always_latch|initial|final|begin|end|if|else|case|casex|casez|randcase|let|endcase|default|unique|unique0|priority|for|while|repeat|forever|do|foreach|break|continue|return|fork|join|join_any|join_none|disable|wait|posedge|negedge|edge|or|and|nand|nor|xor|xnor|not|buf|bufif0|bufif1|notif0|notif1|pullup|pulldown|generate|endgenerate|genvar|class|endclass|extends|implements|virtual|pure|extern|rand|randc|local|protected|constraint|covergroup|endgroup|function|endfunction|task|endtask|automatic|static|const|import|export|timeunit|timeprecision|assert|assume|cover|property|endproperty|sequence|endsequence|inside|with|iff|release|force|deassign|primitive|endprimitive|specify|endspecify|table|endtable|small|medium|large|scalared|vectored|highz0|highz1|strong0|strong1|pull0|pull1|weak0|weak1|cmos|rcmos|nmos|pmos|rnmos|rpmos|tran|rtran|tranif0|tranif1|rtranif0|rtranif1)\\b"
}
}
}
+13 -11
View File
@@ -61,9 +61,9 @@ recreated on every run.
```
dist/
vfmt-0.4.0-aarch64-apple-darwin
vfmt-server-0.4.0-aarch64-apple-darwin
vfmt-0.4.0.vsix
vfmt-0.4.1-aarch64-apple-darwin
vfmt-server-0.4.1-aarch64-apple-darwin
vfmt-0.4.1.vsix
SHA256SUMS
```
@@ -105,17 +105,19 @@ npx @vscode/vsce package --out ../../dist/vfmt-<version>.vsix
repo and only writes its *output* to `-o`.
- `.vscodeignore` keeps `smoke.js`, `.vscode/**` and `.gitignore` out of the
package. Check that after any change to it:
`unzip -l dist/vfmt-<version>.vsix | grep smoke` must print nothing.
`unzip -l dist/vfmt-<version>.vsix | grep smoke` must print nothing, and
`unzip -l dist/vfmt-<version>.vsix | grep syntaxes` must print the grammar —
without it, hover cards ship unhighlighted.
## 5. Install / distribute
```bash
# the CLI and the server: anywhere on PATH
install -m 755 dist/vfmt-0.4.0-aarch64-apple-darwin ~/.local/bin/vfmt
install -m 755 dist/vfmt-server-0.4.0-aarch64-apple-darwin ~/.local/bin/vfmt-server
install -m 755 dist/vfmt-0.4.1-aarch64-apple-darwin ~/.local/bin/vfmt
install -m 755 dist/vfmt-server-0.4.1-aarch64-apple-darwin ~/.local/bin/vfmt-server
# the editor extension: sideload, no marketplace involved
code --install-extension dist/vfmt-0.4.0.vsix
code --install-extension dist/vfmt-0.4.1.vsix
```
Publishing the artifacts is a matter of attaching `dist/`'s contents plus
@@ -123,8 +125,8 @@ Publishing the artifacts is a matter of attaching `dist/`'s contents plus
gate is green:
```bash
git tag -a v0.4.0 -m 'vfmt 0.4.0'
git push origin v0.4.0
git tag -a v0.4.1 -m 'vfmt 0.4.1'
git push origin v0.4.1
```
## Appendix — if the owner ever publishes to a marketplace
@@ -151,10 +153,10 @@ The commands themselves, once those exist:
# VS Code Marketplace: needs an Azure DevOps PAT for the publisher
npx @vscode/vsce publish -p "$VSCE_TOKEN"
# ... or publish an already-built package
npx @vscode/vsce publish --packagePath dist/vfmt-0.4.0.vsix -p "$VSCE_TOKEN"
npx @vscode/vsce publish --packagePath dist/vfmt-0.4.1.vsix -p "$VSCE_TOKEN"
# Open VSX (VSCodium, Gitpod, Cursor): needs an Eclipse Foundation account
npx ovsx publish dist/vfmt-0.4.0.vsix -p "$OVSX_TOKEN"
npx ovsx publish dist/vfmt-0.4.1.vsix -p "$OVSX_TOKEN"
```
Both tokens are secrets. Neither belongs in this repo, in a shell history, or