Skip to main content

VS Code and Cursor extension

Twain ships an extension for VS Code, Cursor, and other VS Code-compatible editors. It opens the file you are editing in the Twain app, and runs the checker so results appear in the Problems panel.

Not yet published

The extension is built but not yet on any marketplace. For now, install it from a packaged VSIX (see below). It also relies on the CLI, which is not yet published either, so you will need to point it at the CLI from a checkout.

Commands

Open the command palette and search for these (all under the Twain category), or use the editor and Explorer context menus:

CommandWhat it does
Open in TwainOpens the current file in the Twain macOS app, rendered. macOS only.
Show Changes in TwainOpens the current file in the Twain app with its changes marked against the last saved version. See Showing changes. macOS only.
Check with TwainRuns the checker and shows the findings in the Problems panel. Saves the file first if needed.
Clear Twain DiagnosticsRemoves the findings this extension added.

Open in Twain hands the file to the app with macOS open, using the configured app path or, when that path does not exist, the bundle identifier md.twain-md.app. Show Changes in Twain asks the app to open the file through its twain-md:// URL scheme instead. On the Mac App Store edition, the sandbox only lets the app open a file it has already been granted access to, so handing it a file through the URL scheme works best for files inside a folder you have opened in Twain. The direct download has no such restriction. See Editions.

Findings in the Problems panel

Check with Twain runs the CLI's check and turns each finding into a Problems-panel entry: warnings appear as warnings, informational findings as information, each labelled with its kind. You can turn on Check on Save in the settings to run it automatically every time you save.

Settings

SettingDefaultPurpose
twain-md.appPath/Applications/Twain.appWhere the app is installed
twain-md.cliPath(empty)Path to the CLI; needed while the CLI is unpublished
twain-md.nodePathnodeNode.js used to run the CLI
twain-md.checkOnSavefalseRun the checker on every save
twain-md.strictfalsePass --strict to the checker
twain-md.checkRemoteLinksfalsePass --remote to the checker
twain-md.componentMap(empty)A component map; otherwise auto-detected

Because the CLI is not yet on your PATH, set twain-md.cliPath to cli/twain-md.mjs in a Twain checkout. The extension will remind you if it cannot find the CLI.

Installing from a VSIX

cd editors/vscode
npx @vscode/vsce package
code --install-extension twain-md-vscode-0.1.0.vsix

In Cursor, use Extensions: Install from VSIX and pick the packaged file.