Skip to content

Commit

Permalink
extension: add stylua.verify
Browse files Browse the repository at this point in the history
  • Loading branch information
JohnnyMorganz committed Dec 30, 2023
1 parent af93051 commit e433127
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions stylua-vscode/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ To view the changelog of the StyLua binary, see [here](https://github.com/Johnny
### Added

- Added configuration option `stylua.configPath` to provide a direct path to a `stylua.toml` file. Note: this will override any workspace config lookup
- Added configuration option `stylua.verify` to pass `--verify` to StyLua CLI when formatting a file. This enforces output verification

### Changed

Expand Down
5 changes: 5 additions & 0 deletions stylua-vscode/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,11 @@
"type": "boolean",
"default": false,
"description": "Search parent directories for a stylua configuration file if one is not directly available."
},
"stylua.verify": {
"type": "boolean",
"default": false,
"description": "Pass the `--verify` flag to StyLua to enforce output verification"
}
}
}
Expand Down
4 changes: 4 additions & 0 deletions stylua-vscode/src/stylua.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@ export function formatCode(
) {
args.push("--search-parent-directories");
}
if (vscode.workspace.getConfiguration("stylua").get("verify")) {
args.push("--verify");
}

args.push("-");

const child = spawn(`${path}`, args, {
Expand Down

0 comments on commit e433127

Please sign in to comment.