Giter Club home page Giter Club logo

language-server's Introduction


Cucumber Language Server

A Language Server for Cucumber

npm test-javascript-package release-package-github backers sponsors

Provides most of the functionality offered by the Cucumber Visual Studio Code Extension and can also be utilised with other editors that support the Language Server Protocol (LSP).

Features

See Cucumber Language Service, which implements most of the logic in this server. If you are looking to add a new feature, you should probably add it to Cucumber Language Service.

Install

Cucumber Language Server is available on npm:

npm install @cucumber/language-server

Settings

The LSP client can provide settings to the server, but the server provides reasonable defaults (see defaultSettings) if the client does not provide them.

The server retrieves cucumber.* settings from the client with a workspace/configuration request.

See Settings for details about the expected format.

External VSCode Usage

We've encountered an issue with the Node version used by Treesitter, a dependency of this language server, when working outside of VSCode. For optimal compatibility, please use the same Node version as version 18 of VSCode.

Support

Support is available from the community if you need it.

language-server's People

Contributors

aslakhellesoy avatar aurelien-reeves avatar binhtran432k avatar cukebot avatar kieran-ryan avatar mpkorstanje avatar mrkaiser avatar olleolleolle avatar renovate-bot avatar renovate[bot] avatar richardruiter avatar surc54 avatar williamboman avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

language-server's Issues

Print existing steps and step definitions

๐Ÿค” What's the problem you're trying to solve?

Get a list of all step definitions and steps that match these step definitions.

โœจ What's your proposed solution?

List all the steps and step definitions:

npx @cucumber/language-server --list

* I have {int} cuke(s)   # features/step_definitions/foo.ts:43
  * I have 3 cukes       # features/a.feature:32
  * I have 1 cuke        # features/b.feature:12
* /I eat (\d+) cukes/    # features/step_definitions/foo.ts:15
  * I eat 3 cukes        # features/a.feature:11

โ› Have you considered any alternatives or workarounds?

This is implemented in the usage formatter in various Cucumber implementations. By implementing it here we can remove this from all Cucumbers.

Does not work? (cannot find tree-sitter)

๐Ÿ‘“ What did you see?

โžœ  ~ # npm install --global @cucumber/language-server

added 112 packages, and audited 113 packages in 14s

8 packages are looking for funding
  run `npm fund` for details

found 0 vulnerabilities
โžœ  ~ # cucumber-language-server --version
Error: Cannot find module 'tree-sitter'
Require stack:
- /usr/local/lib/node_modules/@cucumber/language-server/node_modules/@cucumber/language-service/dist/cjs/src/tree-sitter-node/NodeParserAdapter.js
- /usr/local/lib/node_modules/@cucumber/language-server/dist/cjs/src/node/startNodeServer.js
- /usr/local/lib/node_modules/@cucumber/language-server/bin/cucumber-language-server.cjs
    at Function.Module._resolveFilename (node:internal/modules/cjs/loader:939:15)
    at Function.Module._load (node:internal/modules/cjs/loader:780:27)
    at Module.require (node:internal/modules/cjs/loader:1005:19)
    at require (node:internal/modules/cjs/helpers:102:18)
    at Object.<anonymous> (/usr/local/lib/node_modules/@cucumber/language-server/node_modules/@cucumber/language-service/src/tree-sitter-node/NodeParserAdapter.ts:2:1)
    at Module._compile (node:internal/modules/cjs/loader:1105:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1159:10)
    at Module.load (node:internal/modules/cjs/loader:981:32)
    at Function.Module._load (node:internal/modules/cjs/loader:827:12)
    at Module.require (node:internal/modules/cjs/loader:1005:19)

โœ… What did you expect to see?

The executable installed by this module should not crash.

๐Ÿ“ฆ Which tool/library version are you using?

0.12.10

๐Ÿ”ฌ How could we reproduce it?

โžœ  ~ # npm install --global @cucumber/language-server
โžœ  ~ # cucumber-language-server --version

๐Ÿ“š Any additional context?

I'm trying to use this lsp with neovim via nvim-lspconfig.

LSP Client generates "Cannot find module" error

๐Ÿ‘“ What did you see?

When I review the log file for the LSP, I see

[ERROR][2023-05-01 08:57:04] .../vim/lsp/rpc.lua:734	"rpc"	"cucumber-language-server"	"stderr"	"Error: Cannot find module '../src/version'
Require stack:
- /Users/stagr005/.local/share/lvim/mason/packages/cucumber-language-server/node_modules/@cucumber/language-server/bin/cucumber-language-server.cjs
    at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)
    at Function.Module._load (node:internal/modules/cjs/loader:778:27)
    at Module.require (node:internal/modules/cjs/loader:1005:19)
    at require (node:internal/modules/cjs/helpers:102:18)
    at Object.<anonymous> (/Users/stagr005/.local/share/lvim/mason/packages/cucumber-language-server/node_modules/@cucumber/language-server/bin/cucumber-language-server.cjs:7:21)
    at Module._compile (node:internal/modules/cjs/loader:1103:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1157:10)
    at Module.load (node:internal/modules/cjs/loader:981:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:77:12)

โœ… What did you expect to see?

no errors

๐Ÿ“ฆ Which tool/library version are you using?

java version 1.8.0_181
cucumber version 1.2.5
neovim 0.9.0

๐Ÿ”ฌ How could we reproduce it?

open a cucumber file in neovim. The version of cucumber should be 1.2.5

๐Ÿ“š Any additional context?


Fix the build

The build is failing because the tests don't run in ESM. I think we can still release this as a dual esm/commonjs library, but we can only run the tests with commonjs. See the description in #20 for a bit more details.

Pretty-Quick conflict with Prettier v3 causing pre-commit hook to fail

๐Ÿค” What's the problem you've observed?

I'm encountering an issue where the pre-commit hook using pretty-quick is failing, preventing me from creating new commits. The issue seems to stem from a conflict with Prettier v3.

โœจ Do you have a proposal for making it better?

I think pretty-quick is outdated, it hasn't been updated for 2 years. We should temporarily disable the pre-commit hook now.

๐Ÿ“š Any additional context?

See prettier/pretty-quick#168


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

Failing to start server - can not find module '../src/version'

๐Ÿ‘“ What did you see?

I installed it by npm install @cucumber/[email protected]. When I try to run it with npm exec cucumber-language-server I always get the following error:

Error: Cannot find module '../src/version'
Require stack:
- /tmp/tmp.bonT5bjDQQ/node_modules/@cucumber/language-server/bin/cucumber-language-server.cjs
    at Function.Module._resolveFilename (node:internal/modules/cjs/loader:1143:15)
    at Function.Module._load (node:internal/modules/cjs/loader:984:27)
    at Module.require (node:internal/modules/cjs/loader:1234:19)
    at require (node:internal/modules/helpers:176:18)
    at Object.<anonymous> (/tmp/tmp.bonT5bjDQQ/node_modules/@cucumber/language-server/bin/cucumber-language-server.cjs:7:21)
    at Module._compile (node:internal/modules/cjs/loader:1375:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1434:10)
    at Module.load (node:internal/modules/cjs/loader:1206:32)
    at Function.Module._load (node:internal/modules/cjs/loader:1022:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:142:12)

โœ… What did you expect to see?

I guess some logs of the running server. At least not an error and termination with a non-zero exit code ๐Ÿคท๐Ÿพ

๐Ÿ“ฆ Which tool/library version are you using?

OS: ArchLinux
NodeJS version: v21.5.0
NPM version: 10.2.4

๐Ÿ”ฌ How could we reproduce it?

$ node --version
v21.5.0
$ npm --version
10.2.4
$ cd $(mkdir --parents $(mktemp --directory))
$ npm init
$ npm install @cucumber/[email protected]
$ npm exec cucumber-lanuage-server

๐Ÿ“š Any additional context?

Unfortunately not (yet?).

Support for javascript step definitions

Currently the language server support step definitions only in these 5 languages: typescript, java, c_sharp, php, ruby. Cucumber does support javascript with file extensions '.js' and '.mjs'. Please consider adding support.

Support workspace/didChangeConfiguration request

๐Ÿค” What's the problem you're trying to solve?

I am using neovim with cucumber_language_server installed, but the language server cannot find the glue files with the following config.

    settings = {
        features= {'features/**/*.feature'},
        glue = {'src/Behat/*.php'}
    }

