mirror of
https://github.com/neovim/neovim.git
synced 2025-12-11 00:52:44 +00:00
lsp: add bufnr to callback function arguments
DocumentSymbol type doesn't have location field. So when we'll add 'textDocument/documentSymbol’ handler, we can't decide which file have we jump to.
This commit is contained in:
@@ -101,7 +101,7 @@ local function for_each_buffer_client(bufnr, callback)
|
|||||||
for client_id in pairs(client_ids) do
|
for client_id in pairs(client_ids) do
|
||||||
local client = active_clients[client_id]
|
local client = active_clients[client_id]
|
||||||
if client then
|
if client then
|
||||||
callback(client, client_id)
|
callback(client, client_id, bufnr)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -520,7 +520,7 @@ function lsp.start_client(config)
|
|||||||
end
|
end
|
||||||
|
|
||||||
--- Checks capabilities before rpc.request-ing.
|
--- Checks capabilities before rpc.request-ing.
|
||||||
function client.request(method, params, callback)
|
function client.request(method, params, callback, bufnr)
|
||||||
if not callback then
|
if not callback then
|
||||||
callback = resolve_callback(method)
|
callback = resolve_callback(method)
|
||||||
or error("not found: request callback for client "..client.name)
|
or error("not found: request callback for client "..client.name)
|
||||||
@@ -536,7 +536,7 @@ function lsp.start_client(config)
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
return rpc.request(method, params, function(err, result)
|
return rpc.request(method, params, function(err, result)
|
||||||
callback(err, method, result, client_id)
|
callback(err, method, result, client_id, bufnr)
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -836,8 +836,8 @@ function lsp.buf_request(bufnr, method, params, callback)
|
|||||||
callback = { callback, 'f', true };
|
callback = { callback, 'f', true };
|
||||||
}
|
}
|
||||||
local client_request_ids = {}
|
local client_request_ids = {}
|
||||||
for_each_buffer_client(bufnr, function(client, client_id)
|
for_each_buffer_client(bufnr, function(client, client_id, resolved_bufnr)
|
||||||
local request_success, request_id = client.request(method, params, callback)
|
local request_success, request_id = client.request(method, params, callback, resolved_bufnr)
|
||||||
|
|
||||||
-- This could only fail if the client shut down in the time since we looked
|
-- This could only fail if the client shut down in the time since we looked
|
||||||
-- it up and we did the request, which should be rare.
|
-- it up and we did the request, which should be rare.
|
||||||
@@ -874,7 +874,7 @@ end
|
|||||||
function lsp.buf_request_sync(bufnr, method, params, timeout_ms)
|
function lsp.buf_request_sync(bufnr, method, params, timeout_ms)
|
||||||
local request_results = {}
|
local request_results = {}
|
||||||
local result_count = 0
|
local result_count = 0
|
||||||
local function _callback(err, _method, result, client_id)
|
local function _callback(err, _method, result, client_id, bufnr)
|
||||||
request_results[client_id] = { error = err, result = result }
|
request_results[client_id] = { error = err, result = result }
|
||||||
result_count = result_count + 1
|
result_count = result_count + 1
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -138,6 +138,11 @@ function M.references(context)
|
|||||||
request('textDocument/references', params)
|
request('textDocument/references', params)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function M.document_symbol()
|
||||||
|
local params = { textDocument = util.make_text_document_params() }
|
||||||
|
request('textDocument/documentSymbol', params)
|
||||||
|
end
|
||||||
|
|
||||||
--- Send request to server to resolve document highlights for the
|
--- Send request to server to resolve document highlights for the
|
||||||
--- current text document position. This request can be associated
|
--- current text document position. This request can be associated
|
||||||
--- to key mapping or to events such as `CursorHold`, eg:
|
--- to key mapping or to events such as `CursorHold`, eg:
|
||||||
|
|||||||
Reference in New Issue
Block a user