diff --git a/lua/blink/cmp/sources/lib/utils.lua b/lua/blink/cmp/sources/lib/utils.lua index acbd28dc..d3ae4796 100644 --- a/lua/blink/cmp/sources/lib/utils.lua +++ b/lua/blink/cmp/sources/lib/utils.lua @@ -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 diff --git a/lua/blink/cmp/sources/lsp.lua b/lua/blink/cmp/sources/lsp.lua index 7e75c39d..a358d3bf 100644 --- a/lua/blink/cmp/sources/lsp.lua +++ b/lua/blink/cmp/sources/lsp.lua @@ -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)