Skip to content

Commit 8c70364

Browse files
Add sandbox setup cmd for VSCodium (#2989)
This implicitly requires `vscode-tree-sitter-query` to be published to the Open VSX Registry to not cause issues when running tests, as rn that plugin is commented out in `packages/common/src/extensionDependencies.ts` due to it not being present there. This PR will therefor need to be a draft until that plugin is uploaded to Open VSX; I'll probably also add to the documentation to note the differences in commands between VSCodium and VSCode at some point soon. There's also probably a cleaner way to do this with a variable passed to `packages/cursorless-vscode/src/scripts/initLaunchSandbox.ts` to swap between vscode and vscodium mode or something, but I'll look into that later as well. --------- Co-authored-by: Andreas Arvidsson <[email protected]>
1 parent dd39fcc commit 8c70364

File tree

4 files changed

+88
-27
lines changed

4 files changed

+88
-27
lines changed

packages/cursorless-org-docs/src/docs/contributing/CONTRIBUTING.md renamed to packages/cursorless-org-docs/src/docs/contributing/CONTRIBUTING.mdx

Lines changed: 55 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1+
import Tabs from "@theme/Tabs";
2+
import TabItem from "@theme/TabItem";
3+
14
# Contributing
25

3-
Welcome! So glad you've decided to help make Cursorless better. You'll want to start by getting [set up](#initial-setup) and learning how to [run / test a local copy of the
4-
extension](#running--testing-extension-locally). You may also find the [VSCode API docs](https://code.visualstudio.com/api) helpful to learn about VSCode extension development.
6+
Welcome! So glad you've decided to help make Cursorless better. You'll want to start by getting [set up](#initial-setup) and learning how to [run / test a local copy of the extension](#running--testing-extension-locally). You may also find the [VSCode API docs](https://code.visualstudio.com/api) helpful to learn about VSCode extension development.
57

68
## Initial setup
79

@@ -10,7 +12,8 @@ extension](#running--testing-extension-locally). You may also find the [VSCode A
1012
- [Git](https://git-scm.com/)
1113
- [Node.js](https://nodejs.org/en/)
1214
- [Corepack](https://nodejs.org/api/corepack.html) or [pnpm](https://pnpm.io/installation)
13-
- [VSCode](https://code.visualstudio.com/); minimum version for local development is 1.72.0 in order to support settings profiles for sandboxed development. Please file an issue if that is a problem.
15+
- [VSCode](https://code.visualstudio.com/) or [VSCodium](https://vscodium.com/)
16+
Both VSCode and VSCodium will be referred to as VSCode except when instructions differ between the editors.
1417

1518
### Steps
1619

@@ -23,25 +26,52 @@ extension](#running--testing-extension-locally). You may also find the [VSCode A
2326
pnpm compile
2427
```
2528

26-
4. Run
29+
4. Run the following in the terminal:
2730

28-
```bash
29-
code --profile=cursorlessDevelopment
30-
```
31+
<Tabs groupId="vsx">
32+
<TabItem value="vscode" label="VSCode" default>
33+
`bash code --profile=cursorlessDevelopment`
34+
</TabItem>
35+
<TabItem value="vscodium" label="VSCodium">
36+
`bash codium --profile=cursorlessDevelopment`
37+
</TabItem>
38+
</Tabs>
3139

3240
and then close the window that opens (eg say `"window close"`). This step is necessary to create the [VSCode settings profile](https://code.visualstudio.com/updates/v1_72#_settings-profiles) that acts as a sandbox containing a specific set of VSCode extensions that will be run alongside Cursorless when you launch Cursorless in debug or test mode. Once https://github.com/microsoft/vscode/issues/172046 is resolved, we will be able to remove this step, as the profile can then automatically be created.
3341

3442
5. Run the following in the terminal:
3543

36-
```bash
37-
pnpm init-vscode-sandbox
38-
```
39-
40-
The `pnpm init-vscode-sandbox` command creates a local [VSCode settings profile](https://code.visualstudio.com/updates/v1_72#_settings-profiles) that acts as a sandbox containing a specific set of VSCode extensions that will be run alongside Cursorless when you launch Cursorless in debug or test mode. This approach is [suggested](https://code.visualstudio.com/updates/v1_72#_extension-debugging-in-a-clean-environment) by the VSCode documentation. If you need to update any of the extension dependencies in the sandbox, you can add `--force` to the command. If you'd like to use additional extensions when debugging locally, you can use the following command:
41-
42-
```bash
43-
code --profile=cursorlessDevelopment --install-extension some.extension
44-
```
44+
<Tabs groupId="vsx">
45+
<TabItem value="vscode" label="VSCode">
46+
```bash pnpm init-vscode-sandbox```
47+
</TabItem>
48+
<TabItem value="vscodium" label="VSCodium">
49+
`bash pnpm init-vscode-sandbox --codium` VSCodium users will also need to
50+
manually download and install the `jrieken:vscode-tree-sitter-query`
51+
extension, as it is [currently not
52+
avalible](https://github.com/jrieken/vscode-tree-sitter-query/issues/28)
53+
on the OpenVSX Marketplace. Instructions on how to manually download the
54+
extension can be found [in this Stack Overflow
55+
post](https://stackoverflow.com/a/79565372)
56+
([archived](https://web.archive.org/web/20250421130639/https://stackoverflow.com/questions/79359919/how-can-i-manually-download-vsix-files-now-that-the-vs-code-marketplace-no-long/79565372#79565372)),
57+
while manual installation instructions can be found directly
58+
below—replace `some.extension` with the acquired `.vsix` file's path
59+
instead of an extension id.
60+
</TabItem>
61+
</Tabs>
62+
63+
Said command adds extensions to the aforementioned settings profile that acts as a sandbox containing a specific set of VSCode extensions that will be run alongside Cursorless when you launch Cursorless in debug or test mode. This approach is [suggested](https://code.visualstudio.com/updates/v1_72#_extension-debugging-in-a-clean-environment) by the VSCode documentation. If you need to update any of the extension dependencies in the sandbox, you can add `--force` to the command. If you'd like to use additional extensions when debugging locally, you can use the following command:
64+
65+
<Tabs groupId="vsx">
66+
<TabItem value="vscode" label="VSCode">
67+
`bash code --profile=cursorlessDevelopment --install-extension
68+
some.extension`
69+
</TabItem>
70+
<TabItem value="vscodium" label="VSCodium">
71+
`bash codium --profile=cursorlessDevelopment --install-extension
72+
some.extension`
73+
</TabItem>
74+
</Tabs>
4575

4676
where `some.extension` is the id of the extension you'd like to install into the sandbox.
4777

@@ -106,9 +136,15 @@ vsce package -o bundle.vsix
106136

107137
Once you have your package then you can install it into the sandbox using the following command:
108138

109-
```
110-
code --profile=cursorlessDevelopment --install-extension bundle.vsix
111-
```
139+
<Tabs groupId="vsx">
140+
<TabItem value="vscode" label="VSCode">
141+
`bash code --profile=cursorlessDevelopment --install-extension bundle.vsix`
142+
</TabItem>
143+
<TabItem value="vscodium" label="VSCodium">
144+
`bash codium --profile=cursorlessDevelopment --install-extension
145+
bundle.vsix`
146+
</TabItem>
147+
</Tabs>
112148

113149
## Installing a local build of the Cursorless extension
114150

packages/cursorless-org-docs/src/docs/contributing/cheatsheet.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ The implementation of the local version of the cheatsheet is split between the T
88

99
When you add a new scope type, action, modifier, etc, you'll need to ensure that it shows up both locally and on the website. It will usually automatically show up in the local cheatsheet. You can verify this by saying `"cursorless cheatsheet"` with your development version of `cursorless-talon` active in your Talon user directory, and inspecting the cheatsheet that appears. If it does not, you'll need to make fixes to [the Talon side of the cheatsheet](../../../../../cursorless-talon/src/cheatsheet).
1010

11-
In either case, to get your changes to appear on the website, you need to update the defaults in [`defaults.json`](../../../../../packages/cheatsheet/src/lib/sampleSpokenFormInfos/defaults.json). First make sure you have the `cursorless-talon-dev` user file set in your Talon home directory, as indicated in the [initial contributor setup instructions](CONTRIBUTING.md#initial-setup). Then you can say `"cursorless update cheatsheet"` to update the default spoken forms. Note that this will use your custom spoken forms, so you may need to do some manual cleanup.
11+
In either case, to get your changes to appear on the website, you need to update the defaults in [`defaults.json`](../../../../../packages/cheatsheet/src/lib/sampleSpokenFormInfos/defaults.json). First make sure you have the `cursorless-talon-dev` user file set in your Talon home directory, as indicated in the [initial contributor setup instructions](CONTRIBUTING.mdx#initial-setup). Then you can say `"cursorless update cheatsheet"` to update the default spoken forms. Note that this will use your custom spoken forms, so you may need to do some manual cleanup.
1212

1313
## Running the cheatsheet in development mode
1414

packages/cursorless-org-docs/src/docs/contributing/cursorless-in-neovim.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Note that Cursorless is maintained as a monorepo, hosted at [`cursorless`](https
88

99
### 1. Follow the initial contributor setup guide
1010

11-
Follow the steps in [CONTRIBUTING.md](./CONTRIBUTING.md#initial-setup).
11+
Follow the steps in [CONTRIBUTING.mdx](./CONTRIBUTING.mdx#initial-setup).
1212

1313
### 2. Get production Cursorless neovim working
1414

@@ -45,7 +45,7 @@ In order to test out your local version of the extension or to run unit tests lo
4545

4646
NOTE: This will spawn a standalone nvim instance that is independent of VSCode. Consequently after you're done debugging, you need to close nvim.
4747

48-
If you don't have the `cursorless-talon-dev` files in your Talon user directory as described in step 6 of [CONTRIBUTING.md](./CONTRIBUTING.md#initial-setup), then you instead need to run the `workbench.action.debug.selectandstart` command in VSCode and then select either "Neovim: Run" or "Neovim: Test".
48+
If you don't have the `cursorless-talon-dev` files in your Talon user directory as described in step 6 of [CONTRIBUTING.mdx](./CONTRIBUTING.mdx#initial-setup), then you instead need to run the `workbench.action.debug.selectandstart` command in VSCode and then select either "Neovim: Run" or "Neovim: Test".
4949

5050
### Running lua tests
5151

packages/cursorless-vscode/src/scripts/initLaunchSandbox.ts

Lines changed: 30 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,23 +6,48 @@
66
import { extensionDependencies } from "@cursorless/common";
77
import * as cp from "child_process";
88

9-
const extraExtensions = ["pokey.command-server"];
9+
const vsCodeToolName: string = "code";
10+
const validCliToolParams: Array<string> = ["--code", "--codium"];
1011

1112
async function main() {
1213
try {
14+
// Read cli tool name from arguments, assume tool name is 'code' if not present
15+
let cliToolName = vsCodeToolName;
16+
17+
process.argv.forEach((argument) => {
18+
if (validCliToolParams.includes(argument)) {
19+
cliToolName = argument.replace("--", "");
20+
console.log("Cli tool name manually set to " + cliToolName);
21+
}
22+
});
23+
24+
const extensions = [...extensionDependencies, "pokey.command-server"];
25+
26+
// Do not attempt to install jrieken:vscode-tree-sitter-query if editor is NOT VSCode, assuming lack of access to VSCode Marketplace
27+
if (cliToolName !== vsCodeToolName) {
28+
extensions.splice(
29+
extensions.findIndex((e) => e === "jrieken.vscode-tree-sitter-query"),
30+
1,
31+
);
32+
console.log(
33+
"Not installing jrieken:vscode-tree-sitter-query as it is not on the OpenVSX Marketplace.",
34+
);
35+
console.log(
36+
"You should install this extension manually. Check the Cursorless contributor documentation for more info.",
37+
);
38+
}
39+
1340
const args = [
1441
"--profile=cursorlessDevelopment",
15-
...[...extensionDependencies, ...extraExtensions].flatMap(
16-
(dependency) => ["--install-extension", dependency],
17-
),
42+
...extensions.flatMap((e) => ["--install-extension", e]),
1843
];
1944

2045
if (process.argv.includes("--force")) {
2146
args.push("--force");
2247
}
2348

2449
// Install extension dependencies
25-
const subprocess = cp.spawn("code", args, {
50+
const subprocess = cp.spawn(cliToolName, args, {
2651
stdio: "inherit",
2752
shell: true,
2853
});

0 commit comments

Comments
 (0)