-
Notifications
You must be signed in to change notification settings - Fork 213
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
LSP: Autoformat on save in neovim #575
Comments
hey @will would you be so kind as to look at this? |
I've taken a closer look at this, it's not just autoformat on save, it's the formatting of the buffer that has this bug (that is, it doesn't have to be called in a BufWritePre to reproduce). If that helps (I'm not a ruby expert, nor an LSP one!), when I tweak that line https://github.com/standardrb/standard/blob/main/lib/standard/lsp/routes.rb#L163 for this:
formatting does work. It seems like for some reason, it receives a |
@mna after testing this |
@fernandes oh no, for sure, I didn't mean that this was a workaround (and even less a fix)! Just that it illustrates that for some reason, the |
@mna it formats for me on nvim 0.9.1, which is the current released version of nivm. Formatting breaking might be due to an upcoming change in 10? I'm not in a good situation at the moment to build and try neovim nightly. Would you be able to try formatting with 0.9.1 to test this theory? |
@will 💥 you nailed it! on 0.10 (nighly compiled / macos) happens this error, using nvim 0.9.1 it works perfectly, so yes, some breaking on 10 👍 |
Just wanted to add that I'm seeing this too! |
I also have the error with SublimeText 4169. |
The parameters for this request only include a textDocument, which is a TextDocumentIdentifier, an identifier? and a previousResultId?. The TextDocumentIdentifer only has a uri property, which is of type DocumentUri. According to the LSP spec: https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#textDocument_diagnostic this request does not include the contents of the file (which is what the handler was expecting). I have simply made the handling of this request a no-op, since diagnostics are already sent to the client in textDocument/didChange. Note: This also fixes formatting problems related to Neovim 0.10 described in standardrb#575
I think this is because currently |
The `textDocument` parameter for the `textDocument/diagnostic` request is of type `TextDocumentIdentifier`, which has a single property `uri` of type `DocumentUri`. Ref: https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#textDocument_diagnostic According to the spec the `DocumentUri` type does not hold the contents of the document, which the handler currently relies on in order to publish diagnostics to the client. This breaks the LSP mode in Neovim 0.10, which now supports pull diagnostics, and possibly other editors too. The same problem exists in `standardrb` (standardrb/standard#575) I have made the `textDocument/diagnostic` hander a no-op, since diagnostics are already being pushed to clients on `textDocument/didChange`.
The `textDocument` parameter for the `textDocument/diagnostic` request is of type `TextDocumentIdentifier`, which has a single property `uri` of type `DocumentUri`. Ref: https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#textDocument_diagnostic According to the spec the `DocumentUri` type does not hold the contents of the document, which the handler currently relies on in order to publish diagnostics to the client. This breaks the LSP mode in Neovim 0.10, which now supports pull diagnostics, and possibly other editors too. The same problem exists in `standardrb` (standardrb/standard#575) I have made the `textDocument/diagnostic` hander a no-op, since diagnostics are already being pushed to clients on `textDocument/didChange`.
Hello,
I'm using neovim with the standardrb LSP configured:
It does report the
documentFormattingProvider
capability, but it doesn't seem to work when I try to format a buffer, I get the following error in the LSP log:Is there some configuration I'm missing? I'm using the default LSP configuration as documented in the nvim-lspconfig link above (
require'lspconfig'.standardrb.setup{}
). I noticed the stardard repo's Wiki on neovim doesn't mention formatting as part of its page, so I'm not sure if that's something that's supported or not (even though it does report the capability).Thanks,
Martin
The text was updated successfully, but these errors were encountered: