cursorless-dev / vscode-parse-tree

Syntax trees for VSCode using tree-sitter
MIT License
40 stars 35 forks source link

added PowerShell support #26

Closed scrthq closed 1 year ago

scrthq commented 2 years ago

Disclaimer: Currently failing to build within my own dev environment (failing to compile web-tree-sitter), but happy to test as soon as I have a VSIX built to test with 😅

node ➜ /workspaces/vscode-parse-tree (language/powershell ✗) $ yarn install
yarn install v1.22.17
$ make web-tree-sitter
/usr/bin/env: ‘bash\r’: No such file or directory
make: *** [Makefile:53: vendor/web-tree-sitter/0.20.4/README.md] Error 127
error Command failed with exit code 2.
info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.

Hoping that the pipeline will generate a VSIX artifact that I can test with (if there is still a pipeline?)

pokey commented 2 years ago

Hmm, I can't get it to work either. Seems like they've forgotten to include the generated parser in source control:

➜ yarn compile                   
yarn run v1.22.18
warning parse-tree@0.17.0: The engine "vscode" appears to be invalid.
$ tsc -p ./ && make parsers
mkdir -p parsers/
npx tree-sitter build-wasm node_modules/tree-sitter-c-sharp/
mv tree-sitter-c_sharp.wasm parsers/tree-sitter-c-sharp.wasm
mkdir -p parsers/
npx tree-sitter build-wasm node_modules/tree-sitter-powershell/
Failed to read grammar file "/Users/pokey/src/vscode-parse-tree/node_modules/tree-sitter-powershell/src/grammar.json"

Caused by:
    No such file or directory (os error 2)
make: *** [parsers/tree-sitter-powershell.wasm] Error 1
error Command failed with exit code 2.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

That file grammar.json should appear in their repo here (see eg python). When I just try to generate the parser locally I get an error:

➜ cd node_modules/tree-sitter-powershell/ 
➜ npm run generate

> tree-sitter-powershell@0.1.0 generate /Users/pokey/src/vscode-parse-tree/node_modules/tree-sitter-powershell
> tree-sitter generate

[stdin]:189
      throw value
      ^

ReferenceError: Undefined symbol '_newline'
    at Object.get ([stdin]:207:23)
    at Proxy.class_definition (/Users/pokey/src/vscode-parse-tree/node_modules/tree-sitter-powershell/grammar.js:64:16)
    at grammar ([stdin]:281:42)
    at Object.<anonymous> (/Users/pokey/src/vscode-parse-tree/node_modules/tree-sitter-powershell/grammar.js:12:18)
    at Module._compile (internal/modules/cjs/loader.js:1085:14)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
    at Module.load (internal/modules/cjs/loader.js:950:32)
    at Function.Module._load (internal/modules/cjs/loader.js:790:12)
    at Module.require (internal/modules/cjs/loader.js:974:19)
    at require (internal/modules/cjs/helpers.js:93:18) {
  symbol: { type: 'SYMBOL', name: '_newline' }
}
pokey commented 1 year ago

I'm going to close this one for now, but feel free to re-open if you find the time to investigate the build failures. Might be worth filing an issue with https://github.com/powershell/tree-sitter-powershell if the parser generation failure is reproducible on their main branch