-
Notifications
You must be signed in to change notification settings - Fork 273
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
How to use yaml formatter with Neovim builtin LSP client? #486
Comments
So, I did a bit of experimentation where I forced Neovim to send the formatting request by specifying that the server actually supports it using My only question is why is the server specifying |
That true, we return |
I tracked it down to this PR (#179) which fixes this issue (redhat-developer/vscode-yaml#220) although I'm not sure I understand the reasoning behind this. |
IIRC it was done that way because VSCode needed formatters to be registered dynamically so that you could dispose of them after they weren't in use. I'm not sure if that's still neccessary though. You might be able to set |
There's already an open PR for this: #316 although it's outdated and needs rebasing. |
For reference, the From the README (server#initialization-options):
|
I encountered the same problem, the formatter does not work (or can not find a way to enable it) |
Why was #316 closed? I think #657 is the same problem we're talking about here. From what @dhruvmanila mentioned, it looks like |
Would you mind sharing how you did that? |
Never mind. I got it working myself by adding a line to my
|
I think you should directly use
But, if you want to use the language server, then I suggest to guard the line so that it only affects the YAML language server: local on_attach = function(client, buffer)
if client.name == "yamlls" then
client.resolved_capabilities.document_formatting = true
end
end |
How would one implement this with neovim? |
Using a formatter plugin like https://github.com/stevearc/conform.nvim. You can find a list here: https://github.com/rockerBOO/awesome-neovim#formatting |
Awesome! I was able to get it working super easily (the method above in this PR wasn't working). |
The codebase contains a yamlFormatter although the server capabilities says otherwise:
The formatter runs perfectly well in VSCode. I installed the server using
npm
and running the server with the default settings.The text was updated successfully, but these errors were encountered: