mirror of
				https://github.com/neovim/neovim.git
				synced 2025-10-26 12:27:24 +00:00 
			
		
		
		
	refactor(lsp.buf): remove buf_request wrapper
This commit is contained in:
		| @@ -7,26 +7,6 @@ local ms = require('vim.lsp.protocol').Methods | |||||||
|  |  | ||||||
| local M = {} | local M = {} | ||||||
|  |  | ||||||
| --- Sends an async request to all active clients attached to the current |  | ||||||
| --- buffer. |  | ||||||
| --- |  | ||||||
| ---@param method (string) LSP method name |  | ||||||
| ---@param params (table|nil) Parameters to send to the server |  | ||||||
| ---@param handler lsp.Handler? See |lsp-handler|. Follows |lsp-handler-resolution| |  | ||||||
| --- |  | ||||||
| ---@return table<integer, integer> client_request_ids Map of client-id:request-id pairs |  | ||||||
| ---for all successful requests. |  | ||||||
| ---@return function _cancel_all_requests Function which can be used to |  | ||||||
| ---cancel all the requests. You could instead |  | ||||||
| ---iterate all clients and call their `cancel_request()` methods. |  | ||||||
| --- |  | ||||||
| ---@see |vim.lsp.buf_request()| |  | ||||||
| local function request(method, params, handler) |  | ||||||
|   validate('method', method, 'string') |  | ||||||
|   validate('handler', handler, 'function', true) |  | ||||||
|   return lsp.buf_request(0, method, params, handler) |  | ||||||
| end |  | ||||||
|  |  | ||||||
| --- Displays hover information about the symbol under the cursor in a floating | --- Displays hover information about the symbol under the cursor in a floating | ||||||
| --- window. The window will be dismissed on cursor move. | --- window. The window will be dismissed on cursor move. | ||||||
| --- Calling the function twice will jump into the floating window | --- Calling the function twice will jump into the floating window | ||||||
| @@ -48,7 +28,7 @@ local function request_with_opts(name, params, opts) | |||||||
|       handler(err, result, ctx, vim.tbl_extend('force', config or {}, opts)) |       handler(err, result, ctx, vim.tbl_extend('force', config or {}, opts)) | ||||||
|     end |     end | ||||||
|   end |   end | ||||||
|   request(name, params, req_handler) |   lsp.buf_request(0, name, params, req_handler) | ||||||
| end | end | ||||||
|  |  | ||||||
| ---@param method string | ---@param method string | ||||||
| @@ -187,7 +167,7 @@ end | |||||||
| --- floating window. | --- floating window. | ||||||
| function M.signature_help() | function M.signature_help() | ||||||
|   local params = util.make_position_params() |   local params = util.make_position_params() | ||||||
|   request(ms.textDocument_signatureHelp, params) |   lsp.buf_request(0, ms.textDocument_signatureHelp, params) | ||||||
| end | end | ||||||
|  |  | ||||||
| --- Retrieves the completion items at the current cursor position. Can only be | --- Retrieves the completion items at the current cursor position. Can only be | ||||||
| @@ -201,7 +181,7 @@ end | |||||||
| function M.completion(context) | function M.completion(context) | ||||||
|   local params = util.make_position_params() |   local params = util.make_position_params() | ||||||
|   params.context = context |   params.context = context | ||||||
|   return request(ms.textDocument_completion, params) |   return lsp.buf_request(0, ms.textDocument_completion, params) | ||||||
| end | end | ||||||
|  |  | ||||||
| ---@param bufnr integer | ---@param bufnr integer | ||||||
| @@ -609,7 +589,7 @@ end | |||||||
| local function call_hierarchy(method) | local function call_hierarchy(method) | ||||||
|   local params = util.make_position_params() |   local params = util.make_position_params() | ||||||
|   --- @param result lsp.CallHierarchyItem[]? |   --- @param result lsp.CallHierarchyItem[]? | ||||||
|   request(ms.textDocument_prepareCallHierarchy, params, function(err, result, ctx) |   lsp.buf_request(0, ms.textDocument_prepareCallHierarchy, params, function(err, result, ctx) | ||||||
|     if err then |     if err then | ||||||
|       vim.notify(err.message, vim.log.levels.WARN) |       vim.notify(err.message, vim.log.levels.WARN) | ||||||
|       return |       return | ||||||
| @@ -794,7 +774,7 @@ end | |||||||
| ---         |hl-LspReferenceWrite| | ---         |hl-LspReferenceWrite| | ||||||
| function M.document_highlight() | function M.document_highlight() | ||||||
|   local params = util.make_position_params() |   local params = util.make_position_params() | ||||||
|   request(ms.textDocument_documentHighlight, params) |   lsp.buf_request(0, ms.textDocument_documentHighlight, params) | ||||||
| end | end | ||||||
|  |  | ||||||
| --- Removes document highlights from current buffer. | --- Removes document highlights from current buffer. | ||||||
| @@ -1063,7 +1043,7 @@ function M.execute_command(command_params) | |||||||
|     arguments = command_params.arguments, |     arguments = command_params.arguments, | ||||||
|     workDoneToken = command_params.workDoneToken, |     workDoneToken = command_params.workDoneToken, | ||||||
|   } |   } | ||||||
|   request(ms.workspace_executeCommand, command_params) |   lsp.buf_request(0, ms.workspace_executeCommand, command_params) | ||||||
| end | end | ||||||
|  |  | ||||||
| return M | return M | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Lewis Russell
					Lewis Russell