IRIS Prettier
Languages: English | 简体中文
Prettier-style formatter for InterSystems IRIS ObjectScript (.cls, .mac, .int, etc.).
Formatting only — no linting. Works with the official InterSystems ObjectScript VS Code extension.
Install
Search IRIS Prettier in the marketplace:
ext install iris-prettier.iris-prettier-vscode
Requires an extension that provides objectscript / objectscript-class language IDs (e.g. InterSystems ObjectScript).
Quick start
- Open a
.cls file
- Right-click → Format Document, or
Shift+Alt+F
- Select code → right-click Format Selection / Convert Selection Syntax; or use Preview Format / Preview Syntax Convert to review in a diff before applying
- Set as default formatter in
settings.json (see below)
Features
| Feature |
Description |
| Allman braces |
ClassMethod Foo() and { on separate lines |
| Operator spacing |
Spaces around =, +, -, *, /, _, :, etc. |
Comparisons in () |
(Ingd <= 0), (x >= 1) — spaces on both sides of <= / >= |
| Lowercase commands |
Set → s, If → if |
| Block expansion |
i → if, f → for, e → else |
| Postfix conditions |
Spacing inside q:(...) / s:(...) |
| Method blank lines |
Blank line between adjacent methods |
&sql(...) |
Multiline SQL, lowercase keywords, // after ) |
| Tab indent |
Default tabs in method bodies (1 tab = 4 spaces in IRIS) |
| Selection format |
Indent from enclosing { / } context |
Example:
Before:
ClassMethod Foo() {
Set ret=1
If x=1 s y=2
.i (Ingd<= 0) s Ret=Ingd q
.q:(info="")&&(flag="Y")
}
After:
ClassMethod Foo() {
s ret = 1
if x = 1 s y = 2
.i (Ingd <= 0) s Ret = Ingd q
.q:(info = "")&&(flag = "Y")
}
Block syntax example (non–dot syntax):
Before:
ClassMethod M() {
If (count>0)&&(status="Y") {
Set ret=1
} Else {
Set ret=0
}
}
After:
ClassMethod M() {
if (count > 0) && (status = "Y") {
s ret = 1
} else {
s ret = 0
}
}
Dot syntax → block
Before:
i $d(^DHCRETA(0,"TypePointer","G",rowid)) d
.s retarowid=$o(^DHCRETA(0,"TypePointer","G",rowid,""))
.e d
.&sql(insert into DHC_RetAspAmount ...)
i SQLCODE'=0 d
.s ret=$$SqlErrorRecord^DHCSTERROR(...)
After:
if $d(^DHCRETA(0,"TypePointer","G",rowid)) {
s retarowid=$o(^DHCRETA(0,"TypePointer","G",rowid,""))
} else {
&sql(insert into DHC_RetAspAmount ...)
}
if (SQLCODE'=0) {
s ret=$$SqlErrorRecord^DHCSTERROR(...)
}
for dot syntax example:
Before:
f s info = $o(^IRIS("info", info)) q:info="" d
.s flag = $p(^IRIS("info", info), "^", 1)
.i flag = "1" d
.// todo
After:
for {
s info = $o(^IRIS("info", info)) q:info=""
s flag = $p(^IRIS("info", info), "^", 1)
if (flag = "1") {
// todo
}
}
Also supports: .e i → elseif, range for, inline i cond s cmd, q: → continue: in loops, and selection conversion without a method header.
Dot-to-block pre-formats source before conversion. Use Preview Syntax Convert to review in a side-by-side diff, then click Apply in the notification.
Commands
| Action |
Command palette |
Context menu |
Shortcut |
| Format document |
IRIS Prettier: Format Document |
— |
Shift+Alt+F |
| Format current method |
IRIS Prettier: 格式化当前方法 |
✓ |
— |
| Preview format |
IRIS Prettier: 预览格式化 |
✓ |
— |
| Preview syntax convert |
IRIS Prettier: 预览语法转换 |
✓ |
— |
| Format selection |
IRIS Prettier: 格式化选定内容 |
✓ |
Ctrl+K Ctrl+F |
| Convert selection |
IRIS Prettier: 转换选定内容语法 |
✓ |
— |
| Dot → block |
IRIS Prettier: Convert Dot Syntax to Block |
— |
Ctrl+Shift+Alt+B |
| Format + convert |
IRIS Prettier: Format + Convert Dot to Block |
— |
Ctrl+Shift+Alt+F |
Selection notes: range expands to full lines; indent depth is inferred from { / } above the selection.
Output log: open View → Output → IRIS Prettier to see method name, line range, and changed line count ([skip] when unchanged).
Preview: Preview format opens a side-by-side diff; use Apply in the notification to write changes (syntax conversion preview works the same way).
Recommended settings
{
"irisPrettier.enable": true,
"irisPrettier.useTabs": true,
"irisPrettier.tabWidth": 4,
"irisPrettier.printWidth": 120,
"irisPrettier.formatPostfixConditions": true,
"editor.insertSpaces": false,
"editor.tabSize": 4,
"[objectscript-class]": {
"editor.defaultFormatter": "iris-prettier.iris-prettier-vscode",
"editor.formatOnSave": true,
"editor.tabSize": 4,
"editor.insertSpaces": false
},
"[objectscript]": {
"editor.defaultFormatter": "iris-prettier.iris-prettier-vscode",
"editor.formatOnSave": true,
"editor.tabSize": 4,
"editor.insertSpaces": false
}
}
Configuration
| Setting |
Type |
Default |
Description |
irisPrettier.enable |
boolean |
true |
Enable formatting |
irisPrettier.printWidth |
number |
120 |
Reference line width |
irisPrettier.useTabs |
boolean |
true |
Tabs in method bodies |
irisPrettier.tabWidth |
number |
4 |
Spaces per level when useTabs is false |
irisPrettier.formatPostfixConditions |
boolean |
true |
Format postfix q: / s: conditions |
Indentation uses irisPrettier.* settings, not VS Code global editor.tabSize.
Design principles
- Format only — no semantic linting
- Preserve IRIS idioms — e.g.
e i kept in format-only mode; expanded on dot-to-block
- Do not break existing blocks —
If ind="" { ... } left intact
Known limitations
- Very complex nested dot syntax may need manual touch-up
- Commas in conditions are not converted to
&& by default
- Requires ObjectScript language extension for language IDs
Feedback
License
MIT