Neovim LSP format chooses unexpected server with multiple attached clients
0 reputation · 10 Aug 2021, 21:38 UTC
Goal
Determine which attached language server Neovim uses when vim.lsp.buf.format() is called on a buffer served by multiple formatting clients, and how the async and timeout_ms parameters affect UI blocking and response handling.
Neovim's built-in LSP client selects among eligible servers using priority and registration order, but the exact logic varies by version and is not fully documented for end users. There is no built-in, filetype-independent way to prefer one formatter without Lua configuration or an external plugin. Timeout handling also differs across releases, and a timeout is not guaranteed to cancel the formatter on the server side.
Because API signatures and defaults changed between Neovim 0.10, 0.11, and nightly, treat the behavior as version-dependent until confirmed against the local help pages.
Which server is chosen when multiple clients register formatting for the same buffer? Does setting async to false reliably block the UI until the formatter returns or times out? What happens to partial edits and client state when timeout_ms elapses?