From a8c4a2ecf8eeaf3876659a9376b7fa2e240c403e Mon Sep 17 00:00:00 2001 From: Guoliang Chen Date: Mon, 9 Nov 2026 18:53:04 -0800 Subject: [PATCH] =?UTF-8?q?TODO=20=C2=A766.1:=20the=20VS=20Code=20extensio?= =?UTF-8?q?n=20declares=20the=20language's=20comments=20and=20brackets=20(?= =?UTF-8?q?Ctrl+/=20toggles=20comments)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit editors/vscode/language-configuration.json for both verilog and systemverilog: // and /* */, bracket pairs, auto-closing and surrounding pairs. TODO §66 planned (66.1 here, 66.2 selection formatting). Co-Authored-By: Claude Fable 5.2 --- TODO.md | 45 ++++++++++++++++++++++ editors/vscode/language-configuration.json | 24 ++++++++++++ editors/vscode/package.json | 6 ++- 3 files changed, 73 insertions(+), 2 deletions(-) create mode 100644 editors/vscode/language-configuration.json diff --git a/TODO.md b/TODO.md index 98bb2f6..70f64ad 100644 --- a/TODO.md +++ b/TODO.md @@ -7127,3 +7127,48 @@ completion should offer `tb.`'s hierarchical members, answering `None` when the index has no unit of that name. `docs/features/top-rooted-paths`. - [ ] owner/lead decision; if yes, `completion/member.rs` + tests + +## 66. Format Selection that fits where it stands (planned 2026-11-09, owner's order) + +Owner's report: *Format Selection* "fails more than half of the time". The +usual selection is one whole `always` block or one whole `case` statement, +often nested inside blocks the selection does not cover. Reproduced on trunk +(`lucisv --lines`, the engine `textDocument/rangeFormatting` shares): selecting +a `case` re-lays the whole `always` around it; the block is re-indented to the +formatter's own depth × width, so in a file indented any other way it no +longer lines up with its neighbours; a selection inside `generate` re-lays the +whole region; and a file with a parse error anywhere is refused outright. +Owner's rule: do not worry about the parent — the selected block keeps the +indentation level it starts at, and stays functionally the same. + +### 66.1 VS Code language configuration (lead, done 2026-11-09) + +- [x] `editors/vscode/language-configuration.json` (comment tokens, brackets, + auto-closing and surrounding pairs) wired to both language ids in + `editors/vscode/package.json` — Toggle Line/Block Comment (Ctrl+/) works + without another Verilog extension installed. + +### 66.2 Selection formatting (one lane: dev, then QA) + +Feature README: `docs/features/selection-formatting/README.md`. Files: +`crates/vlog_formatter/src/selection.rs` (+ a `selection/` split if it nears +600 lines), `crates/vlog_formatter/src/{lib.rs,printer.rs,format/mod.rs}`, +`crates/vlog_formatter/tests/selection.rs`, `crates/lucisv_server/src/format.rs`, +`crates/lucisv_server/src/server/tests/formatting.rs`, +`crates/lucisv_server/tests/e2e.rs`. `verify.rs`, `range.rs`, `fence.rs`, the +parser and the CLI's `--lines` are not touched. + +- [x] `format_selection`: the smallest run of sibling items/statements the + selected lines cover, laid out alone at the indentation it was written + at, spliced into otherwise untouched bytes. +- [x] Verified whole-file (`verify_equivalence`, unchanged) and converged by + replaying the located target, not the line numbers. +- [x] Fences outrank the selection; a module/package-level target defers to + `format_range` (header/footer splitting). +- [x] A file that does not parse: the target is located in the tolerant tree + and refused when a diagnostic falls inside it. +- [x] `textDocument/rangeFormatting` / `rangesFormatting` call it. +- [x] Tests: the owner's shapes (whole `always`, whole `case`, inside + `generate`, inside a function), off-grid and tab indentation, partial + selections, comments, fences, broken files, masked-corruption attacks on + the splice. diff --git a/editors/vscode/language-configuration.json b/editors/vscode/language-configuration.json new file mode 100644 index 0000000..233b4cb --- /dev/null +++ b/editors/vscode/language-configuration.json @@ -0,0 +1,24 @@ +{ + "comments": { + "lineComment": "//", + "blockComment": ["/*", "*/"] + }, + "brackets": [ + ["(", ")"], + ["[", "]"], + ["{", "}"] + ], + "autoClosingPairs": [ + { "open": "(", "close": ")" }, + { "open": "[", "close": "]" }, + { "open": "{", "close": "}" }, + { "open": "\"", "close": "\"", "notIn": ["string", "comment"] }, + { "open": "/*", "close": " */", "notIn": ["string"] } + ], + "surroundingPairs": [ + ["(", ")"], + ["[", "]"], + ["{", "}"], + ["\"", "\""] + ] +} diff --git a/editors/vscode/package.json b/editors/vscode/package.json index c726426..4f3f5ab 100644 --- a/editors/vscode/package.json +++ b/editors/vscode/package.json @@ -208,7 +208,8 @@ "extensions": [ ".v", ".vh" - ] + ], + "configuration": "./language-configuration.json" }, { "id": "systemverilog", @@ -219,7 +220,8 @@ "extensions": [ ".sv", ".svh" - ] + ], + "configuration": "./language-configuration.json" } ], "grammars": [