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

Unable to get working with neovim #66

Closed
darrinholst opened this issue Oct 10, 2022 · 11 comments · Fixed by #68 or #74
Closed

Unable to get working with neovim #66

darrinholst opened this issue Oct 10, 2022 · 11 comments · Fixed by #68 or #74

Comments

@darrinholst
Copy link

👓 What did you see?

Tried using the language server in neovim mostly just to get feature file formatting, but getting the following error...

[ERROR][2022-10-10 08:03:10] ...lsp/handlers.lua:485 "Cucumber Language Server 1.0.0: Unhandled Rejection at promise: [object Promise], reason: TypeError: Failed to parse URL from /Users/darrinholst/.local/share/nvim/mason/packages/cucumber-language-server/node_modules/@cucumber/language-server/node_modules/web-tree-sitter/tree-sitter.wasm"

➜ l ~/.local/share/nvim/mason/packages/cucumber-language-server/node_modules/@cucumber/language-server/node_modules/web-tree-sitter
total 512
-rw-r--r--  1 darrinholst  staff   1.1K Oct 10 07:57 LICENSE
-rw-r--r--  1 darrinholst  staff   5.8K Oct 10 07:57 README.md
-rw-r--r--  1 darrinholst  staff   820B Oct 10 07:57 package.json
-rw-r--r--  1 darrinholst  staff   5.2K Oct 10 07:57 tree-sitter-web.d.ts
-rw-r--r--  1 darrinholst  staff    53K Oct 10 07:57 tree-sitter.js
-rwxr-xr-x  1 darrinholst  staff   174K Oct 10 07:57 tree-sitter.wasm*

✅ What did you expect to see?

Not an error. 😏

