editor-packaging: a minimal VS Code extension (41-line plain JS on
vscode-languageclient =9.0.1, one setting vfmt.serverPath, languages
verilog/systemverilog) with a zero-dependency smoke.js that validates
the extension's exact spawn contract against the real binary, plus
Neovim/Vim/coc setup docs (including the load-bearing
vim.filetype.add — Vim maps *.v by content heuristic and *.vh not at
all). Everything headless-validatable was validated: the .vsix
builds, smoke passes with negative controls, npm ci reproduces.
vfmt-core-lift: config.rs and walk.rs moved to a new std-only
vfmt_core crate as byte-identical 100% renames (CLI suite untouched,
corpus TSV md5 equal from HEAD and lifted builds). The LSP server
now discovers vfmt.toml per document with precedence config > client
tabSize > built-in default (an editor default is not a deliberate
override), warns once per document change on a broken config while
formatting with defaults, and scans the workspace with the lifted
gitignore-aware walk. QA drove every claim live over stdio.
With these, every TODO §6 item is delivered: spans, tolerant
parsing, define table, single-file semantics, workspace index, the
server, and both editors. Lead trued up the caveats this round made
stale across five documents.
Dev: 2 Opus agents; QA: 2 Sonnet agents; reviews in
docs/features/{editor-packaging,vfmt-core-lift}/README.md.
Co-Authored-By: Claude Fable 5 <[email protected]>
42 lines
1.5 KiB
JavaScript
42 lines
1.5 KiB
JavaScript
// The whole VS Code extension: start `vfmt-server` over stdio and let the
|
|
// language client do the rest. There is deliberately no command, no status
|
|
// bar item and no setting other than the server's path — every feature the
|
|
// user sees comes from the server, so anything else added here would be
|
|
// editor-specific logic above the protocol (docs/features/editor-packaging).
|
|
|
|
const vscode = require('vscode');
|
|
const { LanguageClient, TransportKind } = require('vscode-languageclient/node');
|
|
|
|
/** The single client, kept only so `deactivate` can stop it. */
|
|
let client;
|
|
|
|
/** Spawn the server and attach it to Verilog/SystemVerilog documents. */
|
|
function activate(context) {
|
|
const serverPath = vscode.workspace.getConfiguration('vfmt').get('serverPath') || 'vfmt-server';
|
|
|
|
// No arguments: `vfmt-server` takes none and speaks LSP on stdin/stdout.
|
|
// `editors/vscode/smoke.js` spawns it exactly this way.
|
|
const serverOptions = {
|
|
command: serverPath,
|
|
args: [],
|
|
transport: TransportKind.stdio,
|
|
};
|
|
|
|
// No `scheme` filter: the server serves `untitled:` buffers too, for
|
|
// everything single-file (docs/features/vfmt-server/README.md).
|
|
const clientOptions = {
|
|
documentSelector: [{ language: 'verilog' }, { language: 'systemverilog' }],
|
|
};
|
|
|
|
client = new LanguageClient('vfmt', 'vfmt', serverOptions, clientOptions);
|
|
context.subscriptions.push(client);
|
|
client.start();
|
|
}
|
|
|
|
/** Stop the server; VS Code waits on the returned promise. */
|
|
function deactivate() {
|
|
return client ? client.stop() : undefined;
|
|
}
|
|
|
|
module.exports = { activate, deactivate };
|