Skip to content

Commit 42f8efb

Browse files
committed
fix: item defaults not being applied
closes #158
1 parent e296d8f commit 42f8efb

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

lua/blink/cmp/sources/lsp.lua

+11-6
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,14 @@ function lsp:get_completions(context, callback)
105105

106106
-- convert full response to our internal format
107107
else
108+
local defaults = response.result and response.result.itemDefaults or {}
109+
for _, item in ipairs(response.result.items) do
110+
-- add defaults to the item
111+
for key, value in pairs(defaults) do
112+
item[key] = value
113+
end
114+
end
115+
108116
responses[client_id] = {
109117
is_incomplete_forward = response.result.isIncomplete,
110118
is_incomplete_backward = true,
@@ -115,7 +123,6 @@ function lsp:get_completions(context, callback)
115123

116124
-- add client_id and defaults to the items
117125
for client_id, response in pairs(responses) do
118-
local defaults = response.result and response.result.itemDefaults or {}
119126
for _, item in ipairs(response.items) do
120127
-- todo: terraform lsp doesn't return a .kind in situations like `toset`, is there a default value we need to grab?
121128
-- it doesn't seem to return itemDefaults either
@@ -124,11 +131,6 @@ function lsp:get_completions(context, callback)
124131

125132
-- todo: make configurable
126133
if item.deprecated or (item.tags and vim.tbl_contains(item.tags, 1)) then item.score_offset = -2 end
127-
128-
-- add defaults to the item
129-
for key, value in pairs(defaults) do
130-
item[key] = value
131-
end
132134
end
133135
end
134136

@@ -159,10 +161,13 @@ function lsp:resolve(item, callback)
159161
end
160162

161163
-- strip blink specific fields to avoid decoding errors on some LSPs (i.e. fsautocomplete)
164+
vim.print(item)
162165
item = require('blink.cmp.sources.lib.utils').blink_item_to_lsp_item(item)
166+
vim.print(item)
163167

164168
local _, request_id = client.request('completionItem/resolve', item, function(error, resolved_item)
165169
if error or resolved_item == nil then callback(item) end
170+
vim.print(resolved_item)
166171
callback(resolved_item)
167172
end)
168173
if request_id ~= nil then return function() client.cancel_request(request_id) end end

0 commit comments

Comments
 (0)