📦 Which tool/library version are you using?

  • cucumber-language-server 1.0.0 (I've never got this working with previous versions either)
  • neovim 0.8.0
  • latest of the lsp/mason plugins
  • node 16
  • mac arm64

🔬 How could we reproduce it?

Sorry, I'm not the best at debugging neovim lsp errors. It seems that others have gotten this to work so it's a shot in the dark to see if anyone else is having this issue. I'd be happy to debug it locally if anyone has any tips or tricks on how to do that. I have been able to work around the formatting that I was in search of by using @cucumber/gherkin-utils directly, but it would be nice to get it working with lsp.

This text was originally generated from a template, then edited by hand. You can modify the template here.

@aslakhellesoy
Copy link
Contributor

Thanks, I'll take a look. I think we've fixed this once before...

@aslakhellesoy
Copy link
Contributor

@Issafalcon I see from #38 that you are also using neovim. Are you able to run 1.0.0 successfully in neovim?

@Issafalcon
Copy link

@aslakhellesoy - It's been a while since I've done anything with cucumber actually, but I have started using mason like @darrinholst instead of the previous methods for installing LSPs, so it might have changed how setup works. When I get chance, I'll try and use it again. Might need to update my Neovim version as well.

@darrinholst
Copy link
Author

I was able to get a better stack trace. Seems that it's expecting a URL and receiving a file path. (I know little more about wasm than what the acronym means)

Promise {
  <rejected> TypeError: Failed to parse URL from /Users/darrinholst/.local/share/nvim/mason/packages/cucumber-language-server/node_modules/@cucumber/language-server/node_modules/web-tree-sitter/tree-sitter.wasm
      at new Request (node:internal/deps/undici/undici:5423:19)
      at Agent.fetch2 (node:internal/deps/undici/undici:6219:25)
      ... 4 lines matching cause stack trace ...
      at new Promise (<anonymous>)
      at Function.init (/Users/darrinholst/.local/share/nvim/mason/packages/cucumber-language-server/node_modules/@cucumber/language-server/node_modules/web-tree-sitter/tree-sitter.js:1:332)
      at WasmParserAdapter.<anonymous> (/Users/darrinholst/.local/share/nvim/mason/packages/cucumber-language-server/node_modules/@cucumber/language-server/node_modules/@cucumber/language-service/dist/cjs/src/tree-sitter-wasm/WasmParserAdapter.js:56:60)
      at step (/Users/darrinholst/.local/share/nvim/mason/packages/cucumber-language-server/node_modules/@cucumber/language-server/node_modules/@cucumber/language-service/dist/cjs/src/tree-sitter-wasm/WasmParserAdapter.js:33:23) {
    [cause]: TypeError: Invalid URL
        at new NodeError (node:internal/errors:387:5)
        at URL.onParseError (node:internal/url:564:9)
        at new URL (node:internal/url:644:5)
        at new Request (node:internal/deps/undici/undici:5421:25)
        at Agent.fetch2 (node:internal/deps/undici/undici:6219:25)
        at Object.fetch (node:internal/deps/undici/undici:7053:20)
        at fetch (node:internal/bootstrap/pre_execution:198:25)
        at /Users/darrinholst/.local/share/nvim/mason/packages/cucumber-language-server/node_modules/@cucumber/language-server/node_modules/web-tree-sitter/tree-sitter.js:1:18418
        at /Users/darrinholst/.local/share/nvim/mason/packages/cucumber-language-server/node_modules/@cucumber/language-server/node_modules/web-tree-sitter/tree-sitter.js:1:18639
        at new Promise (<anonymous>) {
      input: '/Users/darrinholst/.local/share/nvim/mason/packages/cucumber-language-server/node_modules/@cucumber/language-server/node_modules/web-tree-sitter/tree-sitter.wasm',
      code: 'ERR_INVALID_URL'
    }
  }
}

@darrinholst
Copy link
Author

I found the end of the 🐰 hole - tree-sitter/tree-sitter#1765

@aslakhellesoy
Copy link
Contributor

Ooooh that's some serious burrowing @darrinholst! Thanks for doing the digging!

@aslakhellesoy
Copy link
Contributor

I released 1.1.0 which might fix this via #68 although I must admit I haven't tested it.

Please reopen this issue if the problem persists.

@darrinholst
Copy link
Author

Still seeing the same thing when node is 18.6.0. It has the file:// protocol at the time of startWasmServer, but it gets stripped at some point. I didn't think fetch supported file:// anyway so maybe that's what is removing it.

Promise {
  <rejected> TypeError: Failed to parse URL from /Users/darrinholst/.local/share/nvim/mason/packages/cucumber-language-server/node_modules/@cucumber/language-server/node_modules/web-tree-sitter/tree-sitter.wasm
      at new Request (node:internal/deps/undici/undici:5423:19)
      at Agent.fetch2 (node:internal/deps/undici/undici:6219:25)
      ... 4 lines matching cause stack trace ...
      at new Promise (<anonymous>)
      at Function.init (/Users/darrinholst/.local/share/nvim/mason/packages/cucumber-language-server/node_modules/@cucumber/language-server/node_modules/web-tree-sitter/tree-sitter.js:1:332)
      at WasmParserAdapter.<anonymous> (/Users/darrinholst/.local/share/nvim/mason/packages/cucumber-language-server/node_modules/@cucumber/language-server/node_modules/@cucumber/language-service/src/tree-sitter-wasm/WasmParserAdapter.ts:12:22)
      at step (/Users/darrinholst/.local/share/nvim/mason/packages/cucumber-language-server/node_modules/@cucumber/language-server/node_modules/@cucumber/language-service/dist/cjs/src/tree-sitter-wasm/WasmParserAdapter.js:33:23) {
    [cause]: TypeError: Invalid URL
        at new NodeError (node:internal/errors:387:5)
        at URL.onParseError (node:internal/url:564:9)
        at new URL (node:internal/url:644:5)
        at new Request (node:internal/deps/undici/undici:5421:25)
        at Agent.fetch2 (node:internal/deps/undici/undici:6219:25)
        at Object.fetch (node:internal/deps/undici/undici:7053:20)
        at fetch (node:internal/bootstrap/pre_execution:198:25)
        at /Users/darrinholst/.local/share/nvim/mason/packages/cucumber-language-server/node_modules/@cucumber/language-server/node_modules/web-tree-sitter/tree-sitter.js:1:18418
        at /Users/darrinholst/.local/share/nvim/mason/packages/cucumber-language-server/node_modules/@cucumber/language-server/node_modules/web-tree-sitter/tree-sitter.js:1:18639
        at new Promise (<anonymous>) {
      input: '/Users/darrinholst/.local/share/nvim/mason/packages/cucumber-language-server/node_modules/@cucumber/language-server/node_modules/web-tree-sitter/tree-sitter.wasm',
      code: 'ERR_INVALID_URL'
    }
  }
}

On a side note, I did try it with node 16.17.1 and it seems to be working although the thing I really wanted it for was formatting which isn't working (probably a separate issue from this one). This is what I'm seeing...

[DEBUG][2022-10-10 16:48:37] .../vim/lsp/rpc.lua:285	"rpc.send"	{
  id = 3,
  jsonrpc = "2.0",
  method = "textDocument/formatting",
  params = {
    options = {
      insertSpaces = true,
      tabSize = 2
    },
    textDocument = {
      uri = "file:///Users/darrinholst/projects/cucumber-js/features/esm.feature"
    }
  }
}
[DEBUG][2022-10-10 16:48:37] .../vim/lsp/rpc.lua:388	"rpc.receive"	{
  error = {
    code = -32601,
    message = "Unhandled method textDocument/formatting"
  },
  id = 3,
  jsonrpc = "2.0"
}

@darrinholst darrinholst reopened this Oct 10, 2022
@Issafalcon
Copy link

Issafalcon commented Oct 12, 2022

Hi @aslakhellesoy - I just tried running using the following versions of tools:

  • neovim v0.7.2
  • node 16.8
  • latest Mason plugin release
  • cucumber-language-server v1.1.1

I get a series of errors when it tries to load the wasm files:

[ERROR][2022-10-12 17:02:33] .../vim/lsp/rpc.lua:420	"rpc"	"cucumber-language-server"	"stderr"	"Failed to load file:///home/issafalcon/.local/share/nvim/mason/packages/cucumber-language-server/node_modules/@cucumber/language-server/node_modules/@cucumber/language-service/dist/java.wasm: ENOENT: no such file or directory, open 'file:///home/issafalcon/.local/share/nvim/mason/packages/cucumber-language-server/node_modules/@cucumber/language-server/node_modules/@cucumber/language-service/dist/java.wasm'\n"
[ERROR][2022-10-12 17:02:33] .../vim/lsp/rpc.lua:420	"rpc"	"cucumber-language-server"	"stderr"	"Failed to load file:///home/issafalcon/.local/share/nvim/mason/packages/cucumber-language-server/node_modules/@cucumber/language-server/node_modules/@cucumber/language-service/dist/tsx.wasm: ENOENT: no such file or directory, open 'file:///home/issafalcon/.local/share/nvim/mason/packages/cucumber-language-server/node_modules/@cucumber/language-server/node_modules/@cucumber/language-service/dist/tsx.wasm'\n"
[ERROR][2022-10-12 17:02:33] .../vim/lsp/rpc.lua:420	"rpc"	"cucumber-language-server"	"stderr"	"Failed to load file:///home/issafalcon/.local/share/nvim/mason/packages/cucumber-language-server/node_modules/@cucumber/language-server/node_modules/@cucumber/language-service/dist/c_sharp.wasm: ENOENT: no such file or directory, open 'file:///home/issafalcon/.local/share/nvim/mason/packages/cucumber-language-server/node_modules/@cucumber/language-server/node_modules/@cucumber/language-service/dist/c_sharp.wasm'\nFailed to load file:///home/issafalcon/.local/share/nvim/mason/packages/cucumber-language-server/node_modules/@cucumber/language-server/node_modules/@cucumber/language-service/dist/php.wasm: ENOENT: no such file or directory, open 'file:///home/issafalcon/.local/share/nvim/mason/packages/cucumber-language-server/node_modules/@cucumber/language-server/node_modules/@cucumber/language-service/dist/php.wasm'\nFailed to load file:///home/issafalcon/.local/share/nvim/mason/packages/cucumber-language-server/node_modules/@cucumber/language-server/node_modules/@cucumber/language-service/dist/python.wasm: ENOENT: no such file or directory, open 'file:///home/issafalcon/.local/share/nvim/mason/packages/cucumber-language-server/node_modules/@cucumber/language-server/node_modules/@cucumber/language-service/dist/python.wasm'\n"
[ERROR][2022-10-12 17:02:33] .../vim/lsp/rpc.lua:420	"rpc"	"cucumber-language-server"	"stderr"	"Failed to load file:///home/issafalcon/.local/share/nvim/mason/packages/cucumber-language-server/node_modules/@cucumber/language-server/node_modules/@cucumber/language-service/dist/ruby.wasm: ENOENT: no such file or directory, open 'file:///home/issafalcon/.local/share/nvim/mason/packages/cucumber-language-server/node_modules/@cucumber/language-server/node_modules/@cucumber/language-service/dist/ruby.wasm'\nFailed to load file:///home/issafalcon/.local/share/nvim/mason/packages/cucumber-language-server/node_modules/@cucumber/language-server/node_modules/@cucumber/language-service/dist/rust.wasm: ENOENT: no such file or directory, open 'file:///home/issafalcon/.local/share/nvim/mason/packages/cucumber-language-server/node_modules/@cucumber/language-server/node_modules/@cucumber/language-service/dist/rust.wasm'\n"

The wasm files are there in the dist folder where mason installs them

Beyond that, the LspLogs throw lots of the following errors on parsing:

[ERROR][2022-10-12 17:02:36] ...lsp/handlers.lua:455	"* Step Definition errors: Error: Parsing failed\nuri: file:///home/issafalcon/repos/SpecFlow-Examples/Webinars/2021-11-24%20SpecFlow%20Beyond%20The%20UI/SpecFlowBeyondTheUIWebinar.Tests/StepDefinitions/AccountCreationAPISteps.cs\nlanguage: c_sharp\n\n    at Parser.parse (/home/issafalcon/.local/share/nvim/mason/packages/cucumber-language-server/node_modules/@cucumber/language-server/node_modules/web-tree-sitter/tree-sitter.js:1:38190)\n    at SourceAnalyzer.parse (/home/issafalcon/.local/share/nvim/mason/packages/cucumber-language-server/node_modules/@cucumber/language-server/node_modules/@cucumber/language-service/src/language/SourceAnalyzer.ts:139:72)\n    at SourceAnalyzer.getSourceMatches (/home/issafalcon/.local/share/nvim/mason/packages/cucumber-language-server/node_modules/@cucumber/language-server/node_modules/@cucumber/language-service/src/language/SourceAnalyzer.ts:107:21)\n    at SourceAnalyzer.eachStepDefinitionExpression (/home/issafalcon/.local/share/nvim/mason/packages/cucumber-language-server/node_modules/@cucumber/language-server/node_modules/@cucumber/language-service/src/language/SourceAnalyzer.ts:80:40)\n    at ExpressionBuilder.build (/home/issafalcon/.local/share/nvim/mason/packages/cucumber-language-server/node_modules/@cucumber/language-server/node_modules/@cucumber/language-service/src/language/ExpressionBuilder.ts:51:20)\n    at CucumberLanguageServer.<anonymous> (/home/issafalcon/.local/share/nvim/mason/packages/cucumber-language-server/node_modules/@cucumber/language-server/src/CucumberLanguageServer.ts:417:59)\n    at Generator.next (<anonymous>)\n    at fulfilled (/home/issafalcon/.local/share/nvim/mason/packages/cucumber-language-server/node_modules/@cucumber/language-server/dist/cjs/src/CucumberLanguageServer.js:5:58)"

Naturally, the language server is now unusable.

@aslakhellesoy
Copy link
Contributor

Thanks for the details. The language server is embedded as a library in the Cucumber vscode extension, where it works without any problems. I believe VSCode runs on Node 16.

It’s not a priority for me to make it work as a standalone CLI, but I’d be delighted if someone could figure out why it’s not working, and submit a PR.

@darrinholst
Copy link
Author

Closing as I have a workaround for what I need for formatting (and it's probably just me in the middle of the Cucumber-Vim-Neovim Venn diagram anyway 😏 ). I'd like to get it working as well, but I think we're blocked on tree-sitter/tree-sitter#1765 for now. I'll keep an eye on that and come back to this when it's resolved.

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