Skip to content

Commit 942b69a

Browse files
committed
feat: display environment variables contributed by tools in inline decorations
1 parent d1bb37b commit 942b69a

4 files changed

Lines changed: 49 additions & 3 deletions

File tree

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,14 @@ Show tool versions in the editor. (requires reload)
163163

164164
---
165165

166+
##### `mise.showToolEnvVarsDecorations`
167+
- **Type:** `boolean`
168+
- **Default:** `true`
169+
170+
Show environment variables contributed by each tool in the editor inline decorations (e.g. `GOBIN`, `GOROOT` for Go).
171+
172+
---
173+
166174
##### `mise.enableCodeLens`
167175
- **Type:** `boolean`
168176
- **Default:** `true`

package.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,13 @@
284284
"default": true,
285285
"markdownDescription": "Show tool versions in the editor. (requires reload)"
286286
},
287+
"mise.showToolEnvVarsDecorations": {
288+
"order": 9.1,
289+
"type": "boolean",
290+
"title": "Show tool environment variables",
291+
"default": true,
292+
"markdownDescription": "Show environment variables contributed by each tool in the editor inline decorations (e.g. `GOBIN`, `GOROOT` for Go)."
293+
},
287294
"mise.enableCodeLens": {
288295
"order": 10,
289296
"type": "boolean",

src/configuration.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ export const CONFIGURATION_FLAGS = {
1717
enableCodeLens: "enableCodeLens",
1818
enableToolLinks: "enableToolLinks",
1919
showToolVersionsDecorations: "showToolVersionsDecorations",
20+
showToolEnvVarsDecorations: "showToolEnvVarsDecorations",
2021
showOutdatedToolGutterDecorations: "showOutdatedToolGutterDecorations",
2122
checkForNewMiseVersion: "checkForNewMiseVersion",
2223
updateEnvAutomatically: "updateEnvAutomatically",
@@ -130,6 +131,10 @@ export const shouldShowToolVersionsDecorations = () => {
130131
return getConfOrElse(CONFIGURATION_FLAGS.showToolVersionsDecorations, true);
131132
};
132133

134+
export const shouldShowToolEnvVarsDecorations = () => {
135+
return getConfOrElse(CONFIGURATION_FLAGS.showToolEnvVarsDecorations, true);
136+
};
137+
133138
export const shouldShowOutdatedToolGutterDecorations = () => {
134139
return getConfOrElse(
135140
CONFIGURATION_FLAGS.showOutdatedToolGutterDecorations,

src/providers/inlineToolDecorator.ts

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import * as vscode from "vscode";
22
import {
33
isMiseExtensionEnabled,
44
shouldShowOutdatedToolGutterDecorations,
5+
shouldShowToolEnvVarsDecorations,
56
shouldShowToolVersionsDecorations,
67
} from "../configuration";
78
import type { MiseService } from "../miseService";
@@ -31,10 +32,26 @@ export async function showToolVersionInline(
3132
document: vscode.TextDocument,
3233
miseService: MiseService,
3334
): Promise<void> {
34-
const [files, tools] = await Promise.all([
35+
const showEnvVars = shouldShowToolEnvVarsDecorations();
36+
const [files, tools, envsWithInfo] = await Promise.all([
3537
miseService.getCurrentConfigFiles(),
3638
miseService.getCurrentTools({ useCache: false }),
39+
showEnvVars
40+
? miseService.getEnvWithInfo().catch(() => [])
41+
: Promise.resolve([]),
3742
]);
43+
44+
const envVarsByTool = new Map<string, string[]>();
45+
for (const env of envsWithInfo) {
46+
if (env.tool && env.name?.toUpperCase() !== "PATH") {
47+
const existing = envVarsByTool.get(env.tool);
48+
if (existing) {
49+
existing.push(env.name);
50+
} else {
51+
envVarsByTool.set(env.tool, [env.name]);
52+
}
53+
}
54+
}
3855
const currentFile = expandPath(document.uri.fsPath);
3956
if (!files.includes(currentFile)) {
4057
return;
@@ -130,13 +147,22 @@ export async function showToolVersionInline(
130147
}
131148
}
132149

150+
const toolEnvVars = envVarsByTool.get(cleanedToolName);
151+
const envSuffix = toolEnvVars?.length
152+
? ` → ${toolEnvVars.join(", ")}`
153+
: "";
154+
133155
if (isInline) {
134156
if (resolvedInstalled) {
135-
annotations.push(`${cleanedToolName}: ${resolvedVersion}`);
157+
annotations.push(
158+
`${cleanedToolName}: ${resolvedVersion}${envSuffix}`,
159+
);
136160
}
137161
} else {
138162
annotations.push(
139-
resolvedInstalled ? (resolvedVersion ?? "") : "Not installed",
163+
resolvedInstalled
164+
? `${resolvedVersion ?? ""}${envSuffix}`
165+
: "Not installed",
140166
);
141167
}
142168
usedTools.push(cleanedToolName);

0 commit comments

Comments
 (0)