cucumber / language-server

Cucumber Language Server
MIT License
35 stars 20 forks source link

Support workspace/didChangeConfiguration request #44

Closed shth closed 2 years ago

shth commented 2 years ago

πŸ€” 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.

richardbagshaw commented 2 years ago

I've also been experiencing this, no matter what configuration I add, the LSP can't seem to pair the feature files and the context / glue files together.

aurelien-reeves commented 2 years ago

I may say something terribly wrong, but I'll give it a try πŸ˜…β€‹

In vscode, the settings "features" and "glue" are arrays, not plain object. Is it different here?

shth commented 2 years ago

@aurelien-reeves so workspace/didChangeConfiguration reqeuest is supported right now?

aurelien-reeves commented 2 years ago

Yes, didChangeConfiguration should be supported. What I was saying is that your configuration seems to be wrong.

Try to replace your plain object with an array:

settings = {
-        features= {'features/**/*.feature'},
+        features= ['features/**/*.feature'],
-        glue = {'src/Behat/*.php'}
+        glue = ['src/Behat/*.php']
    }
aslakhellesoy commented 2 years ago

@shth what kind of syntax is this? It resembles JSON, but looks different. Is it something from Vim?

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

Does {'features/**/*.feature'} mean "array with one element"? Where are you specifying that these settings are to be picked up by the Cucumber Language Server?

aslakhellesoy commented 2 years ago

There are some nvim docs for cucumber-language-server (presumably generated by a script/bot).

Although it's absent from these docs, other language servers have an init_options section and a settings section. Do you have something like this?

require'lspconfig'.cucumber_language_server.setup{
  settings = {
    features= { "features/**/*.feature" },
    glue = { "src/Behat/*.php" }
  }
}
shth commented 2 years ago

@aslakhellesoy here's what my config looks like. The syntax is lua syntax, which is used by neovim.

require("lvim.lsp.manager").setup("cucumber_language_server", {
    cmd = { "cucumber-language-server", "--stdio" },
    filetypes = { "cucumber", "feature" },
    root_dir = require("lspconfig").util.find_git_ancestor,
    settings = {
        features= {'features/**/*.feature'},
        glue = {'src/Behat/*.php'}
    }
})

features= { "features/**/*.feature" } should equal features: [ "features/**/*.feature" ] in json, but I have yet to confirm with downstream if the lsp client actually emits array.

aslakhellesoy commented 2 years ago

Thanks @shth. Would you be able to:

  1. clone this repo
  2. add some logging statements (*)
  3. build the language server
  4. Try with the local version

(*) Add logging statements above and below this line: https://github.com/cucumber/language-server/blob/1641d3612bcbea8e7fe51e2cd05198b2a1289703/src/CucumberLanguageServer.ts#L65

this.connection.console.info('*** client supports workspace/configuration')
connection.onDidChangeConfiguration((params) => {
  this.connection.console.info(`*** client supplied configuration: JSON.stringify(params, null, 2)`)
  this.reindex(<Settings>params.settings).catch((err) => {
    connection.console.error(`Failed to reindex: ${err.stack}`)
  })
})

Then share the logging output in this ticket? Thanks!

aurelien-reeves commented 2 years ago

... The syntax is lua syntax, which is used by neovim.

Sorry for the confusion :(

aslakhellesoy commented 2 years ago

@shth have you tried cucumber instead of cucumber_language_server?

aslakhellesoy commented 2 years ago

Also, please try the latest version (I published 12.2.1 today)

shth commented 2 years ago

@aurelien-reeves no worries!

@aslakhellesoy The log message confirms that it is an array

[DEBUG][2022-05-30 18:17:20] .../vim/lsp/rpc.lua:454    "rpc.receive"   {  jsonrpc = "2.0",  method = "window/logMessage",  params = {    message = '*** client supplied configuration: {\n  "settings": {\n    "glue": [\n      "src/Behat/*.php"\n    ],\n    "features": [\n      "features/**/*.feature"\n    ]\n  }\n}',    type = 3  }}

However, I think the glue files are loaded properly after updating to 0.12.9. Thanks! I'm closing it now

[TRACE][2022-05-30 18:20:25] .../lua/vim/lsp.lua:792    "notification"  "window/logMessage" {  message = '* Found 13 glue file(s) in ["src/Behat/*.php"]',  type = 3}
[TRACE][2022-05-30 18:20:25] ...lsp/handlers.lua:487    "default_handler"   "window/logMessage" {  ctx = '{\n  client_id = 1,\n  method = "window/logMessage"\n}',  result = {    message = '* Found 13 glue file(s) in ["src/Behat/*.php"]',    type = 3  }}
[INFO][2022-05-30 18:20:25] ...lsp/handlers.lua:458 '* Found 13 glue file(s) in ["src/Behat/*.php"]'