Skip to content

Commit

Permalink
fix: added support for new handler signatures (backward compatible wi…
Browse files Browse the repository at this point in the history
…th 0.5)
  • Loading branch information
folke committed Oct 22, 2021
1 parent d25a8e6 commit 87cae94
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions lua/trouble/providers/lsp.lua
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,18 @@ function M.diagnostics(_win, buf, cb, options)
cb(items)
end

local function lsp_buf_request(buf, method, params, handler)
lsp.buf_request(buf, method, params, function(err, m, result)
handler(err, method == m and result or m)
end)
end

---@return Item[]
function M.references(win, buf, cb, _options)
local method = "textDocument/references"
local params = util.make_position_params(win, buf)
params.context = { includeDeclaration = true }
lsp.buf_request(buf, method, params, function(err, _method, result, _client_id, _bufnr, _config)
lsp_buf_request(buf, method, params, function(err, result)
if err then
util.error("an error happened getting references: " .. err)
return cb({})
Expand All @@ -39,7 +45,7 @@ function M.implementations(win, buf, cb, _options)
local method = "textDocument/implementation"
local params = util.make_position_params(win, buf)
params.context = { includeDeclaration = true }
lsp.buf_request(buf, method, params, function(err, _method, result, _client_id, _bufnr, _config)
lsp_buf_request(buf, method, params, function(err, result)
if err then
util.error("an error happened getting implementation: " .. err)
return cb({})
Expand All @@ -57,7 +63,7 @@ function M.definitions(win, buf, cb, _options)
local method = "textDocument/definition"
local params = util.make_position_params(win, buf)
params.context = { includeDeclaration = true }
lsp.buf_request(buf, method, params, function(err, _method, result, _client_id, _bufnr, _config)
lsp_buf_request(buf, method, params, function(err, result)
if err then
util.error("an error happened getting definitions: " .. err)
return cb({})
Expand Down

0 comments on commit 87cae94

Please sign in to comment.