Skip to content

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

@pprotas

Description

@pprotas

👓 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.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions