Neovim LSP client ↔ external language servers: formatting selection with overlapping capabilities
0 reputation · 26 Jun 2022, 17:16 UTC
Neovim's built-in LSP client communicates with external language servers over msgpack-RPC and exposes vim.lsp functions for diagnostics, completion and formatting. During initialization the client merges server-declared capabilities with client settings and registers handlers for LSP requests and notifications.
When multiple language servers attach to the same buffer, capability overlap such as textDocument/formatting and diagnostics can occur. The documented behavior for selecting a formatter is via vim.lsp.buf.format with an optional filter, and the default selection is tied to the internal client list order. The merge order and deduplication for diagnostics is implementation dependent and varies by version.
What attribute determines the ordering of clients in the internal list used for formatting when no filter is provided? Is capability merging for overlapping features defined deterministically across Neovim 0.9 to 0.11? How are diagnostics from multiple servers merged when ranges overlap?