vscode-powershell icon indicating copy to clipboard operation
vscode-powershell copied to clipboard

Have a tree sitter grammar to unlock better Powershell experience in VS Code web

Open isidorn opened this issue 4 years ago • 6 comments

Prerequisites

  • [X] I have written a descriptive issue title.
  • [X] I have searched all issues to ensure it has not already been reported.

Summary

Hi, VS Code PM here 👋

After discussing with @TylerLeonhardt what would be the best PowerShell experience for vscode.dev and github.dev we think that the best option would be if PowerShell would contribute a Tree Sitter grammar. With that basic AnyCode language support would work and the experience would be much better.

I understand that adding a Tree Sitter grammar is work, but wanted to open this issue so we start a discussion and in the case that you do not have cycles to do it maybe someone from the community would help.

Thank you very much and let me know what you think

Proposed Design

No response

isidorn avatar Dec 07 '21 15:12 isidorn

To fully enumerate the options I thought of that prompted us to open this issue:

  • get PSES working in the web (involves a lot of unknowns...WASM, Blazor, but the problem here is multi-threading on the web)
  • factor out the PowerShell parser which I think will be way easier to get working in WASM (still same WASM Blazor unknowns)
  • Make a tree-sitter grammar for PowerShell (I know this is at least possible...but it is a lot of work)

tree-sitter has the added benefit of allowing github.com itself to light up their code navigation feature.

TylerLeonhardt avatar Dec 07 '21 16:12 TylerLeonhardt

Could have sworn @rjmholt started on one somewhere but I can't seem to find it. Am I misremembering that?

SeeminglyScience avatar Dec 07 '21 16:12 SeeminglyScience

Yeah I don't think we got very far that that was useful to link here.

TylerLeonhardt avatar Dec 07 '21 17:12 TylerLeonhardt

Repo is here.

Importantly, while some things are easy to express, PowerShell has a complicated grammar and even its own tokeniser has some weird bits, hacks and issues.

Things like no semicolons, line continuations, heredocs, expandable strings, etc sometimes require some clever implementation and even dropping into C.

rjmholt avatar Dec 07 '21 22:12 rjmholt

We're actually already looking at doing something like this but had not announced it publicly. It's an incubation project to be sure (no commitment but we're (read: I'm) quite interested).

andyleejordan avatar Dec 09 '21 16:12 andyleejordan

+1 to what @andschwa said, and certainly having more proposed scenarios/integration points/community interest always helps prioritization

SydneyhSmith avatar Dec 09 '21 16:12 SydneyhSmith