345
345
346
346
lsp .document_symbols = function (opts )
347
347
local params = client_position_params (opts .winnr )
348
- vim .lsp .buf_request (opts .bufnr , " textDocument/documentSymbol" , params , function (err , result , _ , _ )
348
+ vim .lsp .buf_request (opts .bufnr , " textDocument/documentSymbol" , params , function (err , result , ctx , _ )
349
349
if err then
350
350
vim .api .nvim_err_writeln (" Error when finding document symbols: " .. err .message )
351
351
return
@@ -359,7 +359,14 @@ lsp.document_symbols = function(opts)
359
359
return
360
360
end
361
361
362
- local locations = vim .lsp .util .symbols_to_items (result or {}, opts .bufnr ) or {}
362
+ local locations
363
+ if vim .fn .has " nvim-0.11" == 1 then
364
+ local client = assert (vim .lsp .get_client_by_id (ctx .client_id ))
365
+ locations = vim .lsp .util .symbols_to_items (result or {}, opts .bufnr , client .offset_encoding ) or {}
366
+ else
367
+ locations = vim .lsp .util .symbols_to_items (result or {}, opts .bufnr ) or {}
368
+ end
369
+
363
370
locations = utils .filter_symbols (locations , opts , symbols_sorter )
364
371
if vim .tbl_isempty (locations ) then
365
372
-- error message already printed in `utils.filter_symbols`
@@ -396,13 +403,20 @@ end
396
403
397
404
lsp .workspace_symbols = function (opts )
398
405
local params = { query = opts .query or " " }
399
- vim .lsp .buf_request (opts .bufnr , " workspace/symbol" , params , function (err , server_result , _ , _ )
406
+ vim .lsp .buf_request (opts .bufnr , " workspace/symbol" , params , function (err , server_result , ctx , _ )
400
407
if err then
401
408
vim .api .nvim_err_writeln (" Error when finding workspace symbols: " .. err .message )
402
409
return
403
410
end
404
411
405
- local locations = vim .lsp .util .symbols_to_items (server_result or {}, opts .bufnr ) or {}
412
+ local locations
413
+ if vim .fn .has " nvim-0.11" == 1 then
414
+ local client = assert (vim .lsp .get_client_by_id (ctx .client_id ))
415
+ locations = vim .lsp .util .symbols_to_items (server_result or {}, opts .bufnr , client .offset_encoding ) or {}
416
+ else
417
+ locations = vim .lsp .util .symbols_to_items (server_result or {}, opts .bufnr ) or {}
418
+ end
419
+
406
420
locations = utils .filter_symbols (locations , opts , symbols_sorter )
407
421
if vim .tbl_isempty (locations ) then
408
422
-- error message already printed in `utils.filter_symbols`
@@ -448,11 +462,16 @@ local function get_workspace_symbols_requester(bufnr, opts)
448
462
local results = rx () --- @type table<integer , { error : lsp.ResponseError ?, result : lsp.WorkspaceSymbol ?} >
449
463
local locations = {} --- @type vim.quickfix.entry[]
450
464
451
- for _ , client_res in pairs (results ) do
465
+ for client_id , client_res in pairs (results ) do
452
466
if client_res .error then
453
467
vim .api .nvim_err_writeln (" Error when executing workspace/symbol : " .. client_res .error .message )
454
468
elseif client_res .result ~= nil then
455
- vim .list_extend (locations , vim .lsp .util .symbols_to_items (client_res .result , bufnr ))
469
+ if vim .fn .has " nvim-0.11" == 1 then
470
+ local client = assert (vim .lsp .get_client_by_id (client_id ))
471
+ vim .list_extend (locations , vim .lsp .util .symbols_to_items (client_res .result , bufnr , client .offset_encoding ))
472
+ else
473
+ vim .list_extend (locations , vim .lsp .util .symbols_to_items (client_res .result , bufnr ))
474
+ end
456
475
end
457
476
end
458
477
0 commit comments