aboutsummaryrefslogtreecommitdiff
path: root/runtime/lua/vim/lsp/_capability.lua
diff options
context:
space:
mode:
authorjdrouhard <john@drouhard.dev>2026-07-05 11:47:30 -0500
committerGitHub <noreply@github.com>2026-07-05 12:47:30 -0400
commit1f18ea1cf7881cece01857bcff04439e810b3429 (patch)
tree5a2f95f092260837bb70d7c95f4fa8c2e8fadb5d /runtime/lua/vim/lsp/_capability.lua
parente494c4777b84f5b1f275c192b52d51b625233e87 (diff)
downloadrneovim-1f18ea1cf7881cece01857bcff04439e810b3429.tar.gz
rneovim-1f18ea1cf7881cece01857bcff04439e810b3429.tar.bz2
rneovim-1f18ea1cf7881cece01857bcff04439e810b3429.zip
feat(lsp): convert inlay_hint to capability framework #40569
Problem: Inlay hints used separate global and per-buffer bufstates tables and bespoke global autocmds for managing the inlay hint state across buffers and clients, duplicating the lifecycle logic already provided by the Capability framework. This caused inconsistencies in how client state was handled and inlay hint state lifecycle was managed compared to other LSP features. Solution: Replace the ad-hoc bufstate tracking and global autocmds in vim.lsp.inlay_hint with a proper InlayHint subclass of Capability. This also refactors the way inlay hint state is managed and fixes bugs I found while doing this: 1. For each line with inlay hints, the list of the hints along with whether they have been applied is stored in a current result on the client state. This allows the on_win decorator to clear all inlay hints for an old document version once, and then re-add the new version's hints line-by-line as they are drawn to the screen, modeling the semantic tokens module. 2. It fixes problems with mixing results from multiple clients attached to the buffer by fully moving each client's state to its own table. Previously, only the most recent document version used to populate a line's inlay hints was stored, but there was no distinction for which client the hints may have come from. (Fixes #36318) 3. It fixes the workspace/inlayHint/refresh server->client notification behavior. Previously it would only re-request inlay hints for buffers currently displayed in a window but would not invalidate them in non-displayed buffers (or provide any mechanism for those buffers to re-request at a later time). Model semantic token module here again by invalidating all buffers, and adding a BufWinEnter autocmd to refresh hints. 4. Add a mechanism to cancel in-flight requests if a new request for a newer document version is made before the last one returned 5. Handle stale results by simply dropping them.
Diffstat (limited to 'runtime/lua/vim/lsp/_capability.lua')
-rw-r--r--runtime/lua/vim/lsp/_capability.lua1
1 files changed, 1 insertions, 0 deletions
diff --git a/runtime/lua/vim/lsp/_capability.lua b/runtime/lua/vim/lsp/_capability.lua
index d4e0b8f90e..c679700e51 100644
--- a/runtime/lua/vim/lsp/_capability.lua
+++ b/runtime/lua/vim/lsp/_capability.lua
@@ -5,6 +5,7 @@ local api = vim.api
---| 'diagnostics'
---| 'document_color'
---| 'folding_range'
+---| 'inlay_hint'
---| 'inline_completion'
---| 'linked_editing_range'
---| 'semantic_tokens'