From 77e3efecee4e9948044ec02caeaf6fec496c6c02 Mon Sep 17 00:00:00 2001 From: Riley Bruins Date: Sun, 31 Aug 2025 14:09:12 -0700 Subject: feat(lsp): support `textDocument/onTypeFormatting` (#34637) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Implements [on-type formatting](https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification/#textDocument_onTypeFormatting) using a `vim.on_key()` approach to listen to typed keys. It will listen to keys on the *left hand side* of mappings. The `on_key` callback is cleared when detaching the last on-type formatting client. This feature is disabled by default. Co-authored-by: Maria José Solano --- runtime/lua/vim/lsp/client.lua | 3 +++ 1 file changed, 3 insertions(+) (limited to 'runtime/lua/vim/lsp/client.lua') diff --git a/runtime/lua/vim/lsp/client.lua b/runtime/lua/vim/lsp/client.lua index c77077e3fc..7605d8fd44 100644 --- a/runtime/lua/vim/lsp/client.lua +++ b/runtime/lua/vim/lsp/client.lua @@ -211,6 +211,9 @@ local all_clients = {} --- --- @field _enabled_capabilities table --- +--- Whether on-type formatting is enabled for this client. +--- @field _otf_enabled boolean? +--- --- Track this so that we can escalate automatically if we've already tried a --- graceful shutdown --- @field private _graceful_shutdown_failed true? -- cgit