Skip to content

Commit 0907b5e

Browse files
authored
feat: add "useArray" option to customBinaryExtensions (#214)
* feat: add asArray functionality * change example to ty
1 parent 50a04d0 commit 0907b5e

5 files changed

Lines changed: 31 additions & 3 deletions

File tree

docs/src/content/docs/guides/custom-extensions.mdx

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ You can configure any VS Code extension to use mise tools via settings:
1010
- **`mise.customBinaryExtensions`**: Configure extensions that need a binary path
1111
- **`mise.customFolderExtensions`**: Configure extensions that need a folder path (e.g., JDK home)
1212

13-
Example for binary mode:
13+
Example for binary mode (string value):
1414

1515
```json
1616
{
@@ -24,6 +24,20 @@ Example for binary mode:
2424
}
2525
```
2626

27+
Some extensions expect an array of paths instead of a single string. Use `vscodeSetting.asArray`:
28+
29+
```json
30+
{
31+
"mise.customBinaryExtensions": [
32+
{
33+
"extensionId": "astral-sh.ty",
34+
"toolSources": ["ty"],
35+
"vscodeSetting": { "key": "ty.path", "asArray": true }
36+
}
37+
]
38+
}
39+
```
40+
2741
Example for folder mode:
2842

2943
```json

docs/src/content/docs/reference/Settings.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,7 @@ Each entry requires:
295295
Optional:
296296
- `binName`: Binary name (defaults to first tool name)
297297
- `vscodeSetting.subdirs`: Subdirectories to append to the path
298+
- `vscodeSetting.asArray`: Whether to wrap the setting value in an array (default: false)
298299
- `supportsShims`: Whether extension supports shims (default: true)
299300
- `supportsSymlinks`: Whether extension supports symlinks (default: true)
300301

package.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,7 @@
391391
"order": 19,
392392
"type": "array",
393393
"default": [],
394-
"markdownDescription": "Custom binary extensions to automatically configure VSCode extensions with mise tool binaries.\n\nEach entry requires:\n- `extensionId`: VSCode extension ID\n- `toolSources`: Array of mise tool registry sources to match\n- `vscodeSetting.key`: VSCode setting key to write\n\nOptional:\n- `binName`: Binary name (defaults to first tool name)\n- `vscodeSetting.subdirs`: Subdirectories to append to the path\n- `supportsShims`: Whether extension supports shims (default: true)\n- `supportsSymlinks`: Whether extension supports symlinks (default: true)",
394+
"markdownDescription": "Custom binary extensions to automatically configure VSCode extensions with mise tool binaries.\n\nEach entry requires:\n- `extensionId`: VSCode extension ID\n- `toolSources`: Array of mise tool registry sources to match\n- `vscodeSetting.key`: VSCode setting key to write\n\nOptional:\n- `binName`: Binary name (defaults to first tool name)\n- `vscodeSetting.subdirs`: Subdirectories to append to the path\n- `vscodeSetting.asArray`: Whether to wrap the setting value in an array (default: false)\n- `supportsShims`: Whether extension supports shims (default: true)\n- `supportsSymlinks`: Whether extension supports symlinks (default: true)",
395395
"items": {
396396
"type": "object",
397397
"required": [
@@ -427,6 +427,11 @@
427427
"type": "string"
428428
},
429429
"description": "Subdirectories to append to the tool path (e.g., ['bin'] to point to bin folder)"
430+
},
431+
"asArray": {
432+
"type": "boolean",
433+
"default": false,
434+
"description": "Whether to wrap the setting value in an array (e.g., ['/path/to/bin'] instead of '/path/to/bin')"
430435
}
431436
}
432437
},

src/configuration.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,7 @@ export const isTaskSymbolProviderEnabled = () => {
209209
type VSCodeSettingSubdirs = {
210210
key: string;
211211
subdirs?: string[];
212+
asArray?: boolean;
212213
};
213214

214215
type CustomBinaryExtensionConfig = {

src/utils/supportedExtensions.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -616,7 +616,7 @@ function appendSubdirs(basePath: string, subdirs?: string[]): string {
616616
export function createCustomBinaryExtensionConfig(customConfig: {
617617
extensionId: string;
618618
toolSources: string[];
619-
vscodeSetting: { key: string; subdirs?: string[] };
619+
vscodeSetting: { key: string; subdirs?: string[]; asArray?: boolean };
620620
binName?: string;
621621
supportsShims?: boolean;
622622
supportsSymlinks?: boolean;
@@ -659,6 +659,13 @@ export function createCustomBinaryExtensionConfig(customConfig: {
659659
}
660660
}
661661

662+
if (customConfig.vscodeSetting.asArray) {
663+
const value = result[customConfig.vscodeSetting.key];
664+
if (typeof value === "string") {
665+
result[customConfig.vscodeSetting.key] = [value];
666+
}
667+
}
668+
662669
return result;
663670
},
664671
};

0 commit comments

Comments
 (0)