marcoroth/stimulus-lsp

False Positive - "bs" isn't a valid Stimulus controller. Did you mean "maps"?Stimulus LSP(stimulus.controller.invalid)

Closed this issue ยท 18 comments

fig commented

I'm using the Bootstrap CSS framework which uses data-bs-xxx attributes for some elements.
Stimulus LSP is picking these up and reporting them as "bs" isn't a valid Stimulus controller.

image

Thanks for reporting this one, @fig!

I'm not quite sure how and if we can solve this. But I'm wondering if we could have an option to maintain an "ignorelist" of identifiers for which Stimulus LSP shouldn't report warnings.

fig commented

@marcoroth , I'm afraid I don't have a clue either. ๐Ÿคท
I'm not very familiar with the internals of the JavaScript LSP space. Would it be possible to scan the internals to register "foreign" JS modules (or whatever they're called). An "ignorelist" sounds like a bit of a shotgun approach, to me.

Now I'm wondering, how does Stimulus deal with naming collisions with third party libraries?

fig commented

Ah, wait! Stimulus requires a data-controller to be declared in a parent element. Maybe this is the seam we are looking for? Stimulus-LSP should check parent nodes. Maybe it already does? Mind you, if we disregard targets outwith a related controller, that kind of negates the purpose of detecting unregistered Targets?
This is not shotgun surgery, It's a circular firing squad!

Looking for the data-controller attribute would only work if the controller is within the same file.

This might be given for most cases, but there's also the use-case where you have the controller elements in different views/partials/components.

Instead of a standard "ignorelist", maybe we can provide the LSP an "ignorelist" on initialization?

This has the benefit that we leave the choice of what to ignore to the client and it also sets up further customization in the future. It does require some more setup...

https://microsoft.github.io/language-server-protocol/specifications/specification-3-14/#workspace_configuration
https://microsoft.github.io/language-server-protocol/specifications/specification-3-14/#workspace_didChangeConfiguration

Did anyone work out a workaround for this? Thanks!

...suffering from the same issue. I tend to use "data-bs" quite a lot and I see quite a lot of red messages. Any ideas how to make stimulus-lsp ignore it (except uninstall stimulus-lsp)? Thanks

Same issue here. Any news? I think the ignorelist is the best way forward here. Any way to help?

I wanted to keep the LSP config-free so you don't have to check anything into the repo. But I guess an ignorelist only really works practically when it's checked in so teammates don't have to ignore the same controller identifiers all over again.

Or maybe we can offer both, like a per project ignorelist that just lives in your editor and isn't commited to the repo and one option where we would commit a file to the repo.

And we could ask the user which strategy they want to use whenever they are ignoring a controller identifier.

Hey @fig, @christopher-b, @pruzicka and @sandrods ๐Ÿ‘‹๐Ÿผ I just published v1.0.3 which allows to configure an ignorelist for HTML attributes and Controller identifiers through quick-fix actions. Let me know how that works for you, thank you!

https://github.com/marcoroth/stimulus-lsp/releases/tag/v1.0.3

fig commented

Works like a charm. Thank you very much.

Awsome, thanks for the quick feedback! ๐Ÿ™Œ๐Ÿผ

I'm getting an error "URI must contain a scheme" in nvim when trying to run the code actions:

[ERROR][2024-05-23 15:25:13] .../vim/lsp/rpc.lua:734  "rpc" "/home/cbennell/.local/share/nvim/mason/bin/stimulus-language-server" "stderr"  "/home/cbennell/.local/share/nvim/mason/packages/stimulus-language-searver/node_modules/stimulus-language-server/node_modules/vscode-jsonrpc/lib/common/connection.js:565
                        responsePromise.reject(new messages_1.ResponseError(error.code, error.message, error.data));
                                               ^

ResponseError: ...bin/squashfs-root/usr/share/nvim/runtime/lua/vim/uri.lua:107: URI must contain a scheme: /home/cbennell/src/ultima7/.stimulus-lsp/config.json
    at handleResponse (/home/cbennell/.local/share/nvim/mason/packages/stimulus-language-server/node_modules/stimulus-language-server/node_modules/vscode-jsonrpc/lib/common/connection.js:565:48)
    at handleMessage (/home/cbennell/.local/share/nvim/mason/packages/stimulus-language-server/node_modules/stimulus-language-server/node_modules/vscode-jsonrpc/lib/common/connection.js:345:13)
    at processMessageQueue (/home/cbennell/.local/share/nvim/mason/packages/stimulus-language-server/node_modules/stimulus-language-server/node_modules/vscode-jsonrpc/lib/common/connection.js:362:17)
    at Immediate.<anonymous> (/home/cbennell/.local/share/nvim/mason/packages/stimulus-language-server/node_modules/stimulus-language-server/node_modules/vscode-jsonrpc/lib/common/connection.js:334:13)
    at process.processImmediate (node:internal/timers:478:21) {
  code: -32603,
  data: undefined
}

Node.js v21.7.1

[ERROR][2024-05-23 15:25:13] .../lua/vim/lsp.lua:1085 "LSP[stimulus_ls]"  "on_error"  {  code = "SERVER_REQUEST_HANDLER_ERROR",  err = "...bin/squashfs-root/usr/share/nvim/runtime/lua/vim/uri.lua:107: URI must contain a scheme: /home/cbennell/src/ultima7/.stimulus-lsp/config.json"}

Is there any other info I can provide to help debug this?

Thanks for reporting @christopher-b, I opened #290 to address this! Going to release a patch version including that fix soon!

@christopher-b I published v1.0.4 to address this

fig commented

Thanks again, @marcoroth, for releasing and allowing us all to use this awesome tool. Thank you for responding to and supporting your community.
โค๏ธ

@christopher-b I published v1.0.4 to address this

Thank you, @marcoroth!

Thank you, for reporting back so quick! ๐Ÿ™Œ๐Ÿผ