Closed binhtran432k closed 4 months ago
Can you provide a guide on how to install this branch locally for my neovim config? Seems like it takes too long for the maintainer to merge it
This also fixes #79
Can you provide a guide on how to install this branch locally for my neovim config? Seems like it takes too long for the maintainer to merge it
@pprotas npm i -g @binhtran432k/cucumber-language-server@1.4.0
@binhtran432k after installing your fork from NPM I can get the language server to run without crashing immediately, but upon trying to use it with Neovim it logs the following:
Cucumber Language Server 1.4.0: Unhandled Rejection at promise: [object Promise], reason: TypeError: Failed to parse URL from /opt/homebrew/lib/node_modules/@binhtran432k/cucumber-language-server/node_modules/web-tree-sitter/tree-sitter.wasm
I added some code to log reason.stack()
at line 14 in bin/cucumber-language-server.cjs
and got the following output:
TypeError: Failed to parse URL from /opt/homebrew/lib/node_modules/@binhtran432k/cucumber-language-server/node_modules/web-tree-sitter/tree-sitter.wasm
at Object.fetch (node:internal/deps/undici/undici:11522:11)"
@binhtran432k after installing your fork from NPM I can get the language server to run without crashing immediately, but upon trying to use it with Neovim it logs the following:
Cucumber Language Server 1.4.0: Unhandled Rejection at promise: [object Promise], reason: TypeError: Failed to parse URL from /opt/homebrew/lib/node_modules/@binhtran432k/cucumber-language-server/node_modules/web-tree-sitter/tree-sitter.wasm
I added some code to log
reason.stack()
at line 14 inbin/cucumber-language-server.cjs
and got the following output:TypeError: Failed to parse URL from /opt/homebrew/lib/node_modules/@binhtran432k/cucumber-language-server/node_modules/web-tree-sitter/tree-sitter.wasm at Object.fetch (node:internal/deps/undici/undici:11522:11)"
Resolved by using Node 16
hi all, thank you for your work! I tried to use your lsp-version in my Lazyvim by your instructions:
return {
{
"neovim/nvim-lspconfig",
opts = {
servers = {
cucumber_language_server = {
-- currently using a forked ls.
mason = false,
root_dir = require("lspconfig.util").root_pattern("pom.xml"),
settings = {
cucumber = {
features = { "**/*.feature" },
glue = { "**/*Steps.java" },
},
},
},
},
},
},
}
Now, after loading my Java repo, or a JS repo...LSP seems to be active but formatting and finding stepDefs does not work. Haven't tried Vscode.
LspLog:
[START][2023-11-14 10:18:12] LSP logging initiated
[WARN][2023-11-14 10:18:12] ...lsp/handlers.lua:137 "The language server cucumber_language_server triggers a registerCapability handler despite dynamicRegistration set to false. Report upstream, this warning is harmless"
[ERROR][2023-11-14 10:18:12] ...lsp/handlers.lua:535 "Failed to reindex: Cannot read properties of undefined (reading 'reduce')"
[ERROR][2023-11-14 10:18:12] ...lsp/handlers.lua:535 "Failed to reindex: Cannot read properties of undefined (reading 'reduce')"
I don't really know what this means. At least it seems we are a few steps further.
hi all, thank you for your work! I tried to use your lsp-version in my Lazyvim by your instructions:
- Install the lsp locally - ✅
- Config Lazyvim:
return { { "neovim/nvim-lspconfig", opts = { servers = { cucumber_language_server = { -- currently using a forked ls. mason = false, root_dir = require("lspconfig.util").root_pattern("pom.xml"), settings = { cucumber = { features = { "**/*.feature" }, glue = { "**/*Steps.java" }, }, }, }, }, }, }, }
Now, after loading my Java repo, or a JS repo...LSP seems to be active but formatting and finding stepDefs does not work. Haven't tried Vscode.
LspLog:
[START][2023-11-14 10:18:12] LSP logging initiated [WARN][2023-11-14 10:18:12] ...lsp/handlers.lua:137 "The language server cucumber_language_server triggers a registerCapability handler despite dynamicRegistration set to false. Report upstream, this warning is harmless" [ERROR][2023-11-14 10:18:12] ...lsp/handlers.lua:535 "Failed to reindex: Cannot read properties of undefined (reading 'reduce')" [ERROR][2023-11-14 10:18:12] ...lsp/handlers.lua:535 "Failed to reindex: Cannot read properties of undefined (reading 'reduce')"
I don't really know what this means. At least it seems we are a few steps further.
I have the same problem myself, I also get Undefined step everywhere
Using the branch npm i -g @binhtran432k/cucumber-language-server@1.4.0
i was able to configure my lsp with config:
{
cmd = { "~/.nvm/versions/node/v16.20.2/bin/cucumber-language-server", "--stdio" },
settings = {
cucumber = {
cucumber = {
features = { "**/*.feature" },
glue = { "**/*Step*.java" },
}
}
},
on_attach = function(client, bufnr)
print("attached to cucumber file")
vim.keymap.set('n', "gd", vim.lsp.buf.definition, { buffer = 0 })
vim.keymap.set('n', "gn", vim.diagnostic.goto_next, { buffer = 0 })
vim.keymap.set('n', "gb", vim.diagnostic.goto_prev, { buffer = 0 })
end
}
I managed to get it working with a little hacking using nvim v0.9.1
on macOS Sonoma 14.2.1.
Although I only tested with @cucumber/language-server@1.2.0
since that's the version the Mason
Registry provides.
Since tree-sitter
currently crashes on node > 19 I reinstalled the dependencies using node v16.17.0 and patched the bin-script to use the node-server instead of the wasm-server.
So if anyone using nvim
, lspconfig
and Mason
comes, here this is a temporary workaround.
//cucumber-language-server/node_modules/.bin/cucumber-language-server
#!/change/this/path/to/v16.17.0/bin/node
/* eslint-disable @typescript-eslint/no-var-requires */
require('source-map-support').install()
const url = require('url')
const { startNodeServer, NodeFiles } = require('@cucumber/language-server/node')
const wasmBaseUrl = url.pathToFileURL(
`file:///${__dirname}/../node_modules/@cucumber/language-service/dist`
)
startNodeServer(wasmBaseUrl.href, (rootUri) => new NodeFiles(rootUri))
Another detail I had to add was to double up the lspconfig
settings and pass empty parameterTypes to prevent some errors from @cucumber/language-service
require("lspconfig").cucumber_language_server.setup({
settings = {
cucumber = {
features = { "**/*.feature" },
glue = { "**/*.steps.ts" },
parameterTypes = {},
},
features = { "**/*.feature" },
glue = { "**/*.steps.ts" },
parameterTypes = {},
},
})
I managed to get it working with a little hacking using
nvim v0.9.1
on macOS Sonoma 14.2.1. Although I only tested with@cucumber/language-server@1.2.0
since that's the version theMason
Registry provides.Since
tree-sitter
currently crashes on node > 19 I reinstalled the dependencies using node v16.17.0 and patched the bin-script to use the node-server instead of the wasm-server.So if anyone using
nvim
,lspconfig
andMason
comes, here this is a temporary workaround.//cucumber-language-server/node_modules/.bin/cucumber-language-server #!/change/this/path/to/v16.17.0/bin/node /* eslint-disable @typescript-eslint/no-var-requires */ require('source-map-support').install() const url = require('url') const { startNodeServer, NodeFiles } = require('@cucumber/language-server/node') const wasmBaseUrl = url.pathToFileURL( `file:///${__dirname}/../node_modules/@cucumber/language-service/dist` ) startNodeServer(wasmBaseUrl.href, (rootUri) => new NodeFiles(rootUri))
Another detail I had to add was to double up the
lspconfig
settings and pass empty parameterTypes to prevent some errors from@cucumber/language-service
require("lspconfig").cucumber_language_server.setup({ settings = { cucumber = { features = { "**/*.feature" }, glue = { "**/*.steps.ts" }, parameterTypes = {}, }, features = { "**/*.feature" }, glue = { "**/*.steps.ts" }, parameterTypes = {}, }, })
Hi @kumpan-david, thank you again for your help. Unfortunately, a significant refactor implemented after v1.2.0 makes reverting to that version impractical. However, I'm glad to report that this fix works with the latest version. I appreciate your understanding.
Hi @kieran-ryan,
I've pushed new commits that accomplish the following:
Testing:
Unit Testing:
External VSCode Usage:
Please review the changes and let me know if you have any questions or feedback.
@binhtran432k from a fellow neovim user, thank you so much! I was able to get a working cucumber-language-server by installing your branch! I am using node 18.19.0 and neovim 0.9.5
This issue has been bugging me for months!
Any chance this can get merged anytime soon?
@kieran-ryan, Thank you for your review. I have just completed the requested changes.
Thanks everyone 🙏 this is a life saver
v1.5.0 is now available 🚀
🤔 What's changed?
⚡️ What's your motivation?
Fixes #72, #79, #90, #96
🏷️ What kind of change is this?
♻️ Anything particular you want feedback on?
First, The
url.pathToFileURL
was introduced by #68 to fix #66 but it did not fix the problem and #66 was closed by using another product.After that, the #73 change how
language-server
worked. It refactorsrc/wasm/startWasmServer.ts
intosrc/wasm/startEmbeddedServer.ts
andsrc/wasm/startStandaloneServer.ts
. ThestartEmbeddedServer
is used for VS Code with browser support and thestartStandaloneServer
is used as fallback for user outside of VS Code but it was not tested properly.As a result, the language server is rendered unusable outside of VS Code, and this PR aims to rectify this issue.
📋 Checklist:
This text was originally generated from a template, then edited by hand. You can modify the template here.