neovim

Neovim text editor
git clone https://git.dasho.dev/neovim.git
Log | Files | Refs | README

commit 1f63735f175d178f37e2fd27b190699486614a04
parent 6018aed92f5ce6a43a8bba87543e262e3ac3f771
Author: Maria José Solano <majosolano99@gmail.com>
Date:   Sun, 24 Aug 2025 15:46:08 -0700

fix(lsp): treat nil inlay hint result as empty array (#35458)

`gopls` seems to send a nil result when there are no inlay hints for the
buffer. [The protocol](https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#textDocument_inlayHint)
allows for the server to send an array or nil, and it isn't clear what
nil should represent. I think it's reasonable to treat it as an empty
array though.
Diffstat:
Mruntime/lua/vim/lsp/inlay_hint.lua | 5++++-
1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/runtime/lua/vim/lsp/inlay_hint.lua b/runtime/lua/vim/lsp/inlay_hint.lua @@ -44,9 +44,9 @@ function M.on_inlayhint(err, result, ctx) return end local bufnr = assert(ctx.bufnr) + if util.buf_versions[bufnr] ~= ctx.version - or not result or not api.nvim_buf_is_loaded(bufnr) or not bufstates[bufnr].enabled then @@ -61,6 +61,9 @@ function M.on_inlayhint(err, result, ctx) local client_hints = bufstate.client_hints local client = assert(vim.lsp.get_client_by_id(client_id)) + -- If there's no error but the result is nil, clear existing hints. + result = result or {} + local new_lnum_hints = vim.defaulttable() local num_unprocessed = #result if num_unprocessed == 0 then