aboutsummaryrefslogtreecommitdiff
path: root/runtime/lua/vim
diff options
context:
space:
mode:
authorMarcus Caisey <marcus@teckna.com>2026-05-13 17:53:27 +0100
committerMarcus Caisey <marcus@teckna.com>2026-05-21 18:22:13 +0100
commitd6d03716cf8628de7d9a261e1caeb5cefeb74774 (patch)
treec2e3b377108738f04b391c922c65e5cf79d7f9d8 /runtime/lua/vim
parentce7df01391be8df721c5de1c57d4b254a7792524 (diff)
downloadrneovim-d6d03716cf8628de7d9a261e1caeb5cefeb74774.tar.gz
rneovim-d6d03716cf8628de7d9a261e1caeb5cefeb74774.tar.bz2
rneovim-d6d03716cf8628de7d9a261e1caeb5cefeb74774.zip
fix(lsp): show detail in popup when server can't completionItem/resolve
Problem: `CompletionItem.detail` is only shown in the info popup if the server supports `completionItem/resolve`. Solution: If the server doesn't support `completionItem/resolve`, prepend the complete item `info` with `CompletionItem.detail` in a fenced codeblock, same as we do when the server supports `completionItem/resolve`. To ensure that completion items are displayed in the same way, regardless of whether the server supports `completionItem/resolve`, i've extracted out the test logic from the `selecting an item triggers completionItem/resolve + (snippet) preview` case so that we can run the same tests against a server which supports `completionItem/resolve` and one which doesn't. Hopefully this should prevent the two behaviours diverging again.
Diffstat (limited to 'runtime/lua/vim')
-rw-r--r--runtime/lua/vim/lsp/completion.lua15
1 files changed, 13 insertions, 2 deletions
diff --git a/runtime/lua/vim/lsp/completion.lua b/runtime/lua/vim/lsp/completion.lua
index 111405bc05..44de65ca1b 100644
--- a/runtime/lua/vim/lsp/completion.lua
+++ b/runtime/lua/vim/lsp/completion.lua
@@ -435,12 +435,21 @@ function M._lsp_to_complete_items(
hl_group = 'DiagnosticDeprecated'
end
local kind, kind_hlgroup = generate_kind(item)
+ local info = get_doc(item)
+ if item.detail and item.detail ~= '' then
+ if info == '' then
+ info = ('```%s\n%s\n```'):format(vim.bo.filetype, item.detail)
+ elseif not info:find(item.detail, 1, true) then
+ local detail_block = ('```%s\n%s\n```'):format(vim.bo.filetype, item.detail)
+ info = detail_block .. '\n' .. info
+ end
+ end
local completion_item = {
word = word,
abbr = ('%s%s'):format(item.label, vim.tbl_get(item, 'labelDetails', 'detail') or ''),
kind = kind,
menu = vim.tbl_get(item, 'labelDetails', 'description') or '',
- info = get_doc(item),
+ info = info,
icase = 1,
dup = 1,
empty = 1,
@@ -800,7 +809,8 @@ local function on_completechanged(group, bufnr)
return
end
local data = vim.fn.complete_info({ 'selected' })
- if (completed_item.info or '') ~= '' then
+ local info = completed_item.info or ''
+ if info ~= '' then
local kind = vim.tbl_get(lsp_item, 'documentation', 'kind')
update_popup_window(
data.preview_winid,
@@ -818,6 +828,7 @@ local function on_completechanged(group, bufnr)
then
if
has_completeopt('popup')
+ and info == ''
and lsp_item.insertTextFormat == protocol.InsertTextFormat.Snippet
then
-- Shows snippet preview in doc popup if completeopt=popup.