Skip to content

Commit 4bc3544

Browse files
committed
feat: Add mise.configureExtensionsAutomaticallyIncludeList setting
1 parent e36bc05 commit 4bc3544

File tree

8 files changed

+140
-8
lines changed

8 files changed

+140
-8
lines changed

README.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,10 @@ to use tools provided by `mise` in your current project.
3333
- [Open VSX Registry](https://open-vsx.org/extension/hverlin/mise-vscode)
3434

3535
> [!NOTE]
36-
> The extension includes default settings that you might want to change. See the [configuration guide](https://hverlin.github.io/mise-vscode/tutorials/settinguptheextension/) to customize your setup.
36+
> The extension includes default settings that you might want to change. See the [configuration guide](https://hverlin.github.io/mise-vscode/tutorials/settinguptheextension/) to customize your set-up.
37+
> For example, you can choose to disable automatic configuration of other extensions or change the path to the `mise` binary.
38+
>
39+
> You can access the settings by clicking on the mise extension indicator in the status bar.
3740
3841
## ✨ Features
3942

@@ -62,7 +65,7 @@ The mise-vscode extension integrates mise's core functionality into VS Code, hel
6265
- 📱 Show tools which are not installed or active
6366
- 📦 Install/Remove/Use tools directly from the sidebar
6467
- 🔧 Configure your other VSCode extensions to use tools provided by `mise`
65-
([list of supported extensions](https://hverlin.github.io/mise-vscode/reference/supported-extensions/))
68+
([list of supported extensions](https://hverlin.github.io/mise-vscode/reference/supported-extensions/)). See the [set-up guide](https://hverlin.github.io/mise-vscode/tutorials/settinguptheextension/) for more information.
6669

6770
<video src="https://github.com/user-attachments/assets/c2ad5e60-f011-46a4-8e1b-1da4264f0d09"></video>
6871

docs/src/content/docs/tutorials/Getting-Started.mdx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,5 @@ The extension should now be activated. You can access the features using:
2525
![]( ../../../../../screenshots/mise-vscode-screenshot.png)
2626

2727

28-
Everything should work if your `mise` setup is standard. Read the next section on [how to customize the extension to your needs](/mise-vscode/tutorials/settinguptheextension/).
28+
Everything should work out of the box if your `mise` setup is standard.
29+
Read the next section on [how to customize the extension to your needs](/mise-vscode/tutorials/settinguptheextension/).

docs/src/content/docs/tutorials/SettingUpTheExtension.mdx

Lines changed: 59 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,68 @@ However, there are some challenges with sharing `.vscode/settings.json`:
3535

3636
Ideally, VS Code should support a `settings.local.json` file that would be ignored by git. See [this issue](https://github.com/microsoft/vscode/issues/40233) for more information.
3737

38-
If you want to share some settings with others, a good workaround is to create a `settings.shared.json` file that other can use as a reference. You can also create a `mise` task to populate the `settings.json` file with the content of `settings.shared.json` if needed.
38+
If you want to share some settings with others, here are some good workarounds:
39+
- Git ignore the `.vscode/settings.json` file. Create a `settings.shared.json` file that other can use as a reference. Set up a `mise` task to populate your `settings.json` file with the content of `settings.shared.json` if needed.
40+
- Use extension such as [workspace-config-plus](https://github.com/swellaby/vscode-workspace-config-plus) to have a `settings.local.json` file that is ignored by git.
3941

4042
</details>
4143

44+
#### Controlling which extensions are configured automatically
45+
46+
You can control which supported extensions are automatically configured by mise-vscode using the following settings in your VS Code settings (user or workspace):
47+
48+
- [`mise.configureExtensionsAutomaticallyIgnoreList`](/mise-vscode/reference/settings/#miseconfigureextensionsautomaticallyignorelist): List of extensions that should **not** be configured automatically.
49+
- [`mise.configureExtensionsAutomaticallyIncludeList`](/mise-vscode/reference/settings/#miseconfigureextensionsautomaticallyincludelist): List of extensions that **should** be configured automatically.
50+
51+
**How it works:**
52+
- If the **include** list is set and non-empty, only extensions in this list are considered for automatic configuration.
53+
- If both **include** and **ignore** lists are set, the ignore list takes precedence (extensions in the ignore list are always excluded).
54+
- If the **include** list contains `"all"`, all supported extensions are considered (except those in the ignore list).
55+
- If the **include** list is empty or not set, no extensions are configured automatically, and the extension will not modify your `.vscode/settings.json` file.
56+
- If [`mise.configureExtensionsAutomatically`](/mise-vscode/reference/settings/#miseconfigureextensionsautomatically) is set to `false`, no extensions will be configured automatically, regardless of the include or ignore lists.
57+
58+
You can find the full list of supported extensions in the [Supported Extensions](/mise-vscode/reference/supported-extensions/) documentation.
59+
60+
Example usage in your `settings.json`:
61+
62+
```json
63+
{
64+
"mise.configureExtensionsAutomaticallyIncludeList": ["ms-python.python", "golang.go"],
65+
"mise.configureExtensionsAutomaticallyIgnoreList": ["denoland.vscode-deno"]
66+
}
67+
```
68+
69+
This will configure only Python and Go extensions, and will always ignore Deno, even if it is in the include list.
70+
71+
#### Advanced: Fine-grained control with user and workspace settings
72+
73+
You can take advantage of VS Code's user and workspace settings to control which extensions are configured automatically at different levels.
74+
For example, you can set a global default at the **user** level and then override it at the **workspace** level for specific projects.
75+
76+
This allows you to have a flexible setup where you can control which extensions are configured automatically based on your needs.
77+
78+
To do this, set the `mise.configureExtensionsAutomaticallyIncludeList` to an empty array at the **user** level, and then specify the desired extensions at the **workspace** level in your `.vscode/settings.json` file.
79+
80+
**User settings (`settings.json`):**
81+
```json
82+
{
83+
"mise.configureExtensionsAutomaticallyIncludeList": []
84+
}
85+
```
86+
87+
**Workspace settings (`.vscode/settings.json`):**
88+
```json
89+
{
90+
"mise.configureExtensionsAutomaticallyIncludeList": [
91+
"denoland.vscode-deno"
92+
]
93+
}
94+
```
95+
96+
With this setup, only the deno extensions will be configured automatically for your project. However, if you open another project that does not specify the `mise.configureExtensionsAutomaticallyIncludeList`, no extensions will be configured automatically.
97+
98+
**Note that updating this setting might require you to reload the VS Code window for the changes to take effect.**
99+
42100
### Automatic loading of environment variables
43101

44102
The extension will load the environment variables provided by `mise` and update the VS Code process with them.

package.json

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,37 @@
158158
},
159159
"markdownDescription": "List of extensions that should not be configured automatically."
160160
},
161+
"mise.configureExtensionsAutomaticallyIncludeList": {
162+
"order": 5.1,
163+
"type": "array",
164+
"default": ["all"],
165+
"items": {
166+
"type": "string",
167+
"enum": [
168+
"all",
169+
"ms-python.python",
170+
"denoland.vscode-deno",
171+
"charliermarsh.ruff",
172+
"golang.go",
173+
"oven.bun-vscode",
174+
"oracle.oracle-java",
175+
"redhat.java",
176+
"vscjava.vscode-gradle",
177+
"salesforce.salesforcedx-vscode-apex",
178+
"timonwong.shellcheck",
179+
"ms-vscode.js-debug",
180+
"vscode.php-language-features",
181+
"xdebug.php-debug",
182+
"julialang.language-julia",
183+
"pgourlain.erlang",
184+
"Dart-Code.dart-code",
185+
"dart-code.flutter",
186+
"ziglang.vscode-zig",
187+
"signageos.signageos-vscode-sops"
188+
]
189+
},
190+
"markdownDescription": "List of extensions that should be configured automatically. If both include and ignore lists are set, the ignore list takes precedence. If the include list includes 'all' (default), all supported extensions are considered except those in the ignore list."
191+
},
161192
"mise.configureExtensionsUseShims": {
162193
"order": 6,
163194
"type": "boolean",

src/configuration.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ export const CONFIGURATION_FLAGS = {
1212
configureExtensionsUseSymLinks: "configureExtensionsUseSymLinks",
1313
configureExtensionsAutomaticallyIgnoreList:
1414
"configureExtensionsAutomaticallyIgnoreList",
15+
configureExtensionsAutomaticallyIncludeList:
16+
"configureExtensionsAutomaticallyIncludeList",
1517
enableCodeLens: "enableCodeLens",
1618
showToolVersionsDecorations: "showToolVersionsDecorations",
1719
showOutdatedToolGutterDecorations: "showOutdatedToolGutterDecorations",
@@ -43,6 +45,13 @@ export const getIgnoreList = (): string[] => {
4345
);
4446
};
4547

48+
export const getIncludeList = (): string[] => {
49+
return getConfOrElse(
50+
CONFIGURATION_FLAGS.configureExtensionsAutomaticallyIncludeList,
51+
[],
52+
);
53+
};
54+
4655
export const shouldConfigureExtensionsAutomatically = (): boolean => {
4756
return getConfOrElse(
4857
CONFIGURATION_FLAGS.configureExtensionsAutomatically,

src/miseService.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -805,7 +805,7 @@ export class MiseService {
805805
"self_update_available value from mise dr:",
806806
miseConfig.self_update_available,
807807
);
808-
return !miseConfig.self_update_available;
808+
return miseConfig.self_update_available;
809809
}
810810

811811
const isSelfUpdateDisabled = await this.isSelfUpdateDisabled();

src/package-json.test.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,19 @@ describe("package.json configuration tests", () => {
1717

1818
expect(ignoreListOptions).toEqual(supportedExtensionNames);
1919
});
20+
21+
test("include list should be correct", () => {
22+
const supportedExtensionNames = [
23+
...new Set(
24+
SUPPORTED_EXTENSIONS.map((extension) => extension.extensionId),
25+
),
26+
];
27+
28+
const includeListOptions =
29+
packageJson.contributes.configuration.properties[
30+
"mise.configureExtensionsAutomaticallyIncludeList"
31+
].items.enum;
32+
33+
expect(includeListOptions).toEqual(["all"].concat(supportedExtensionNames));
34+
});
2035
});

src/providers/toolsProvider.ts

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import {
1616
} from "../commands";
1717
import {
1818
getIgnoreList,
19+
getIncludeList,
1920
isMiseExtensionEnabled,
2021
shouldUseShims,
2122
shouldUseSymLinks,
@@ -617,7 +618,10 @@ export function registerToolsCommands(
617618
),
618619
vscode.commands.registerCommand(MISE_CONFIGURE_ALL_SKD_PATHS, async () => {
619620
await miseService.miseReshim();
621+
620622
const ignoreList = getIgnoreList();
623+
const includeList = getIncludeList();
624+
621625
const tools = await miseService.getCurrentTools();
622626
const configurableTools = tools.filter((tool) => {
623627
const configurableExtensions = CONFIGURABLE_EXTENSIONS_BY_TOOL_NAME.get(
@@ -628,9 +632,20 @@ export function registerToolsCommands(
628632
}
629633

630634
return configurableExtensions.some((configurableExtension) => {
631-
return ignoreList.includes(configurableExtension.extensionId)
632-
? false
633-
: vscode.extensions.getExtension(configurableExtension.extensionId);
635+
if (ignoreList.includes(configurableExtension.extensionId)) {
636+
return false;
637+
}
638+
639+
if (
640+
!includeList.includes(configurableExtension.extensionId) &&
641+
!includeList.includes("all")
642+
) {
643+
return false;
644+
}
645+
646+
return vscode.extensions.getExtension(
647+
configurableExtension.extensionId,
648+
);
634649
});
635650
});
636651

0 commit comments

Comments
 (0)