aboutsummaryrefslogtreecommitdiff
path: root/runtime/lua/vim
diff options
context:
space:
mode:
authorLewis Russell <lewis6991@gmail.com>2024-10-24 09:58:22 +0100
committerLewis Russell <lewis6991@gmail.com>2024-10-24 09:58:22 +0100
commit2ee39b7eb46f091bf22dd1ba3066afff51139bdd (patch)
tree4398c744d51a1c5b61cecce84361552346211014 /runtime/lua/vim
parentad4e14c201c2f400e721362d8581f524fdad9038 (diff)
downloadrneovim-2ee39b7eb46f091bf22dd1ba3066afff51139bdd.tar.gz
rneovim-2ee39b7eb46f091bf22dd1ba3066afff51139bdd.tar.bz2
rneovim-2ee39b7eb46f091bf22dd1ba3066afff51139bdd.zip
refactor(lsp.buf): remove buf_request wrapper
Diffstat (limited to 'runtime/lua/vim')
-rw-r--r--runtime/lua/vim/lsp/buf.lua32
1 files changed, 6 insertions, 26 deletions
diff --git a/runtime/lua/vim/lsp/buf.lua b/runtime/lua/vim/lsp/buf.lua
index 0bb7904ca1..4a48172ab1 100644
--- a/runtime/lua/vim/lsp/buf.lua
+++ b/runtime/lua/vim/lsp/buf.lua
@@ -7,26 +7,6 @@ local ms = require('vim.lsp.protocol').Methods
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
--- window. The window will be dismissed on cursor move.
--- 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))
end
end
- request(name, params, req_handler)
+ lsp.buf_request(0, name, params, req_handler)
end
---@param method string
@@ -187,7 +167,7 @@ end
--- floating window.
function M.signature_help()
local params = util.make_position_params()
- request(ms.textDocument_signatureHelp, params)
+ lsp.buf_request(0, ms.textDocument_signatureHelp, params)
end
--- Retrieves the completion items at the current cursor position. Can only be
@@ -201,7 +181,7 @@ end
function M.completion(context)
local params = util.make_position_params()
params.context = context
- return request(ms.textDocument_completion, params)
+ return lsp.buf_request(0, ms.textDocument_completion, params)
end
---@param bufnr integer
@@ -609,7 +589,7 @@ end
local function call_hierarchy(method)
local params = util.make_position_params()
--- @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
vim.notify(err.message, vim.log.levels.WARN)
return
@@ -794,7 +774,7 @@ end
--- |hl-LspReferenceWrite|
function M.document_highlight()
local params = util.make_position_params()
- request(ms.textDocument_documentHighlight, params)
+ lsp.buf_request(0, ms.textDocument_documentHighlight, params)
end
--- Removes document highlights from current buffer.
@@ -1063,7 +1043,7 @@ function M.execute_command(command_params)
arguments = command_params.arguments,
workDoneToken = command_params.workDoneToken,
}
- request(ms.workspace_executeCommand, command_params)
+ lsp.buf_request(0, ms.workspace_executeCommand, command_params)
end
return M