cucumber / language-server

Cucumber Language Server
MIT License
36 stars 20 forks source link

Can't load language parsers in combination with Neovim #72

Closed pprotas closed 8 months ago

pprotas commented 2 years ago

šŸ‘“ 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
  2. test.feature content:
    Feature: Test
    Scenario: A test scenario
    Given a step definition
  3. test.rb content:
    Given('a step definition') do
    puts 'Hello World'
    end
  4. Install LunarVim
  5. 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' }
    }
    }
    })
  6. Use lvim to open LunarVim
  7. Type :LspInstall cucumber and select cucumber_language_server
  8. Wait for it to install, then quit LunarVim
  9. Open test.feature in LunarVim in your shell using lvim test.feature
  10. 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.

pluma9 commented 2 years ago

I'm facing this same error in C# .NET project. I'm using Neovim. It works fine in Visual Studio (with the SpecFlow for Visual Studio 2022 extension installed).

[START][2022-11-20 21:26:33] LSP logging initiated
[ERROR][2022-11-20 21:26:33] .../vim/lsp/rpc.lua:733    "rpc"   "cmd.exe"   "stderr"    "Failed to load file:///C:/Users/pluma9/AppData/Roaming/npm/node_modules/@cucumber/language-server/node_modules/@cucumber/language-service/dist/java.wasm: ENOENT: no such file or directory, open 'file:///C:/Users/pluma9/AppData/Roaming/npm/node_modules/@cucumber/language-server/node_modules/@cucumber/language-service/dist/java.wasm'\n"
[ERROR][2022-11-20 21:26:33] .../vim/lsp/rpc.lua:733    "rpc"   "cmd.exe"   "stderr"    "Failed to load file:///C:/Users/pluma9/AppData/Roaming/npm/node_modules/@cucumber/language-server/node_modules/@cucumber/language-service/dist/tsx.wasm: ENOENT: no such file or directory, open 'file:///C:/Users/pluma9/AppData/Roaming/npm/node_modules/@cucumber/language-server/node_modules/@cucumber/language-service/dist/tsx.wasm'\nFailed to load file:///C:/Users/pluma9/AppData/Roaming/npm/node_modules/@cucumber/language-server/node_modules/@cucumber/language-service/dist/c_sharp.wasm: ENOENT: no such file or directory, open 'file:///C:/Users/pluma9/AppData/Roaming/npm/node_modules/@cucumber/language-server/node_modules/@cucumber/language-service/dist/c_sharp.wasm'\n"
[ERROR][2022-11-20 21:26:33] .../vim/lsp/rpc.lua:733    "rpc"   "cmd.exe"   "stderr"    "Failed to load file:///C:/Users/pluma9/AppData/Roaming/npm/node_modules/@cucumber/language-server/node_modules/@cucumber/language-service/dist/php.wasm: ENOENT: no such file or directory, open 'file:///C:/Users/pluma9/AppData/Roaming/npm/node_modules/@cucumber/language-server/node_modules/@cucumber/language-service/dist/php.wasm'\nFailed to load file:///C:/Users/pluma9/AppData/Roaming/npm/node_modules/@cucumber/language-server/node_modules/@cucumber/language-service/dist/python.wasm: ENOENT: no such file or directory, open 'file:///C:/Users/pluma9/AppData/Roaming/npm/node_modules/@cucumber/language-server/node_modules/@cucumber/language-service/dist/python.wasm'\n"
[ERROR][2022-11-20 21:26:33] .../vim/lsp/rpc.lua:733    "rpc"   "cmd.exe"   "stderr"    "Failed to load file:///C:/Users/pluma9/AppData/Roaming/npm/node_modules/@cucumber/language-server/node_modules/@cucumber/language-service/dist/ruby.wasm: ENOENT: no such file or directory, open 'file:///C:/Users/pluma9/AppData/Roaming/npm/node_modules/@cucumber/language-server/node_modules/@cucumber/language-service/dist/ruby.wasm'\nFailed to load file:///C:/Users/pluma9/AppData/Roaming/npm/node_modules/@cucumber/language-server/node_modules/@cucumber/language-service/dist/rust.wasm: ENOENT: no such file or directory, open 'file:///C:/Users/pluma9/AppData/Roaming/npm/node_modules/@cucumber/language-server/node_modules/@cucumber/language-service/dist/rust.wasm'\n"
[WARN][2022-11-20 21:26:33] ...lsp/handlers.lua:113 "The language server cucumber_language_server triggers a registerCapability handler despite dynamicRegistration set to false. Report upstream, this warning is harmless"
[ERROR][2022-11-20 21:26:33] ...lsp/handlers.lua:485    "Failed to reindex: Cannot read properties of undefined (reading 'reduce')"
[ERROR][2022-11-20 21:26:33] ...lsp/handlers.lua:485    "Failed to reindex: Cannot read properties of undefined (reading 'reduce')"
[ERROR][2022-11-20 21:26:33] ...lsp/handlers.lua:485    "* Step Definition errors: Error: Parsing failed\nuri: file:///D:/demo/CucumberDemo/Features/login/login.feature.cs\nlanguage: c_sharp\n\n    at Parser.parse (C:\\Users\\pluma9\\AppData\\Roaming\\npm\\node_modules\\@cucumber\\language-server\\node_modules\\web-tree-sitter\\tree-sitter.js:1:38190)\n    at SourceAnalyzer.parse (C:\\Users\\pluma9\\AppData\\Roaming\\npm\\node_modules\\@cucumber\\language-server\\node_modules\\@cucumber\\language-service\\src\\language\\SourceAnalyzer.ts:139:72)\n    at SourceAnalyzer.getSourceMatches (C:\\Users\\pluma9\\AppData\\Roaming\\npm\\node_modules\\@cucumber\\language-server\\node_modules\\@cucumber\\language-service\\src\\language\\SourceAnalyzer.ts:107:21)\n    at SourceAnalyzer.eachParameterTypeLink (C:\\Users\\pluma9\\AppData\\Roaming\\npm\\node_modules\\@cucumber\\language-server\\node_modules\\@cucumber\\language-service\\src\\language\\SourceAnalyzer.ts:35:39)\n    at ExpressionBuilder.build (C:\\Users\\pluma9\\AppData\\Roaming\\npm\\node_modules\\@cucumber\\language-server\\node_modules\\@cucumber\\language-service\\src\\language\\ExpressionBuilder.ts:45:20)\n    at CucumberLanguageServer.<anonymous> (C:\\Users\\pluma9\\AppData\\Roaming\\npm\\node_modules\\@cucumber\\language-server\\src\\CucumberLanguageServer.ts:417:59)\n    at Generator.next (<anonymous>)\n    at fulfilled (C:\\Users\\pluma9\\AppData\\Roaming\\npm\\node_modules\\@cucumber\\language-server\\dist\\cjs\\src\\CucumberLanguageServer.js:5:58)"
[ERROR][2022-11-20 21:26:33] ...lsp/handlers.lua:485    "* Step Definition errors: Error: Parsing failed\nuri: file:///D:/demo/CucumberDemo/Features/login/login.feature.cs\nlanguage: c_sharp\n\n    at Parser.parse (C:\\Users\\pluma9\\AppData\\Roaming\\npm\\node_modules\\@cucumber\\language-server\\node_modules\\web-tree-sitter\\tree-sitter.js:1:38190)\n    at SourceAnalyzer.parse (C:\\Users\\pluma9\\AppData\\Roaming\\npm\\node_modules\\@cucumber\\language-server\\node_modules\\@cucumber\\language-service\\src\\language\\SourceAnalyzer.ts:139:72)\n    at SourceAnalyzer.getSourceMatches (C:\\Users\\pluma9\\AppData\\Roaming\\npm\\node_modules\\@cucumber\\language-server\\node_modules\\@cucumber\\language-service\\src\\language\\SourceAnalyzer.ts:107:21)\n    at SourceAnalyzer.eachStepDefinitionExpression (C:\\Users\\pluma9\\AppData\\Roaming\\npm\\node_modules\\@cucumber\\language-server\\node_modules\\@cucumber\\language-service\\src\\language\\SourceAnalyzer.ts:80:40)\n    at ExpressionBuilder.build (C:\\Users\\pluma9\\AppData\\Roaming\\npm\\node_modules\\@cucumber\\language-server\\node_modules\\@cucumber\\language-service\\src\\language\\ExpressionBuilder.ts:51:20)\n    at CucumberLanguageServer.<anonymous> (C:\\Users\\pluma9\\AppData\\Roaming\\npm\\node_modules\\@cucumber\\language-server\\src\\CucumberLanguageServer.ts:417:59)\n    at Generator.next (<anonymous>)\n    at fulfilled (C:\\Users\\pluma9\\AppData\\Roaming\\npm\\node_modules\\@cucumber\\language-server\\dist\\cjs\\src\\CucumberLanguageServer.js:5:58)"
[WARN][2022-11-20 21:26:33] .../lua/vim/lsp.lua:1072    "server_request: no handler found for"  "workspace/semanticTokens/refresh"
[ERROR][2022-11-20 21:26:33] ...lsp/handlers.lua:485    "Cucumber Language Server 1.2.0: Unhandled Rejection at promise: [object Promise], reason: Error: MethodNotFound"
[ERROR][2022-11-20 21:26:36] ...lsp/handlers.lua:485    "* Step Definition errors: Error: Parsing failed\nuri: file:///D:/demo/CucumberDemo/Features/login/login.feature.cs\nlanguage: c_sharp\n\n    at Parser.parse (C:\\Users\\pluma9\\AppData\\Roaming\\npm\\node_modules\\@cucumber\\language-server\\node_modules\\web-tree-sitter\\tree-sitter.js:1:38190)\n    at SourceAnalyzer.parse (C:\\Users\\pluma9\\AppData\\Roaming\\npm\\node_modules\\@cucumber\\language-server\\node_modules\\@cucumber\\language-service\\src\\language\\SourceAnalyzer.ts:139:72)\n    at SourceAnalyzer.getSourceMatches (C:\\Users\\pluma9\\AppData\\Roaming\\npm\\node_modules\\@cucumber\\language-server\\node_modules\\@cucumber\\language-service\\src\\language\\SourceAnalyzer.ts:107:21)\n    at SourceAnalyzer.eachParameterTypeLink (C:\\Users\\pluma9\\AppData\\Roaming\\npm\\node_modules\\@cucumber\\language-server\\node_modules\\@cucumber\\language-service\\src\\language\\SourceAnalyzer.ts:35:39)\n    at ExpressionBuilder.build (C:\\Users\\pluma9\\AppData\\Roaming\\npm\\node_modules\\@cucumber\\language-server\\node_modules\\@cucumber\\language-service\\src\\language\\ExpressionBuilder.ts:45:20)\n    at CucumberLanguageServer.<anonymous> (C:\\Users\\pluma9\\AppData\\Roaming\\npm\\node_modules\\@cucumber\\language-server\\src\\CucumberLanguageServer.ts:417:59)\n    at Generator.next (<anonymous>)\n    at fulfilled (C:\\Users\\pluma9\\AppData\\Roaming\\npm\\node_modules\\@cucumber\\language-server\\dist\\cjs\\src\\CucumberLanguageServer.js:5:58)"
[ERROR][2022-11-20 21:26:36] ...lsp/handlers.lua:485    "* Step Definition errors: Error: Parsing failed\nuri: file:///D:/demo/CucumberDemo/Features/login/login.feature.cs\nlanguage: c_sharp\n\n    at Parser.parse (C:\\Users\\pluma9\\AppData\\Roaming\\npm\\node_modules\\@cucumber\\language-server\\node_modules\\web-tree-sitter\\tree-sitter.js:1:38190)\n    at SourceAnalyzer.parse (C:\\Users\\pluma9\\AppData\\Roaming\\npm\\node_modules\\@cucumber\\language-server\\node_modules\\@cucumber\\language-service\\src\\language\\SourceAnalyzer.ts:139:72)\n    at SourceAnalyzer.getSourceMatches (C:\\Users\\pluma9\\AppData\\Roaming\\npm\\node_modules\\@cucumber\\language-server\\node_modules\\@cucumber\\language-service\\src\\language\\SourceAnalyzer.ts:107:21)\n    at SourceAnalyzer.eachStepDefinitionExpression (C:\\Users\\pluma9\\AppData\\Roaming\\npm\\node_modules\\@cucumber\\language-server\\node_modules\\@cucumber\\language-service\\src\\language\\SourceAnalyzer.ts:80:40)\n    at ExpressionBuilder.build (C:\\Users\\pluma9\\AppData\\Roaming\\npm\\node_modules\\@cucumber\\language-server\\node_modules\\@cucumber\\language-service\\src\\language\\ExpressionBuilder.ts:51:20)\n    at CucumberLanguageServer.<anonymous> (C:\\Users\\pluma9\\AppData\\Roaming\\npm\\node_modules\\@cucumber\\language-server\\src\\CucumberLanguageServer.ts:417:59)\n    at Generator.next (<anonymous>)\n    at fulfilled (C:\\Users\\pluma9\\AppData\\Roaming\\npm\\node_modules\\@cucumber\\language-server\\dist\\cjs\\src\\CucumberLanguageServer.js:5:58)"
[WARN][2022-11-20 21:26:36] .../lua/vim/lsp.lua:1072    "server_request: no handler found for"  "workspace/semanticTokens/refresh"
[ERROR][2022-11-20 21:26:36] ...lsp/handlers.lua:485    "Cucumber Language Server 1.2.0: Unhandled Rejection at promise: [object Promise], reason: Error: MethodNotFound"
lkoning commented 1 year ago

