Things look solidly grim at this point. On the edge of reporting a bug against
I’d like to format current visual selection via LSP.
documentFormattingProvider is present in
client.server_capabilities and formatting the whole file works just fine.
What I have tried so far:
vim.lsp.buf.format()as per documented. It fails to act on visual selection when called without parameters.
bufnr. Same result, formats the whole buffer.
- Calling it via user command. Still formats the whole buffer.
autopep8 acting as formatters.
Any ideas how to make it work? As an absolutely last resort, I am considering extracting text via Lua function, passing it to an external formatter via
stdin and then replacing selection with its
stdout, but… This is too much, there has to be a better way.