Skip to content

Commit 0a2abab

Browse files
committed
fix: use offset encoding of first client
Closes #380
1 parent c58b3a8 commit 0a2abab

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

lua/blink/cmp/sources/lsp.lua

+10-3
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ function lsp:get_clients_with_capability(capability, filter)
4949
end
5050

5151
function lsp:get_completions(context, callback)
52-
-- TODO: offset encoding is global but should be per-client
5352
-- TODO: should make separate LSP requests to return results earlier, in the case of slow LSPs
5453

5554
-- no providers with completion support
@@ -58,8 +57,12 @@ function lsp:get_completions(context, callback)
5857
return function() end
5958
end
6059

60+
-- TODO: offset encoding is global but should be per-client
61+
local first_client = vim.lsp.get_clients({ bufnr = 0 })[1]
62+
local offset_encoding = first_client and first_client.offset_encoding or 'utf-16'
63+
6164
-- completion context with additional info about how it was triggered
62-
local params = vim.lsp.util.make_position_params()
65+
local params = vim.lsp.util.make_position_params(nil, offset_encoding)
6366
params.context = {
6467
triggerKind = context.trigger.kind,
6568
}
@@ -214,7 +217,11 @@ function lsp:get_signature_help(context, callback)
214217
return function() end
215218
end
216219

217-
local params = vim.lsp.util.make_position_params()
220+
-- TODO: offset encoding is global but should be per-client
221+
local first_client = vim.lsp.get_clients({ bufnr = 0 })[1]
222+
local offset_encoding = first_client and first_client.offset_encoding or 'utf-16'
223+
224+
local params = vim.lsp.util.make_position_params(nil, offset_encoding)
218225
params.context = {
219226
triggerKind = context.trigger.kind,
220227
triggerCharacter = context.trigger.character,

0 commit comments

Comments
 (0)