-
Notifications
You must be signed in to change notification settings - Fork 171
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bugfix: Recognise ERB files correctly in Neovim #2432
Conversation
These are reported as "eruby", not "erb", so we need to account for this.
I have signed the CLA! |
Confirming this patch corrects the errors seen in Neovim. |
I’ll also note the Rubocop warning I mentioned can be removed simply by telling Rubocop to ignore ERB files. Should Rubocop be able to successfully run in ERB files normally though? (i.e. am I missing out on some other functionality by doing that?) |
No, RuboCop should only run in Ruby files. We turn off diagnostics for ERB documents, but eventually we'd like to offer diagnostics + formatting through erb-lint.
Checking other Ruby language servers for NeoVim, it seems like it standardizes on |
Would it be possible to cut a release for this? If you are an erb enjoyer, this is a pretty disruptive bug :) |
Might be worth adjusting your nvim config temporarily to remove eruby from the filetype. Here's two examples, tho I wasn't able to test Mason directly because I only use it for managing non-Ruby LSPs. local lspconfig = require('lspconfig')
lspconfig.ruby_lsp.setup({
filetypes = { 'ruby' }
}) require('mason-lspconfig').setup_handlers {
function (server_name) -- default handler
require('lspconfig')[server_name].setup({})
end,
['ruby_lsp'] = function ()
require('lspconfig').ruby_lsp.setup({
filetypes = { 'ruby' },
})
end,
} |
Is this a regex issue, perhaps? If we need to narrow the diagnostics only between |
The parser is already aware of ERB formatted files. The issue corrected here was the filetype sent by vim/neovim wasn't the same filetype sent by the VSCode extension. |
Just cut a release with the fix https://github.com/Shopify/ruby-lsp/releases/tag/v0.17.13. To force the upgrade, you can either
No, this was a mismatch of the language ID for ERB documents expected by the server vs the one provided by NeoVim - which does not match the one used by VS Code. |
Just upgraded, everything works great, thank you to everyone involved :D |
Just to round out this PR, I checked Zed's support for the Ruby LSP and it appears that it sends |
When the Ruby LSP broadcasts its diagnostic capabilities, it scopes it to only Ruby files
Maybe NeoVim is not respecting the server's document selector for diagnostics? If that's the case, it's a NeoVim bug since the spec prescribes the possibility for the server to dictate which files it wants to handle for diagnostics. See Diagnostic registration options, which extends Text document registration options and allows for a document selector. In addition to correctness, this is important for performance reasons too. We don't want the client to keep sending requests that the server doesn't want to handle. VS Code respects the server selection and never sends diagnostic requests for ERB files. In terms of tactics on how to move forward with this, our 3 person team does not have NeoVim experience. My suggestion is to revert neovim/nvim-lspconfig#3266 and then someone with more NeoVim experience would need to do a more in depth investigation to understand what's not going right before shipping that configuration PR again (to avoid disruption for NeoVim users). |
Seems that neovim does indeed not yet support the needed interface neovim/neovim#24412 (the PR that added initial @vinistock as someone who has experience already implemented this on the VSCode side; would this be a big piece of work? Is this just something that is checked on startup then before every diagnostic request? In the meantime, I also agree that the PR should be reverted. |
I agree. I've submitted a PR to do so. |
Great job! I would really like this in, so I might look into what's needed at the weekend but no promises 😄 |
I don't have experience implementing the client side. The VS Code team provides an official package for the client side which implements the entire specification for us. We only implement the server side of the equation. I would imagine that the client needs to remember the document selector on a per feature basis since some of the features (if not all of them?) can have it overridden by the server. When receiving the response from the initialize request, it needs to go over the capabilities and adjust the document selectors according to what the server responded with. |
I see, thank you. That's cleared some of it up. 😄 |
Motivation
Though ruby-lsp supports ERB files, in Neovim these were either not being parsed at all, or, following this update to lspconfig, parsed as Ruby (with all the associated errors that brings).
Implementation
Checking for "eruby" as the filetype, as well as "erb" gets things working.
There is one caveat: I still have a single error in each file being thrown by Rubocop:
Lint/Syntax: unexpected token tLT This offense is not auto-correctable
. I presume this does not occur in VS Code but can’t see any code preventing Rubocop in ERB files, so would appreciate any thoughts on that. Still worth merging as-is, I believe, as it reduces a screen full of errors and no functionality to one error plus functionality.Automated Tests
Not applicable
Manual Tests
In VS Code there should be no change, in Neovim ERB HTML files should now be parsed correctly.