Closed GaetanLepage closed 2 months ago
Instead of skipping the check, it should subscribe to the changes IMO, to react to dynamic registration, like vscode:
_languageFeaturesService.onTypeFormattingEditProvider.onDidChange(this._update, this);
Yeah I agree, this should get handled automatically. Having to set a force option for this is not nice user experience.
I agree as well that an an automatic behavior would be better. Currently, there is no easy way to listen for this kind of events in neovim.
It has been discussed here to add an LspCapability
event that would let us register an appropriate autocmd.
However, this has not been addressed yet.
I do feel like a force_attach
option is the only way in the meantime. What do you think ?
We don't need to listen for an event. We can just attach all buffers, and check if the client supports formatting each time formatting is triggered.
client.supports_method
supports dynamic registration, this shouldn't be too complicated.
We don't need to listen for an event. We can just attach all buffers, and check if the client supports formatting each time formatting is triggered.
client.supports_method
supports dynamic registration, this shouldn't be too complicated.
Right indeed ! I had not understood this at first. I made a separate PR: #88.
Some language servers rely on dynamic registration for the
textDocument/formatting
capability. Although the neovimclient.supports_method
(used here) is supposed to account for that, some language servers are still not reporting to support this capability.To account for this, this PR introduces a new parameter
force_attach
that lets the user skip theif not client.supports_method(method)
check and attach lsp-format nonetheless. This has been working for me for tinymist. Formatting works great now.