hello, I am facing the same issue when installing the cucumber-ls with Mason in Neovim. I found a branch 'fix-standalone', which seems to work, but stops working if I update it with master.

[ERROR][2022-12-16 10:19:37] .../vim/lsp/rpc.lua:733 "rpc" "cucumber-language-server" "stderr" "Error: Cannot find module '../src/version'\nRequire stack:\n- /home/laurens/.local/share/nvim/mason/packages/cucumber-language-server/node_modules/@cucumber/language-server/bin/cucumber-language-server.cjs\n at Function.Module._resolveFilename (node:internal/modules/cjs/loader:1039:15)\n at Function.Module._load (node:internal/modules/cjs/loader:885:27)\n at Module.require (node:internal/modules/cjs/loader:1105:19)\n at require (node:internal/modules/cjs/helpers:103:18)\n at Object.<anonymous> (/home/laurens/.local/share/nvim/mason/packages/cucumber-language-server/node_modules/@cucumber/language-server/bin/cucumber-language-server.cjs:7:21)\n at Module._compile (node:internal/modules/cjs/loader:1218:14)\n at Object.Module._extensions..js (node:internal/modules/cjs/loader:1272:10)\n at Module.load (node:internal/modules/cjs/loader:1081:32)\n at Function.Module._load (node:internal/modules/cjs/loader:922:12)\n at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:82:12)\n"

pprotas commented 1 year ago

hello, I am facing the same issue when installing the cucumber-ls with Mason in Neovim. I found a branch 'fix-standalone', which seems to work, but stops working if I update it with master.

Can you provide a guide on how you installed this branch on your machine?

lkoning commented 1 year ago

hello, I am facing the same issue when installing the cucumber-ls with Mason in Neovim. I found a branch 'fix-standalone', which seems to work, but stops working if I update it with master.

Can you provide a guide on how you installed this branch on your machine?

a bit...

  1. clone @cucumbe/language-server
  2. checkout branch 'fix-standalone'
  3. npm install / npm run build etc.
  4. then you can start it from cli with './bin/cucumber-language-server.cjs --stdio'
  5. use that as binary for lspconfig
jeeeem commented 1 year ago

Any update on this, did you found a workaround? I can't seem able to config this.

pprotas commented 1 year ago

Any update on this, did you found a workaround? I can't seem able to config this.

Nope, I didn't get it to work

binhtran432k commented 1 year ago

Hello everyone, I apologize for my lateness. I created a PR #74 to fix this problem a long time ago, but it has not been merged yet. Therefore, I am here to confirm that there is a package called @binhtran432k/cucumber-language-server. To install it globally and use it, simply run the command npm i -g @binhtran432k/cucumber-language-server. This package was created for my personal use and only works on older versions of Node.js. I hope this helps everyone here.