the log file shows that the config was passed to server with workspace/didChangeConfiguration request

[DEBUG][2022-05-15 11:35:34] .../vim/lsp/rpc.lua:347	"rpc.send"	{  jsonrpc = "2.0",  method = "workspace/didChangeConfiguration",  params = {    settings = {      features = { "features/**/*.feature" },      glue = { "src/Behat/*.php" },      <metatable> = {        __tostring = <function 1>      }    }  }}
[DEBUG][2022-05-15 11:35:34] .../vim/lsp/rpc.lua:454	"rpc.receive"	{  id = 1,  jsonrpc = "2.0",  method = "workspace/configuration",  params = {    items = { {        section = "cucumber"      } }  }}
[INFO][2022-05-15 11:35:34] ...lsp/handlers.lua:458	"Found 25 feature file(s)"
[INFO][2022-05-15 11:35:34] ...lsp/handlers.lua:458	"Found 4286 steps in those feature files"
[INFO][2022-05-15 11:35:34] ...lsp/handlers.lua:458	"Found 0 glue file(s)"
[INFO][2022-05-15 11:35:34] ...lsp/handlers.lua:458	"Found 0 step definitions in those glue files"
[INFO][2022-05-15 11:35:34] ...lsp/handlers.lua:458	"Built 0 step documents for auto complete"

โœจ What's your proposed solution?

Support workspace/didChangeConfiguration request so that the setting can be passed with this request

โ› Have you considered any alternatives or workarounds?

๐Ÿ“š Any additional context?


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

Glue code not being found

๐Ÿ‘“ What did you see?

I'm starting to write some features with a proof-of-concept repo for automated testing. The tech stack(so far) is Java, Maven, and Sikuli and I believe I have the right coordinates in my pom to throw Cucumber into the mix. I added version 1.2.3 in VS Code and started to make some step defs. I noticed they weren't being recognized nor could I make a new one from a feature file. The logs indicate Cucumber Language server can't find anything. I've tried the default setting for cucumber.features and cucumber.glue, hard-coding the direct paths, and escaping the /s. Nothing's taken root. Relevant settings in settings.json are currently:

    "cucumber.features": [
        "src/test/**/*.feature",
        "src/test/resources/feature/*.feature"
    ],

    "cucumber.glue": [
        "src/test/**/*.java",
        "src/test/java/com/oddball/xmlcomparemaven/*.java"
    ]

Here is the log from 'Cucumber Language Server`:

[Info  - 8:38:40 AM] Reindexing...
[Info  - 8:38:40 AM] * Found 0 feature file(s) in ["src/test/**/*.feature","src/test/resources/feature/*.feature"]
[Info  - 8:38:40 AM] * Found 0 steps in those feature files
[Info  - 8:38:40 AM] * Found 0 glue file(s) in ["src/test/**/*.java","src/test/java/com/oddball/xmlcomparemaven/*.java"]
[Info  - 8:38:40 AM] * Found 0 parameter types in those glue files
[Info  - 8:38:40 AM] * Found 0 step definitions in those glue files
[Info  - 8:38:40 AM] Generating diagnostics
[Info  - 8:38:40 AM] * Built 0 suggestions for auto complete
[Info  - 8:38:40 AM] Unable to generate step definition. Please create one first manually.

This is reflected when I execute the runner class:
image

โœ… What did you expect to see?

  • The stepdef being recognized
  • The ability to add a new stepdef from the feature file
  • Ability to run Scenarios from the Runner class

๐Ÿ“ฆ Which tool/library version are you using?

  • Mac OSX 12.4 (M1)
  • VS Code 1.67.2
  • Cucumber for Visual Studio Code 1.2.3
  • The last time I mentioned this I posted the pom I was told it was irrelevant. If that changes I can post it on request.

๐Ÿ”ฌ How could we reproduce it?

  • Install VS Code and relevant plugins
  • Add Runner and Stepdef classes
  • Configure settings.json with above configuration
  • Configure pom.xml with relevant Maven coordinates
  • Save everything, restart VS Code
  • pom.xml > Update project
  • Change the Output tab to Cucumber Language Server
  • Attempt to use existing stepdefs, write new ones from the feature file, and run scenarios from the Runner class.

