@@ -68,8 +68,29 @@ local function pick_call_hierarchy_item(call_hierarchy_items)
6868 return call_hierarchy_items [choice ]
6969end
7070
71+ --- @param win number ? Window handler
72+ --- @param extra table ? Extra fields in params
73+ --- @return table | (fun ( client : vim.lsp.Client ): table ) parmas to send to the server
74+ local function client_position_params (win , extra )
75+ win = win or vim .api .nvim_get_current_win ()
76+ if vim .fn .has " nvim-0.11" == 0 then
77+ local params = vim .lsp .util .make_position_params (win )
78+ if extra then
79+ params = vim .tbl_extend (" force" , params , extra )
80+ end
81+ return params
82+ end
83+ return function (client )
84+ local params = vim .lsp .util .make_position_params (win , client .offset_encoding )
85+ if extra then
86+ params = vim .tbl_extend (" force" , params , extra )
87+ end
88+ return params
89+ end
90+ end
91+
7192local function calls (opts , direction )
72- local params = vim . lsp . util . make_position_params ()
93+ local params = client_position_params ()
7394 vim .lsp .buf_request (opts .bufnr , " textDocument/prepareCallHierarchy" , params , function (err , result )
7495 if err then
7596 vim .api .nvim_err_writeln (" Error when preparing call hierarchy: " .. err )
171192--- @param action telescope.lsp.list_or_jump_action
172193--- @param title string prompt title
173194--- @param funname string : name of the calling function
174- --- @param params lsp.TextDocumentPositionParams
195+ --- @param params lsp.TextDocumentPositionParams | ( fun ( client : vim.lsp.Client , bufnr : integer ): table ?)
175196--- @param opts table
176197local function list_or_jump (action , title , funname , params , opts )
177198 opts .reuse_win = vim .F .if_nil (opts .reuse_win , false )
@@ -263,19 +284,19 @@ end
263284
264285lsp .references = function (opts )
265286 opts .include_current_line = vim .F .if_nil (opts .include_current_line , false )
266- --- @class lsp.TextDocumentPositionParams
267- local params = vim .lsp . util . make_position_params (opts .winnr )
268- params . context = { includeDeclaration = vim . F . if_nil ( opts . include_declaration , true ) }
287+ local params = client_position_params ( opts . winnr , {
288+ context = { includeDeclaration = vim .F . if_nil (opts .include_declaration , true ) },
289+ })
269290 return list_or_jump (" textDocument/references" , " LSP References" , " builtin.lsp_references" , params , opts )
270291end
271292
272293lsp .definitions = function (opts )
273- local params = vim . lsp . util . make_position_params (opts .winnr )
294+ local params = client_position_params (opts .winnr )
274295 return list_or_jump (" textDocument/definition" , " LSP Definitions" , " builtin.lsp_definitions" , params , opts )
275296end
276297
277298lsp .type_definitions = function (opts )
278- local params = vim . lsp . util . make_position_params (opts .winnr )
299+ local params = client_position_params (opts .winnr )
279300 return list_or_jump (
280301 " textDocument/typeDefinition" ,
281302 " LSP Type Definitions" ,
@@ -286,7 +307,7 @@ lsp.type_definitions = function(opts)
286307end
287308
288309lsp .implementations = function (opts )
289- local params = vim . lsp . util . make_position_params (opts .winnr )
310+ local params = client_position_params (opts .winnr )
290311 return list_or_jump (" textDocument/implementation" , " LSP Implementations" , " builtin.lsp_implementations" , params , opts )
291312end
292313
@@ -323,7 +344,7 @@ local symbols_sorter = function(symbols)
323344end
324345
325346lsp .document_symbols = function (opts )
326- local params = vim . lsp . util . make_position_params (opts .winnr )
347+ local params = client_position_params (opts .winnr )
327348 vim .lsp .buf_request (opts .bufnr , " textDocument/documentSymbol" , params , function (err , result , _ , _ )
328349 if err then
329350 vim .api .nvim_err_writeln (" Error when finding document symbols: " .. err .message )
0 commit comments