Skip to content

Commit 5ad341b

Browse files
authored
Add support for Bazel plugin (#179)
* Add support for Bazel and Buildifier tools * Added symlink support, added doc table * Fix unnecessary & incompatible pathing * Windows support & tidy * Fix lint issues * Fix docs
1 parent aa49445 commit 5ad341b

4 files changed

Lines changed: 71 additions & 3 deletions

File tree

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ List of extensions that should not be configured automatically.
8888
- `joselitofilho.ginkgotestexplorer`
8989
- `bufbuild.vscode-buf`
9090
- `biomejs.biome`
91+
- `bazelbuild.vscode-bazel`
9192

9293
---
9394

@@ -122,6 +123,7 @@ List of extensions that should be configured automatically. If both include and
122123
- `joselitofilho.ginkgotestexplorer`
123124
- `bufbuild.vscode-buf`
124125
- `biomejs.biome`
126+
- `bazelbuild.vscode-bazel`
125127

126128
---
127129

docs/src/content/docs/reference/Supported-extensions.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ List of extensions that can be automatically configured to use tools from
1717
`.vscode` directory with a symlink to the tools installed by `mise`.
1818

1919
| Extension | Settings | Comment |
20-
|--------------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------|
20+
| ------------------------------------------------------------------------------------------------------------ | -------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------- |
2121
| [Python](https://marketplace.visualstudio.com/items?itemName=ms-python.python) | `python.defaultInterpreterPath` | You will still need to select the interpreter. See [this discussion](https://github.com/hverlin/mise-vscode/discussions/71) |
2222
| [Go](https://marketplace.visualstudio.com/items?itemName=golang.Go) | `go.goroot`, `go.alternateTools` | |
2323
| [Java](https://marketplace.visualstudio.com/items?itemName=oracle.oracle-java) | `jdk.jdkhome` | |
@@ -36,6 +36,7 @@ List of extensions that can be automatically configured to use tools from
3636
| [ginkgo test explorer](https://marketplace.visualstudio.com/items?itemName=joselitofilho.ginkgotestexplorer) | `ginkgotestexplorer.ginkgoPath` | |
3737
| [buf](https://marketplace.visualstudio.com/items?itemName=bufbuild.vscode-buf) | `buf.commandLine.path` | |
3838
| [biome](https://marketplace.visualstudio.com/items?itemName=biomejs.biome-vscode) | `biome.lsp.bin` | Not enabled by default. Update `"mise.configureExtensionsAutomaticallyIgnoreList"` to `[]` to enable it. Use it only if you don't install biome with npm. |
39+
| [bazel](https://marketplace.visualstudio.com/items?itemName=BazelBuild.vscode-bazel) | `bazel.executable`, `bazel.buildifierExecutable` | Does not work with shims |
3940

4041
Extensions which have built-in support for `mise`:
4142

package.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,8 @@
213213
"signageos.signageos-vscode-sops",
214214
"joselitofilho.ginkgotestexplorer",
215215
"bufbuild.vscode-buf",
216-
"biomejs.biome"
216+
"biomejs.biome",
217+
"bazelbuild.vscode-bazel"
217218
]
218219
},
219220
"markdownDescription": "List of extensions that should not be configured automatically."
@@ -249,7 +250,8 @@
249250
"signageos.signageos-vscode-sops",
250251
"joselitofilho.ginkgotestexplorer",
251252
"bufbuild.vscode-buf",
252-
"biomejs.biome"
253+
"biomejs.biome",
254+
"bazelbuild.vscode-bazel"
253255
]
254256
},
255257
"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."

src/utils/supportedExtensions.ts

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,24 @@ const generateJavaConfiguration =
4141
};
4242
};
4343

44+
function removeUnsupportedWorkspace(target: string) {
45+
// Some plugins fail to resolve ${workspaceFolder}/
46+
const prefixVariants = [
47+
// biome-ignore lint/suspicious/noTemplateCurlyInString: expected
48+
"${workspaceFolder}/",
49+
// biome-ignore lint/suspicious/noTemplateCurlyInString: expected
50+
"${workspaceFolder}\\",
51+
];
52+
53+
for (const prefix of prefixVariants) {
54+
if (target.startsWith(prefix)) {
55+
return target.slice(prefix.length);
56+
}
57+
}
58+
59+
return target;
60+
}
61+
4462
export const SUPPORTED_EXTENSIONS: Array<ConfigurableExtension> = [
4563
{
4664
extensionId: "ms-python.python",
@@ -451,6 +469,51 @@ export const SUPPORTED_EXTENSIONS: Array<ConfigurableExtension> = [
451469
});
452470
},
453471
},
472+
{
473+
toolNames: [
474+
"bazelisk",
475+
"aqua:bazelbuild/bazelisk",
476+
"npm:@bazel/bazelisk",
477+
"asdf:josephtate/asdf-bazelisk",
478+
],
479+
extensionId: "bazelbuild.vscode-bazel",
480+
generateConfiguration: async ({
481+
miseService,
482+
tool,
483+
miseConfig,
484+
useSymLinks,
485+
}) => {
486+
return configureSimpleExtension(miseService, {
487+
configKey: "bazel.executable",
488+
binName: "bazelisk",
489+
useShims: false,
490+
useSymLinks,
491+
tool,
492+
miseConfig,
493+
valueTransformer: removeUnsupportedWorkspace,
494+
});
495+
},
496+
},
497+
{
498+
toolNames: ["buildifier", "aqua:bazelbuild/buildtools/buildifier"],
499+
extensionId: "bazelbuild.vscode-bazel",
500+
generateConfiguration: async ({
501+
miseService,
502+
tool,
503+
miseConfig,
504+
useSymLinks,
505+
}) => {
506+
return configureSimpleExtension(miseService, {
507+
configKey: "bazel.buildifierExecutable",
508+
binName: "buildifier",
509+
useShims: false,
510+
useSymLinks,
511+
tool,
512+
miseConfig,
513+
valueTransformer: removeUnsupportedWorkspace,
514+
});
515+
},
516+
},
454517
];
455518

456519
export const CONFIGURABLE_EXTENSIONS_BY_TOOL_NAME = new Map<

0 commit comments

Comments
 (0)