Skip to content

Commit 83609ed

Browse files
authored
feat: add configureExtensionsIncludeGlobalTools setting (#187)
* add include global autoconfig setting * Default to true for compatibility * Update docs & walkthrough
1 parent 486d353 commit 83609ed

7 files changed

Lines changed: 50 additions & 6 deletions

File tree

README.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,15 @@ The extension will notify you if neither is installed.
4545
> [!NOTE]
4646
> 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.
4747
> For example, you can choose to enable/disable automatic configuration of other extensions or change the path to the `mise` binary.
48-
>
48+
>
4949
> You can access the settings by clicking on the mise extension indicator in the status bar.
5050
51+
### Recommended: Disable Global Tools in Auto-Configuration
52+
53+
By default, the extension includes tools from your global mise configuration (`~/.config/mise/config.toml`) when auto-configuring other VS Code extensions. This can pollute your project settings with extensions for tools not in your current project.
54+
55+
**Recommended setting:** Set `mise.configureExtensionsIncludeGlobalTools` to `false` to only use tools from your local `mise.toml` file. This keeps your `.vscode/settings.json` clean and ensures extensions are only configured for tools actually used in your project.
56+
5157
## ✨ Features
5258

5359
The mise-vscode extension integrates mise's core functionality into VS Code, helping you manage your development environment directly from the editor. You can handle task running, tool versions, and environment variables through a simple interface. Here's what's available:

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,16 @@ This is useful if you share the `.vscode/settings.json` file with others. When t
147147

148148
---
149149

150+
##### `mise.configureExtensionsIncludeGlobalTools`
151+
- **Type:** `boolean`
152+
- **Default:** `true`
153+
154+
When enabled, tools from the global mise configuration (`~/.config/mise/config.toml`) will be included when automatically configuring VS Code extensions.
155+
156+
When disabled (recommended), only tools from the local project configuration (`mise.toml`) are used. This prevents settings.json from being polluted with extensions for tools that are not part of the current project.
157+
158+
---
159+
150160
##### `mise.checkForNewMiseVersion`
151161
- **Type:** `boolean`
152162
- **Default:** `true`

package.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,13 @@
270270
"default": false,
271271
"markdownDescription": "Create symlinks in your `.vscode` folder that links to the `mise` bin.\n\nThis is useful if you share the `.vscode/settings.json` file with others. When the project is version controlled:\n- every user must have the extension installed\n- the directory `.vscode/mise-tools` must be excluded from version control."
272272
},
273+
"mise.configureExtensionsIncludeGlobalTools": {
274+
"order": 7.1,
275+
"type": "boolean",
276+
"title": "Include global mise tools when auto-configuring extensions",
277+
"default": true,
278+
"markdownDescription": "When enabled, tools from the global mise configuration (`~/.config/mise/config.toml`) will be included when automatically configuring VS Code extensions.\n\nWhen disabled (recommended), only tools from the local project configuration (`mise.toml`) are used. This prevents settings.json from being polluted with extensions for tools that are not part of the current project."
279+
},
273280
"mise.checkForNewMiseVersion": {
274281
"order": 8,
275282
"type": "boolean",

src/configuration.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ export const CONFIGURATION_FLAGS = {
1010
configureExtensionsAutomatically: "configureExtensionsAutomatically",
1111
configureExtensionsUseShims: "configureExtensionsUseShims",
1212
configureExtensionsUseSymLinks: "configureExtensionsUseSymLinks",
13+
configureExtensionsIncludeGlobalTools:
14+
"configureExtensionsIncludeGlobalTools",
1315
configureExtensionsAutomaticallyIgnoreList:
1416
"configureExtensionsAutomaticallyIgnoreList",
1517
configureExtensionsAutomaticallyIncludeList:
@@ -84,6 +86,13 @@ export const shouldUseSymLinks = () => {
8486
);
8587
};
8688

89+
export const shouldIncludeGlobalTools = (): boolean => {
90+
return getConfOrElse(
91+
CONFIGURATION_FLAGS.configureExtensionsIncludeGlobalTools,
92+
true,
93+
);
94+
};
95+
8796
export const isMiseExtensionEnabled = (): boolean => {
8897
return getConfOrElse(CONFIGURATION_FLAGS.enable, true);
8998
};

src/miseService.ts

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -412,17 +412,23 @@ export class MiseService {
412412
}
413413
}
414414

415-
async getCurrentTools(
416-
{ useCache }: { useCache?: boolean } = { useCache: true },
417-
): Promise<Array<MiseTool>> {
415+
async getCurrentTools({
416+
useCache = true,
417+
local = false,
418+
}: {
419+
useCache?: boolean;
420+
local?: boolean;
421+
} = {}): Promise<Array<MiseTool>> {
418422
if (!this.getMiseBinaryPath()) {
419423
return [];
420424
}
421425

422426
try {
423427
const cacheInstance = useCache ? this.cache : this.dedupeCache;
424428
const { stdout } = await cacheInstance.execCmd({
425-
command: "ls --current --offline --json",
429+
command: local
430+
? "ls --local --offline --json"
431+
: "ls --current --offline --json",
426432
});
427433

428434
return Object.entries(JSON.parse(stdout)).flatMap(([toolName, tools]) => {

src/providers/toolsProvider.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import {
1818
getIgnoreList,
1919
getIncludeList,
2020
isMiseExtensionEnabled,
21+
shouldIncludeGlobalTools,
2122
shouldUseShims,
2223
shouldUseSymLinks,
2324
} from "../configuration";
@@ -636,7 +637,9 @@ export function registerToolsCommands(
636637
}
637638
}
638639

639-
const tools = await miseService.getCurrentTools();
640+
const tools = shouldIncludeGlobalTools()
641+
? await miseService.getCurrentTools()
642+
: await miseService.getCurrentTools({ local: true });
640643
const configurableTools = tools.filter((tool) => {
641644
const configurableExtensions = extByToolName.get(tool.name);
642645
if (!configurableExtensions?.length) {

walkthrough/auto-configure.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ One of the main features of this extension is the ability to **automatically con
1212
When enabled, the extension will automatically update your `.vscode/settings.json` file to configure supported VSCode extensions.
1313
See [the list of supported extensions](https://github.com/hverlin/mise-vscode/wiki/Supported-extensions).
1414

15+
> [!IMPORTANT]
16+
> **Recommended:** Set `mise.configureExtensionsIncludeGlobalTools` to `false` to only use tools from your local `mise.toml` file. This prevents your project settings from being polluted with extensions for tools not in your current project.
17+
1518
To enable this feature, simply click this button:
1619
**[Enable Auto-Configuration](command:mise.enableAutoConfiguration)**
1720

0 commit comments

Comments
 (0)