Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable vetur to work with VS Code on the Web #3248

Open
isidorn opened this issue Nov 25, 2021 · 14 comments
Open

Enable vetur to work with VS Code on the Web #3248

isidorn opened this issue Nov 25, 2021 · 14 comments

Comments

@isidorn
Copy link

isidorn commented Nov 25, 2021

👋 I'm Isidor, a PM from the VS Code team, and we recently announced VS Code for the Web at https://vscode.dev/, which provides a free, zero-install Microsoft Visual Studio Code experience running entirely in your browser. You can learn more here.

We'd like to ensure vetur can run in the web, and we have a guide for enabling extensions for the web here. As a couple of highlights:

  • In VS Code for the Web, both the UI and extension host run inside the browser.
  • A web extension is structured like a regular extension, but with a different main file: it's defined by the browser property
  • Access to workspace files needs to go through the VS Code file system API accessible at vscode.workspace.fs
  • There are currently three ways to test a web extension

I checked your extension and I see there are quite some node dependencies, so this transition to web might not be trivial. However it would be cool if you could at least contribute grammars for web, and using when clauses disable all other contributions which can not work on the web.

We are also open to helping here. Let us know what you think. Thanks!

@aeschli @octref

@bamurtaugh
Copy link

Hi @octref! I was wondering if you might have any thoughts on this? We're happy to discuss if you have any questions or feedback. Thanks!

@johnsoncodehk
Copy link
Member

Sorry to bother, I was hoping for some guidance, this question should be generic.

Typescript's language service API with language service host is synchronous, so it is not possible to request vscode.workspace.fs from a language client asynchronously.
How does the typescript extension solve this problem to support the Web IDE?
Or TS language service can't solve it, but it be solved by tsserver?

Thanks in advance. 🙏

@isidorn
Copy link
Author

isidorn commented Apr 20, 2022

@johnsoncodehk good question. I do not know.
@jrieken or @mjbvz would know better here.

@jrieken
Copy link

jrieken commented Apr 20, 2022

How does the typescript extension solve this problem to support the Web IDE?

This is being worked on. Today, the TypeScript web extension is more or less single file, e.g it doesn't support cross file features like find references. You correctly pointed out that tsserver is all sync and unfortunately that won't change. The current plan is to add logic to tsserver to add a virtual, synchronous file system which is updated and initialized by async messages. This is the corresponding issue: microsoft/TypeScript#47600.

@johnsoncodehk
Copy link
Member

@jrieken If I understand correctly, I need to migrate from TS language service API to tsserver after tsserver supports virtual file system, or I have to implement virtual file system for TS language service host in LSP langauge server, and sync by language client's vscode.workspace.fs.

Your comment is very helpful, thank you. 🙏

@jrieken
Copy link

jrieken commented Apr 25, 2022

@jrieken If I understand correctly, I need to migrate from TS language service API to tsserver after tsserver supports virtual file system, or I have to implement virtual file system for TS language service host in LSP langauge server, and sync by language client's vscode.workspace.fs.

That's something I have a hard time answering. I don't know what approach you have taken right now

@johnsoncodehk
Copy link
Member

@jrieken It's okay, I think I know how to do it now. :)

But my concern is whether synchronizing workspace files to virtual file system of language server will cause performance issues, it seems not proven in tsserver yet and I have to try.

@jrieken
Copy link

jrieken commented Apr 26, 2022

of language server will cause performance issues, it seems not proven in tsserver yet and I have to try.

I do something similar with vscode-anycode and it seems to work. What I do is this: build a glob pattern with all types of files that I support and search for them. I later open them one by one to digest them. There is some tricks and a tad of remote hub knowledge to not get blocked. We are thinking about better API for this but meanwhile that works

@FossPrime
Copy link

FossPrime commented Apr 27, 2022

In the meantime, Rahul Kadyan made an extension called Vue that brings some sintax highliting to Vue SFC's. The extension ID is znck.vue, last update was April 9th, 2020...

For the clue-less: this is what we're getting:
Screenshot 2022-04-27 09 00 57

@yoyo930021
Copy link
Member

@johnsoncodehk Does volar support it?
If yes, I think vetur should not do a repeat

@johnsoncodehk
Copy link
Member

johnsoncodehk commented Nov 1, 2022

@yoyo930021 yes it do, you can try by clone https://github.com/johnsoncodehk/volar and run pnpm I && npm run build && npm run chrome to try.

But it was only working on the local dev browser, not working on github.dev, I have no idea how to debug this problem for github.dev.

@FossPrime
Copy link

@yoyo930021 yes it do, you can try by clone https://github.com/johnsoncodehk/volar and run pnpm I && npm run build && npm run chrome to try.

But it was only working on the local dev browser, not working on github.dev, I have no idea how to debug this problem for github.dev.

Debugger statements work on stackblitz cloudflow. Alternatively, eclipse-theia/theia#11797 (comment) or locally running a VSCode build in VSCode.dev mode could also help.

@ameerthehacker
Copy link

vuejs/language-tools#2177
this fixes issues and makes volar language features work in vscode.dev

@johnsoncodehk
Copy link
Member

FYI, we've got TS + Vue (based on Volar) support for Web IDE by https://marketplace.visualstudio.com/items?itemName=johnsoncodehk.vscode-typescript-web. And Astro support is coming soon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants