From cc5c63cb99b67f4596ee7a22e814abd4aac1ebeb Mon Sep 17 00:00:00 2001 From: Filip Tibell Date: Mon, 5 Sep 2022 14:31:33 +0200 Subject: [PATCH] Add search parent dirs config for VSCode extension --- stylua-vscode/CHANGELOG.md | 1 + stylua-vscode/package-lock.json | 4 ++-- stylua-vscode/package.json | 5 +++++ stylua-vscode/src/stylua.ts | 5 +++++ 4 files changed, 13 insertions(+), 2 deletions(-) diff --git a/stylua-vscode/CHANGELOG.md b/stylua-vscode/CHANGELOG.md index 4b9ff9ac..4de79865 100644 --- a/stylua-vscode/CHANGELOG.md +++ b/stylua-vscode/CHANGELOG.md @@ -13,6 +13,7 @@ To view the changelog of the StyLua binary, see [here](https://github.com/Johnny ### Added +- Added `stylua.searchParentDirectories` to configure whether we look for configuration files in parent directories or not. - Added `stylua.disableVersionCheck` to configure whether we call out to GitHub to check for newer versions. Useful if you do not want network requests - Added v0.13 to release version setting diff --git a/stylua-vscode/package-lock.json b/stylua-vscode/package-lock.json index 1166f84c..67aa89a8 100644 --- a/stylua-vscode/package-lock.json +++ b/stylua-vscode/package-lock.json @@ -1,12 +1,12 @@ { "name": "stylua", - "version": "1.2.0", + "version": "1.3.2", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "stylua", - "version": "1.2.0", + "version": "1.3.2", "license": "MPL-2.0", "dependencies": { "ignore": "^5.1.8", diff --git a/stylua-vscode/package.json b/stylua-vscode/package.json index 3f1bcfbb..bf2a44e3 100644 --- a/stylua-vscode/package.json +++ b/stylua-vscode/package.json @@ -85,6 +85,11 @@ "type": "boolean", "default": false, "description": "Disable checking the version of stylua for newer versions. Useful if you do not want network requests" + }, + "stylua.searchParentDirectories": { + "type": "boolean", + "default": false, + "description": "Search parent directories for a stylua configuration file if one is not directly available." } } } diff --git a/stylua-vscode/src/stylua.ts b/stylua-vscode/src/stylua.ts index 8301b5e3..925d9cf5 100644 --- a/stylua-vscode/src/stylua.ts +++ b/stylua-vscode/src/stylua.ts @@ -45,6 +45,11 @@ export function formatCode( args.push("--range-end"); args.push(endPos.toString()); } + if ( + vscode.workspace.getConfiguration("stylua").get("searchParentDirectories") + ) { + args.push("--search-parent-directories"); + } args.push("-"); const child = spawn(`${path}`, args, {