๐Ÿ“š Any additional context?

I've used Cucumber before in IntelliJ and Eclipse. This is my first time using this in VS Code. This could very well be something I am doing wrong instead of a bug. For original context, see cucumber/language-service#45

Windows test fails on ENAMETOOLONG

Describe the bug

There is 1 failing test which can not run on Windows, and it fails with an ENAMETOOLONG error.

Should that test be skipped, or amended, for that platform?

To Reproduce
Steps to reproduce the behavior:

  1. Go to any CI test output for the windows target
  2. Click on the install-test step
  3. See error

Expected behavior

โœ… green tests.

CI:

  • OS: windows-latest
  • Browser n/a
  • Version: Node 16.x

Unable to get working with neovim

๐Ÿ‘“ 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.

CI: is it time to let go of Node 14?

๐Ÿค” What's the problem you've observed?

npm install hits problems running Python code that gyp started executing, not understanding the rU mode specifier - that seems like a Python version support issue somewhere.

โœจ Do you have a proposal for making it better?

Um, perhaps node 14 is too old for this fast-moving landscape?

๐Ÿ“š Any additional context?

here is where I saw the build error
#94

node 16.x passes.

> [email protected] install /Users/runner/work/language-server/language-server/node_modules/tree-sitter-c-sharp
> node-gyp rebuild

