Parsnip for VS Code
Syntax highlighting, IntelliSense, formatting, and syntax checking for Parsnip snips — Trident's rule/expression DSL (src/Abbey/Common/Parsnip.Core).
MAP(
FILTER(
@all_products,
AND(
@val['globalKey'] != 'GAP',
@val['globalKey'] != 'VSC',
@val['globalKey'] != 'maintenance'
)
),
@val['name']
)
Features
- Language: files ending in
.snip or .parsnip open as Parsnip. Bracket matching, auto-closing quotes and brackets.
- Highlighting: functions,
@variables, strings, numbers, booleans, operators. Bare identifiers that the real lexer would silently drop (EQ(@a, GAP)) are highlighted as invalid.
- IntelliSense: start typing a name and every Parsnip function drops down with its signature, description and examples; accepting one inserts placeholders for its parameters. Type
@ for variables already used in the file, plus @val / @acc inside FILTER, MAP, REDUCE and friends.
- Signature help: parameter hints while typing inside a call. Hover a function for its docs.
- Format Document / Format Selection (
Shift+Alt+F): reflows a snip to the configured width.
- Parsnip: Format Selection as Snip: command that formats the selected text as a snip in any file type, for snips embedded in C#, JSON or SQL.
- Diagnostics: syntax errors are underlined as you type. A file that does not parse is never reformatted.
- A call or array prints on one line if it fits within
parsnip.format.printWidth; otherwise one argument per line with the closing bracket on its own line.
- Operator chains that do not fit break one operand per line with the operator leading (
&& @apr >= 0.0).
- A single-operator expression keeps the operator on the closing line when only one side needs to break:
COUNT(\n ...\n) > 0.
- Function names and
TRUE/FALSE are uppercased (they are case-insensitive in Parsnip). Variable names are case-sensitive and never changed.
- Numbers and strings are copied verbatim:
5 is a long, 5.0 is a decimal, and strings have no escapes.
- Explicit parentheses are always kept.
- Whitespace is the only thing that changes: the formatted output lexes to exactly the same tokens as the input.
- A file may hold several snips, each starting on its own line; they are separated by one blank line.
Indentation follows the editor's tabSize / insertSpaces for the file.
Settings
| Setting |
Default |
Description |
parsnip.format.printWidth |
80 |
Line width to fit a call or expression into before breaking it. |
Development
npm install
npm run compile
npm run test:unit # fast, pure formatter tests
npm test # extension-host tests (downloads VS Code on first run)
Press F5 to launch an Extension Development Host with the extension loaded.
To package: npx @vscode/vsce package. To publish: npx @vscode/vsce publish (needs a Marketplace PAT for the timscriv publisher; run npx @vscode/vsce login timscriv once).