117
117
--- @class trouble.lsp.Response <R , P >: {client : vim.lsp.Client , result : R , err : lsp.ResponseError , params : P }
118
118
119
119
--- @param method string
120
- --- @param params ? table
120
+ --- @param params ? table | fun ( client : vim.lsp.Client ): table
121
121
--- @param opts ? { client ?: vim.lsp.Client }
122
122
function M .request (method , params , opts )
123
123
opts = opts or {}
@@ -143,8 +143,9 @@ function M.request(method, params, opts)
143
143
--- @param client vim.lsp.Client
144
144
return Promise .all (vim .tbl_map (function (client )
145
145
return Promise .new (function (resolve )
146
- client .request (method , params , function (err , result )
147
- resolve ({ client = client , result = result , err = err , params = params })
146
+ local p = type (params ) == " function" and params (client ) or params --[[ @as table]]
147
+ client .request (method , p , function (err , result )
148
+ resolve ({ client = client , result = result , err = err , params = p })
148
149
end , buf )
149
150
end )
150
151
end , clients )):next (function (results )
@@ -171,12 +172,16 @@ function M.get_locations(method, cb, ctx, opts)
171
172
end
172
173
173
174
opts = opts or {}
174
- --- @type lsp.TextDocumentPositionParams
175
- local params = opts .params or vim .lsp .util .make_position_params (win )
176
- --- @diagnostic disable-next-line : inject-field
177
- params .context = params .context or opts .context or nil
175
+ --- @type fun ( client : vim.lsp.Client ): lsp.TextDocumentPositionParams
176
+ local params = function (client )
177
+ local ret = opts .params or vim .lsp .util .make_position_params (win , client .offset_encoding )
178
+ --- @diagnostic disable-next-line : inject-field
179
+ ret .context = ret .context or opts .context or nil
180
+ return ret
181
+ end
178
182
179
- local id = table.concat ({ buf , cursor [1 ], col , method , vim .inspect (params ) }, " -" )
183
+ local id =
184
+ table.concat ({ buf , cursor [1 ], col , method , vim .inspect (vim .lsp .util .make_position_params (win , " utf-16" )) }, " -" )
180
185
if Cache .locations [id ] then
181
186
return cb (Cache .locations [id ])
182
187
end
@@ -235,10 +240,10 @@ end
235
240
236
241
--- @param cb trouble.Source.Callback
237
242
function M .call_hierarchy (cb , incoming )
238
- --- @type lsp.CallHierarchyPrepareParams
239
- local params = vim . lsp . util . make_position_params ( )
240
-
241
- M . request ( " textDocument/prepareCallHierarchy " , params )
243
+ local win = vim . api . nvim_get_current_win ()
244
+ M . request ( " textDocument/prepareCallHierarchy " , function ( client )
245
+ return vim . lsp . util . make_position_params ( win , client . offset_encoding )
246
+ end )
242
247
:next (
243
248
--- @param results trouble.lsp.Response<lsp.CallHierarchyItem[]>[]
244
249
function (results )
0 commit comments