Skip to content

Commit

Permalink
fix: strip blink fields from lsp items for resolve
Browse files Browse the repository at this point in the history
  • Loading branch information
Saghen committed Oct 11, 2024
1 parent deba523 commit ab99b02
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
11 changes: 11 additions & 0 deletions lua/blink/cmp/sources/lib/utils.lua
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,15 @@ function utils.concat_responses(responses)
}
end

--- @param item blink.cmp.CompletionItem
--- @return lsp.CompletionItem
function utils.blink_item_to_lsp_item(item)
local lsp_item = vim.deepcopy(item)
lsp_item.cursor_column = nil
lsp_item.score_offset = nil
lsp_item.client_id = nil
lsp_item.source = nil
return lsp_item
end

return utils
3 changes: 3 additions & 0 deletions lua/blink/cmp/sources/lsp.lua
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,9 @@ function lsp:resolve(item, callback)
return
end

-- strip blink specific fields to avoid decoding errors on some LSPs (i.e. fsautocomplete)
item = require('blink.cmp.sources.lib.utils').blink_item_to_lsp_item(item)

local _, request_id = client.request('completionItem/resolve', item, function(error, resolved_item)
if error or resolved_item == nil then callback(item) end
callback(resolved_item)
Expand Down

0 comments on commit ab99b02

Please sign in to comment.