Closed haberdashPI closed 1 month ago
The extension only uses builtin VS Code APIs so it should directly work in the browser.
I haven't tried building it to .vsix
(as I'm not sure how to test these in the browser without publishing them to the marketplace), but I can get it working locally:
Add the following to package.json
:
"main": "./out/extension.js",
+ "browser": "./out/extension.js",
Serve the extension:
$ deno run -A npm:serve -l 5001 --cors`.
Visit vscode.dev
, run Developer: Install Extension from Location...
, and enter http://localhost:5001
.
At this point I can directly run Tree Sitter: Inspect Scopes
to make sure that the extension works (which requires being in a supported file, like a JS file), or better yet I can use it through Dance by adding the following snippet to the user configuration:
"dance.menus": {
"object": {
"items": {
"f": {
"text": "function",
"command": "dance.seek.object",
"args": [{
"input": "(?#textobject=function)"
}],
}
}
}
}
Then pressing a-i f
in a function.
The instructions above also work when replacing vscode.dev
with the test app served with
$ deno run -A npm:@vscode/test-web --extensionDevelopmentPath=.
Note that you may need to reload the window after installing the extension in case Dance doesn't pick up on it being available, or if it somehow doesn't load.
Mmm... okay. Thanks for the tips. I'll keep puttering away at this.
Having eliminated the differences in extension type, there were some other issues I eventually found with my setup, so it's possible that now that I have those resolved this problem will be easier to fix. (But I think I'll first get what I have working without the web vs. desktop issues).
I'll close for now, and if I find a more specific/precise issue and/or MWE I'll post again.
Having played around with this for a little bit, something I've noticed in trying to get this to play nicely with one of my extensions is it appears to be pretty non-trivial to convert this to a web extension (and as best I can tell, if I want to get the API object from another web extension, this extension would have to also be a web extension).
Since you set up the build process here, I thought it might be possible you know how one might go about doing that. The obvious things I tried seemed to fail: happy to give more details about what I tried if you think it'd be helpful.
A longer-term problem here seems to be that depending on where an extension resides (e.g. vscode local or remote machine), and whether it is a web or desktop extension, impacts what other extensions it can access when calling
getExtension
. Seems like there would need to be e.g. anvscode-tree-sitter-api-desktop
andvscode-tree-sitter-api-web
extension.