Skip to content

Commit

Permalink
extension: add stylua.configPath (#842)
Browse files Browse the repository at this point in the history
Add `stylua.configPath`
  • Loading branch information
JohnnyMorganz authored Dec 30, 2023
1 parent c3a9d97 commit 76e6119
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
4 changes: 4 additions & 0 deletions stylua-vscode/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ To view the changelog of the StyLua binary, see [here](https://github.com/Johnny

## [Unreleased]

### Added

- Added configuration option `stylua.configPath` to provide a direct path to a `stylua.toml` file. Note: this will override any workspace config lookup

### Changed

- Removed excessive error notifications on formatting failure and replaced with VSCode language status bar item
Expand Down
5 changes: 5 additions & 0 deletions stylua-vscode/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,11 @@
"default": false,
"description": "Disable checking the version of stylua for newer versions. Useful if you do not want network requests."
},
"stylua.configPath": {
"type": "string",
"default": "",
"description": "Path to a `stylua.toml` configuration file. NOTE: this will override workspace configuration lookup"
},
"stylua.searchParentDirectories": {
"type": "boolean",
"default": false,
Expand Down
9 changes: 9 additions & 0 deletions stylua-vscode/src/stylua.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,15 @@ export function formatCode(
args.push("--range-end");
args.push(endPos.toString());
}

const configPath = vscode.workspace
.getConfiguration("stylua")
.get<string>("configPath");
if (configPath && configPath.trim() !== "") {
args.push("--config-path");
args.push(configPath);
}

if (
vscode.workspace.getConfiguration("stylua").get("searchParentDirectories")
) {
Expand Down

0 comments on commit 76e6119

Please sign in to comment.