cucumber / language-server

Cucumber Language Server
MIT License
33 stars 19 forks source link

Go-to-definition failing #90

Closed conradogarciaberrotaran closed 4 months ago

conradogarciaberrotaran commented 9 months ago

Hi, im having problems running go-to-definition in nvim. seems like the step is unparseable? how can I fix this? thanks!

What did you see?

There is a traceback error when running go-to-definition on a Cucumber file under a behave for python. The error is:

[ERROR][2023-11-20 17:16:42] ...lsp/handlers.lua:535
  * Step Definition errors: Error: Parsing failed
    uri: file:///path/to/your/project/features/steps/transform.py
    language: python

    at Parser.parse (/path/to/your/project/node_modules/@cucumber/language-server/node_modules/web-tree-sitter/tree-sitter.js:1:53439)
    at SourceAnalyzer.parse (/path/to/your/project/node_modules/@cucumber/language-server/node_modules/@cucumber/language-service/src/language/SourceAnalyzer.ts:139:72)
    at SourceAnalyzer.getSourceMatches (/path/to/your/project/node_modules/@cucumber/language-server/node_modules/@cucumber/language-service/src/language/SourceAnalyzer.ts:107:21)
    at SourceAnalyzer.eachStepDefinitionExpression (/path/to/your/project/node_modules/@cucumber/language-server/node_modules/@cucumber/language-service/src/language/SourceAnalyzer.ts:80:40)
    at ExpressionBuilder.build (/path/to/your/project/node_modules/@cucumber/language-server/node_modules/@cucumber/language-service/src/language/ExpressionBuilder.ts:51:20)
    at CucumberLanguageServer.<anonymous> (/path/to/your/project/node_modules/@cucumber/language-server/src/CucumberLanguageServer.ts:417:59)
    at Generator.next (<anonymous>)
    at fulfilled (/path/to/your/project/node_modules/@cucumber/language-server/dist/cjs/src/CucumberLanguageServer.js:5:58)

✅ What did you expect to see?

The step definition

📦 Which tool/library version are you using?

Python, nvim 0.9.2, Mason, cucumber.

See my config here: https://github.com/conradogarciaberrotaran/dotfiles/blob/master/nvim/after/plugin/lsp.lua#L93C4-L93C12

🔬 How could we reproduce it?

Install nvim 0.9+ and copy my nvim folder into your .config, install cucumber-language-server in Mason.

conradogarciaberrotaran commented 9 months ago

Update: I found what was the parsing issue, in the file where the parsing failed there was piece of code like this

SOMETHING = {
    "foo": "one|two|three|four"
}

I removed it and the error on the log dissapeared, but still cannot go-to-definition. Now it doesn't work and it shows no error.

kieran-ryan commented 7 months ago

@conradogarciaberrotaran, would you also be able to provide a minimal reproducible example in terms of a gherkin feature file containing one step and also an associated step definition in a module on its own that's failing? Will be useful to rule out a few possibilities and home in on the issue.

binhtran432k commented 7 months ago

The issue is that Mason is using the old version of cucumber-language-server because the lastest version cannot start up outside of VS Code, as indicated this line:

https://github.com/mason-org/mason-registry/blob/96c1f38c4541228abf04b4e72c18583669bc8d44/packages/cucumber-language-server/package.yaml#L13

And in theory, it only works properly on old versions of Node.js. It's also possible that this issue may be solved in #74

lkoning commented 7 months ago

And in theory, it only works properly on old versions of Node.js. It's also possible that this issue may be solved in #74

I'm not very familiar with Nodejs...which older version could we try?

conradogarciaberrotaran commented 7 months ago

should we create a PR for mason registry updating to the latest version?

binhtran432k commented 7 months ago

Hi @conradogarciaberrotaran and @lkoning,

The latest version is experiencing a startup problem when used outside of VS Code. I've just released a temporary package, @binhtran432k/cucumber-language-server, based on the latest update from Git that includes the startup fix from #74.

Could you please test it? Use npm install -g @binhtran432k/cucumber-language-server to install it instead of the Mason version. This temporary package will be in place until #74 is merged and a new version is released by @cucumber.

However, it is not working properly in all of the newest Node.js versions. I've tested it and listed the status of the package for each Node.js version here. I hope this information helps both of you.

Node.js version status
v16.20.2 Work
v17.9.1 Work
v18.19.0 Work
v19.9.0 Failed
v20.11.0 Failed
v21.5.0 Work
lkoning commented 7 months ago

thank you for looking into this. My local Manjaro-install is using Node 21.5.0 but still does seem to work. Also 18.18.2 did not do it. I don't want to bother you with this, there could be something on my side if others are succesful. Thanks again!