Traceback (most recent call last):
  File "/Users/runner/hostedtoolcache/node/14.21.3/x64/lib/node_modules/npm/node_modules/node-gyp/gyp/gyp_main.py", line 50, in <module>
    sys.exit(gyp.script_main())
             ^^^^^^^^^^^^^^^^^
  File "/Users/runner/hostedtoolcache/node/14.21.3/x64/lib/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/__init__.py", line 554, in script_main
    return main(sys.argv[1:])
           ^^^^^^^^^^^^^^^^^^
  File "/Users/runner/hostedtoolcache/node/14.21.3/x64/lib/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/__init__.py", line 547, in main
    return gyp_main(args)
           ^^^^^^^^^^^^^^
  File "/Users/runner/hostedtoolcache/node/14.21.3/x64/lib/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/__init__.py", line 520, in gyp_main
    [generator, flat_list, targets, data] = Load(
                                            ^^^^^
  File "/Users/runner/hostedtoolcache/node/14.21.3/x64/lib/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/__init__.py", line 136, in Load
    result = gyp.input.Load(build_files, default_variables, includes[:],
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/runner/hostedtoolcache/node/14.21.3/x64/lib/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/input.py", line 2782, in Load
    LoadTargetBuildFile(build_file, data, aux_data,
  File "/Users/runner/hostedtoolcache/node/14.21.3/x64/lib/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/input.py", line 391, in LoadTargetBuildFile
    build_file_data = LoadOneBuildFile(build_file_path, data, aux_data,
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/runner/hostedtoolcache/node/14.21.3/x64/lib/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/input.py", line 234, in LoadOneBuildFile
    build_file_contents = open(build_file_path, 'rU').read()
                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^
ValueError: invalid mode: 'rU' while trying to load binding.gyp
gyp ERR! configure error 
gyp ERR! stack Error: `gyp` failed with exit code: 1
gyp ERR! stack     at ChildProcess.onCpExit (/Users/runner/hostedtoolcache/node/14.21.3/x64/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:351:16)
gyp ERR! stack     at ChildProcess.emit (events.js:400:28)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:285:12)
gyp ERR! System Darwin 21.6.0
gyp ERR! command "/Users/runner/hostedtoolcache/node/14.21.3/x64/bin/node" "/Users/runner/hostedtoolcache/node/14.21.3/x64/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /Users/runner/work/language-server/language-server/node_modules/tree-sitter-c-sharp
gyp ERR! node -v v14.21.3
gyp ERR! node-gyp -v v5.1.1
gyp ERR! not ok 

> [email protected] install /Users/runner/work/language-server/language-server/node_modules/tree-sitter-cli
> node install.js

Downloading https://github.com/tree-sitter/tree-sitter/releases/download/v0.20.7/tree-sitter-macos-x64.gz
  File "/Users/runner/hostedtoolcache/node/14.21.3/x64/lib/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/__init__.py", line 554, in script_main
    return main(sys.argv[1:])
           ^^^^^^^^^^^^^^^^^^
  File "/Users/runner/hostedtoolcache/node/14.21.3/x64/lib/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/__init__.py", line 547, in main
    return gyp_main(args)
           ^^^^^^^^^^^^^^
  File "/Users/runner/hostedtoolcache/node/14.21.3/x64/lib/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/__init__.py", line 520, in gyp_main
    [generator, flat_list, targets, data] = Load(
                                            ^^^^^
  File "/Users/runner/hostedtoolcache/node/14.21.3/x64/lib/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/__init__.py", line 136, in Load
    result = gyp.input.Load(build_files, default_variables, includes[:],
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/runner/hostedtoolcache/node/14.21.3/x64/lib/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/input.py", line 2782, in Load
    LoadTargetBuildFile(build_file, data, aux_data,
  File "/Users/runner/hostedtoolcache/node/14.21.3/x64/lib/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/input.py", line 391, in LoadTargetBuildFile
    build_file_data = LoadOneBuildFile(build_file_path, data, aux_data,
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/runner/hostedtoolcache/node/14.21.3/x64/lib/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/input.py", line 234, in LoadOneBuildFile
    build_file_contents = open(build_file_path, 'rU').read()
                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^
ValueError: invalid mode: 'rU' while trying to load binding.gyp
gyp ERR! configure error 
gyp ERR! stack Error: `gyp` failed with exit code: 1
gyp ERR! stack     at ChildProcess.onCpExit (/Users/runner/hostedtoolcache/node/14.21.3/x64/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:351:16)
gyp ERR! stack     at ChildProcess.emit (events.js:400:28)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:285:12)
gyp ERR! System Darwin 21.6.0
gyp ERR! command "/Users/runner/hostedtoolcache/node/14.21.3/x64/bin/node" "/Users/runner/hostedtoolcache/node/14.21.3/x64/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /Users/runner/work/language-server/language-server/node_modules/tree-sitter-ruby
gyp ERR! node -v v14.21.3
gyp ERR! node-gyp -v v5.1.1
gyp ERR! not ok 

> @cucumber/[email protected] prepare /Users/runner/work/language-server/language-server
> husky install

file:///Users/runner/work/language-server/language-server/node_modules/husky/bin.mjs:14
	;(o.scripts ||= {}).prepare = 'husky'
	            ^^^

SyntaxError: Unexpected token '||='
    at Loader.moduleStrategy (internal/modules/esm/translators.js:149:18)
    at async link (internal/modules/esm/module_job.js:67:21)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! @cucumber/[email protected] prepare: `husky install`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the @cucumber/[email protected] prepare script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/runner/.npm/_logs/2024-02-28T22_49_53_945Z-debug.log
Error: Process completed with exit code 1.

Action Required: Fix Renovate Configuration

There is an error with this repository's Renovate configuration that needs to be fixed. As a precaution, Renovate will stop PRs until it is resolved.

Location: .github/renovate.json
Error type: Invalid JSON (parsing failed)
Message: Syntax error: expecting end of expression or separator near oard": tru

Go-to-definition failing

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.

Fix autocomplete - load expressions from step definitions

Is your feature request related to a problem? Please describe.

The language server currently reports 0 items for autocompletion. This is because it doesn't load any step definitions (cucumber expressions and regular expressions).

Describe the solution you'd like
The ExpressionBuilder object that we pass to the CucumberLanguageServer constructor is currently not used. We should call ExpressionBuilder#build on it, passing in the source code of all the Java/TypeScript files in the project. To improve performance, we should only load the source code that contains step definitions, and not production source code. This could use a glob that is defined as part of settings.

The LSP does not yet provide a way to read the file system, so this has to be done using the Node.js fs module. It might need to use some kind of "watch" trigger so that we read again whenever a step definitions file is modified/added/deleted.

Using fs has consequences for cucumber/vscode#1 - we cannot use fs in a web extension.

Require of ES Modules not supported error when attempting to run v0.6.0

๐Ÿ‘“ What did you see?

After recent updates to the language server, I tested it out using the cucumber-lsp in Neovim (v0.7.0) and got the following client error:
[ERROR][2022-04-26 18:54:51] .../vim/lsp/rpc.lua:420 "rpc" "cucumber-language-server" "stderr" 'Error [ERR_REQUIRE_ESM]: Must use import to load ES Module: /home/issafalcon/.local/share/nvim/lsp_servers/cucumber_language_server/node_modules/@cucumber/language-server/dist/cjs/src/startServer.js\nrequire() of ES modules is not supported.\nrequire() of /home/issafalcon/.local/share/nvim/lsp_servers/cucumber_language_server/node_modules/@cucumber/language-server/dist/cjs/src/startServer.js from /home/issafalcon/.local/share/nvim/lsp_servers/cucumber_language_server/node_modules/@cucumber/language-server/bin/cucumber-language-server.cjs is an ES module file as it is a .js file whose nearest parent package.json contains "type": "module" which defines all .js files in that package scope as ES modules.\nInstead rename startServer.js to end in .cjs, change the requiring code to use import(), or remove "type": "module" from /home/issafalcon/.local/share/nvim/lsp_servers/cucumber_language_server/node_modules/@cucumber/language-server/package.json.\n\n at Object.Module._extensions..js (internal/modules/cjs/loader.js:1089:13)\n at Module.load (internal/modules/cjs/loader.js:937:32)\n at Function.Module._load (internal/modules/cjs/loader.js:778:12)\n at Module.require (internal/modules/cjs/loader.js:961:19)\n at require (internal/modules/cjs/helpers.js:92:18)\n at Object.<anonymous> (/home/issafalcon/.local/share/nvim/lsp_servers/cucumber_language_server/node_modules/@cucumber/language-server/bin/cucumber-language-server.cjs:3:25)\n at Module._compile (internal/modules/cjs/loader.js:1072:14)\n at Object.Module._extensions..js (internal/modules/cjs/loader.js:1101:10)\n at Module.load (internal/modules/cjs/loader.js:937:32)\n at Function.Module._load (internal/modules/cjs/loader.js:778:12)\n'

โœ… What did you expect to see?

The lsp client should load correctly without errors

๐Ÿ“ฆ Which tool/library version are you using?

Latest version (0.6.0) of cucumber_language_server. Neovim 0.7.0

๐Ÿ”ฌ How could we reproduce it?

Steps to reproduce the behavior:

  1. Attempt to run the cucumber_language_server script

๐Ÿ“š Any additional context?


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

Workspace configuration file support for settings

๐Ÿค” What's the problem you're trying to solve?

The features and glue settings in the language server are only configurable in the configuration sent during the startup process. However, almost all clients only support sending them in the global settings. This forces users to declare all possible styles to ensure that features and glue work as expected. Additionally, this can reduce performance when the search pattern is extensive, and conflicts may arise in the groups at times.

โœจ What's your proposed solution?

Provide a way to set configurations at the workspace level. We can reuse the cucumber.json settings file from cucumber.js.

โ› Have you considered any alternatives or workarounds?

Alternatively, we can add a configuration file like cucumber-config.json, inspired by jsconfig.json of TypeScript, which does nothing except providing IDE support.

๐Ÿ“š Any additional context?

None


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

cucumber-language-server fails to start up

Describe the bug

I am attempting to get the language-server setup for use in neovim. However, it fails to start up with the following error.

โฏ cucumber-language-server
file:///usr/local/lib/node_modules/@cucumber/language-server/bin/cucumber-language-server.js:2
require('source-map-support').install()
^

ReferenceError: require is not defined in ES module scope, you can use import instead
This file is being treated as an ES module because it has a '.js' file extension and '/usr/local/lib/node_modules/@cucumber/language-server/package.json' contains "type": "module". To treat it as a CommonJS script, rename it to use the '.cjs' file extension.
    at file:///usr/local/lib/node_modules/@cucumber/language-server/bin/cucumber-language-server.js:2:1
    at ModuleJob.run (node:internal/modules/esm/module_job:185:25)
    at async Promise.all (index 0)
    at async ESMLoader.import (node:internal/modules/esm/loader:281:24)
    at async loadESM (node:internal/process/esm_loader:88:5)
    at async handleMainPromise (node:internal/modules/run_main:65:12)

Node.js v17.0.1

This is being run on the (most recent?) released version.

โฏ bat package.json | grep version
  "version": "0.3.1",

The package was installed via npm.

โฏ npm install -g @cucumber/language-server

To Reproduce
Steps to reproduce the behavior:

  1. Run the server (i.e. cucumber-language-server)

Expected behavior
The server should start up without errors.

Screenshots
N/A

Desktop (please complete the following information):

  • OS: macOS Monterey

Smartphone (please complete the following information):
N/A

Additional context
N/A

Can't load language parsers in combination with Neovim

๐Ÿ‘“ What did you see?

Hello. I am trying to use cucumber_language_server in combination with NeoVim (specifically LunarVim). Here is the related LSP configuration:

require("lvim.lsp.manager").setup("cucumber_language_server", {
  settings = {
    cucumber = {
      features = { 'features/**/*.feature' },
      glue = { 'features/step_definitions/*.rb', 'features/step_definitions/*.ts' }
    }
  }
})

This configuration is correctly passed to cucumber_language_server. The features & glue are correctly loaded (I can see this in the logs).

The problem is that the step definitions are not able to be parsed. There are many errors related to this in my LSP logs. I have attached my logs in this bug report, see the bottom of this issue. I think the following line tells us that the Ruby parser (or any other language parser) can not be loaded:

ENOENT: no such file or directory, open 'file:///Users/pawel/.local/share/nvim/mason/packages/cucumber-language-server/node_modules/@cucumber/language-server/node_modules/@cucumber/language-service/dist/ruby.wasm'

It is very strange that this file can not be loaded, because I have manually confirmed that the ruby.wasm file exists in exactly that directory.

At the bottom of the log file you can see that there are errors when trying to parse the Ruby file containing the step definition:

[ERROR][2022-11-09 19:34:43] ...lsp/handlers.lua:484    "* Step Definition errors: Error: Parsing failed
uri: file:///Users/pawel/Projects/cucumber_test/features/step_definitions/test.rb
language: ruby

    at Parser.parse (/Users/pawel/.local/share/nvim/mason/packages/cucumber-language-server/node_modules/@cucumber/language-server/node_modules/web-tree-sitter/tree-sitter.js:1:38190)
    at SourceAnalyzer.parse (/Users/pawel/.local/share/nvim/mason/packages/cucumber-language-server/node_modules/@cucumber/language-server/node_modules/@cucumber/language-service/src/language/SourceAnalyzer.ts:139:72)
    at SourceAnalyzer.getSourceMatches (/Users/pawel/.local/share/nvim/mason/packages/cucumber-language-server/node_modules/@cucumber/language-server/node_modules/@cucumber/language-service/src/language/SourceAnalyzer.ts:107:21)
    at SourceAnalyzer.eachParameterTypeLink (/Users/pawel/.local/share/nvim/mason/packages/cucumber-language-server/node_modules/@cucumber/language-server/node_modules/@cucumber/language-service/src/language/SourceAnalyzer.ts:35:39)
    at ExpressionBuilder.build (/Users/pawel/.local/share/nvim/mason/packages/cucumber-language-server/node_modules/@cucumber/language-server/node_modules/@cucumber/language-service/src/language/ExpressionBuilder.ts:45:20)
    at CucumberLanguageServer.<anonymous> (/Users/pawel/.local/share/nvim/mason/packages/cucumber-language-server/node_modules/@cucumber/language-server/src/CucumberLanguageServer.ts:417:59)
    at Generator.next (<anonymous>)
    at fulfilled (/Users/pawel/.local/share/nvim/mason/packages/cucumber-language-server/node_modules/@cucumber/language-server/dist/cjs/src/CucumberLanguageServer.js:5:58)"

My intuition tells me that the step definition can not be parsed because the Ruby parser is not loaded somehow.

I have opened the same folder in VSCode, and the LSP works fine there. The logs are a bit different from my Neovim LSP logs, though.

โœ… What did you expect to see?

The step definition file is correctly parsed, and I get full LSP support in Neovim

๐Ÿ“ฆ Which tool/library version are you using?

cucumber_language_server 1.1.1

๐Ÿ”ฌ How could we reproduce it?

The easiest way to reproduce it would be to install LunarVim. Note: This error is not unique to LunarVim. LunarVim is a custom NeoVim distro that uses nvim-lsp to connect to language servers. This problem will probably occur on any NeoVim distro.

  1. Create the following file structure:
repro_example
|- features
          |- step_definitions
          |              |- test.rb
          |- test.feature
  1. test.feature content:
Feature: Test
  Scenario: A test scenario
    Given a step definition
  1. test.rb content:
Given('a step definition') do
  puts 'Hello World'
end
  1. Install LunarVim
  2. Edit ~/.config/lvim/config.lua and add the following LSP configuration:
require("lvim.lsp.manager").setup("cucumber_language_server", {
  settings = {
    cucumber = {
      features = { 'features/**/*.feature' },
      glue = { 'features/step_definitions/*.rb', 'features/step_definitions/*.ts' }
    }
  }
})
  1. Use lvim to open LunarVim
  2. Type :LspInstall cucumber and select cucumber_language_server
  3. Wait for it to install, then quit LunarVim
  4. Open test.feature in LunarVim in your shell using lvim test.feature
  5. Assert that the steps are undefined and they don't work.

Logs can be found in ~/local/state/nvim/lsp.log.

๐Ÿ“š Any additional context?

lsp.log


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

Handling *.mts files

๐Ÿค” What's the problem you're trying to solve?

Currently *.mts files (and probably *.mjs, *.cjs and *.cts) are ignored as glue files:

[Info  - 5:31:37 PM] * Found 2 feature file(s) in ["features/**/*.feature"]
[Info  - 5:31:37 PM] * Found 50 steps in those feature files
[Info  - 5:31:37 PM] * Found 0 glue file(s) in ["features/step-definitions/**/*.mts"]
[Info  - 5:31:37 PM] * Found 0 parameter types in those glue files
[Info  - 5:31:37 PM] * Found 0 step definitions in those glue files

โœจ What's your proposed solution?

To add those files extensions to the supported ones, I think it should probably be added in https://github.com/cucumber/language-server/blob/main/src/fs.ts and https://github.com/cucumber/language-server/blob/main/src/CucumberLanguageServer.ts to support those file extensions.

โ› Have you considered any alternatives or workarounds?

Yes, to use simple ts files but I would prefer to keep .mts files

๐Ÿ“š Any additional context?

-


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

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Open

These updates have all been created already. Click a checkbox below to force a retry/rebase of any.

Detected dependencies

github-actions
.github/workflows/release-github.yml
  • actions/checkout v4
  • cucumber/action-create-github-release v1.1.1
.github/workflows/release-npm.yml
  • actions/checkout v4
  • actions/setup-node v4
  • cucumber/action-publish-npm v1.1.1
.github/workflows/test-javascript.yml
  • actions/checkout v4
  • actions/setup-node v4
npm
node/package.json
package.json
  • @cucumber/gherkin-utils ^8.0.2
  • @cucumber/language-service ^1.4.0
  • fast-glob 3.3.2
  • source-map-support 0.5.21
  • vscode-languageserver 8.0.2
  • vscode-languageserver-textdocument 1.0.11
  • vscode-languageserver-types 3.17.5
  • @cucumber/cucumber 10.3.1
  • @types/mocha 10.0.6
  • @types/node 20.11.30
  • @typescript-eslint/eslint-plugin 7.3.1
  • @typescript-eslint/parser 7.3.1
  • eslint 8.57.0
  • eslint-config-prettier 9.1.0
  • eslint-plugin-import 2.29.1
  • eslint-plugin-n 16.6.2
  • eslint-plugin-prettier 5.1.3
  • eslint-plugin-simple-import-sort 12.0.0
  • husky 9.0.11
  • lint-staged ^15.2.0
  • mocha 10.3.0
  • npm-check-updates 16.14.17
  • prettier 3.2.5
  • ts-node 10.9.2
  • typescript 5.4.3
  • vscode-jsonrpc 8.2.0
  • vscode-languageserver-protocol 3.17.2
  • node >=16.0.0
wasm/package.json

  • Check this box to trigger a request for Renovate to run again on this repository

Getting undefined step while using nvim with mason

Hi, I have installed the languages server via mason. And getting undefined step. Anyone having the same issue? I assume is my setup issue, I can see the LS is running when i fire up my .feature file. But getting the undefined steps for all the steps.

Any help is welcome. :D

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.