aboutsummaryrefslogtreecommitdiff
path: root/runtime/lua/vim/lsp
diff options
context:
space:
mode:
Diffstat (limited to 'runtime/lua/vim/lsp')
-rw-r--r--runtime/lua/vim/lsp/buf.lua15
-rw-r--r--runtime/lua/vim/lsp/handlers.lua7
-rw-r--r--runtime/lua/vim/lsp/log.lua2
-rw-r--r--runtime/lua/vim/lsp/rpc.lua17
-rw-r--r--runtime/lua/vim/lsp/sync.lua12
5 files changed, 28 insertions, 25 deletions
diff --git a/runtime/lua/vim/lsp/buf.lua b/runtime/lua/vim/lsp/buf.lua
index bac66b671d..8ae0e0cde3 100644
--- a/runtime/lua/vim/lsp/buf.lua
+++ b/runtime/lua/vim/lsp/buf.lua
@@ -13,10 +13,11 @@ local M = {}
---@param params (table|nil) Parameters to send to the server
---@param handler (function|nil) See |lsp-handler|. Follows |lsp-handler-resolution|
--
----@returns 2-tuple:
---- - Map of client-id:request-id pairs for all successful requests.
---- - Function which can be used to cancel all the requests. You could instead
---- iterate all clients and call their `cancel_request()` methods.
+---@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)
@@ -30,7 +31,7 @@ end
--- Checks whether the language servers attached to the current buffer are
--- ready.
---
----@returns `true` if server responds.
+---@return boolean if server responds.
---@deprecated
function M.server_ready()
vim.deprecate('vim.lsp.buf.server_ready', nil, '0.10.0')
@@ -108,7 +109,7 @@ end
--- Retrieves the completion items at the current cursor position. Can only be
--- called in Insert mode.
---
----@param context (context support not yet implemented) Additional information
+---@param context table (context support not yet implemented) Additional information
--- about the context in which a completion was triggered (how it was triggered,
--- and by which trigger character, if applicable)
---
@@ -549,7 +550,7 @@ end
--- call, the user is prompted to enter a string on the command line. An empty
--- string means no filtering is done.
---
----@param query (string, optional)
+---@param query string|nil optional
---@param options table|nil additional options
--- - on_list: (function) handler for list results. See |lsp-on-list-handler|
function M.workspace_symbol(query, options)
diff --git a/runtime/lua/vim/lsp/handlers.lua b/runtime/lua/vim/lsp/handlers.lua
index 70781cb7a6..20c4d7458b 100644
--- a/runtime/lua/vim/lsp/handlers.lua
+++ b/runtime/lua/vim/lsp/handlers.lua
@@ -382,7 +382,7 @@ M['textDocument/hover'] = M.hover
---@private
--- Jumps to a location. Used as a handler for multiple LSP methods.
----@param _ (not used)
+---@param _ nil not used
---@param result (table) result of LSP method; a location or a list of locations.
---@param ctx (table) table containing the context of the request, including the method
---(`textDocument/definition` can return `Location` or `Location[]`
@@ -496,8 +496,9 @@ end
--- Displays call hierarchy in the quickfix window.
---
---@param direction `"from"` for incoming calls and `"to"` for outgoing calls
----@returns `CallHierarchyIncomingCall[]` if {direction} is `"from"`,
----@returns `CallHierarchyOutgoingCall[]` if {direction} is `"to"`,
+---@return function
+--- `CallHierarchyIncomingCall[]` if {direction} is `"from"`,
+--- `CallHierarchyOutgoingCall[]` if {direction} is `"to"`,
local make_call_hierarchy_handler = function(direction)
return function(_, result)
if not result then
diff --git a/runtime/lua/vim/lsp/log.lua b/runtime/lua/vim/lsp/log.lua
index c77e7c045b..033f93bd6e 100644
--- a/runtime/lua/vim/lsp/log.lua
+++ b/runtime/lua/vim/lsp/log.lua
@@ -44,7 +44,7 @@ do
vim.fn.mkdir(vim.fn.stdpath('log'), 'p')
--- Returns the log filename.
- ---@returns (string) log filename
+ ---@return string log filename
function log.get_filename()
return logfilename
end
diff --git a/runtime/lua/vim/lsp/rpc.lua b/runtime/lua/vim/lsp/rpc.lua
index 6552eaa800..c110c3a67c 100644
--- a/runtime/lua/vim/lsp/rpc.lua
+++ b/runtime/lua/vim/lsp/rpc.lua
@@ -8,7 +8,7 @@ local is_win = uv.os_uname().version:find('Windows')
---@private
--- Checks whether a given path exists and is a directory.
---@param filename (string) path to check
----@returns (bool)
+---@return boolean
local function is_dir(filename)
local stat = uv.fs_stat(filename)
return stat and stat.type == 'directory' or false
@@ -18,7 +18,7 @@ end
--- Embeds the given string into a table and correctly computes `Content-Length`.
---
---@param encoded_message (string)
----@returns (table) table containing encoded message and `Content-Length` attribute
+---@return string containing encoded message and `Content-Length` attribute
local function format_message_with_content_length(encoded_message)
return table.concat({
'Content-Length: ',
@@ -32,7 +32,7 @@ end
--- Parses an LSP Message's header
---
---@param header string: The header to parse.
----@return table parsed headers
+---@return table # parsed headers
local function parse_headers(header)
assert(type(header) == 'string', 'header must be a string')
local headers = {}
@@ -190,7 +190,8 @@ end
---
---@param method (string) The invoked LSP method
---@param params (table): Parameters for the invoked LSP method
----@returns `nil` and `vim.lsp.protocol.ErrorCodes.MethodNotFound`.
+---@return nil
+---@return table `vim.lsp.protocol.ErrorCodes.MethodNotFound`
function default_dispatchers.server_request(method, params)
local _ = log.debug() and log.debug('server_request', method, params)
return nil, rpc_response_error(protocol.ErrorCodes.MethodNotFound)
@@ -268,7 +269,7 @@ end
--- Sends a notification to the LSP server.
---@param method (string) The invoked LSP method
---@param params (any): Parameters for the invoked LSP method
----@returns (bool) `true` if notification could be sent, `false` if not
+---@return boolean `true` if notification could be sent, `false` if not
function Client:notify(method, params)
return self:encode_and_send({
jsonrpc = '2.0',
@@ -522,7 +523,7 @@ local function public_client(client)
--- Sends a notification to the LSP server.
---@param method (string) The invoked LSP method
---@param params (table|nil): Parameters for the invoked LSP method
- ---@returns (bool) `true` if notification could be sent, `false` if not
+ ---@return boolean `true` if notification could be sent, `false` if not
function result.notify(method, params)
return client:notify(method, params)
end
@@ -624,9 +625,7 @@ end
--- server process. May contain:
--- - {cwd} (string) Working directory for the LSP server process
--- - {env} (table) Additional environment variables for LSP server process
----@returns Client RPC object.
----
----@returns Methods:
+---@return table|nil Client RPC object, with these methods:
--- - `notify()` |vim.lsp.rpc.notify()|
--- - `request()` |vim.lsp.rpc.request()|
--- - `is_closing()` returns a boolean indicating if the RPC is closing.
diff --git a/runtime/lua/vim/lsp/sync.lua b/runtime/lua/vim/lsp/sync.lua
index fb5b0b3194..350c096b47 100644
--- a/runtime/lua/vim/lsp/sync.lua
+++ b/runtime/lua/vim/lsp/sync.lua
@@ -94,7 +94,8 @@ end
---@param line string the line to index into
---@param byte integer the byte idx
---@param offset_encoding string utf-8|utf-16|utf-32|nil (default: utf-8)
----@returns table<string, int> byte_idx and char_idx of first change position
+---@return integer byte_idx of first change position
+---@return integer char_idx of first change position
local function align_end_position(line, byte, offset_encoding)
local char
-- If on the first byte, or an empty string: the trivial case
@@ -129,7 +130,7 @@ end
---@param lastline integer lastline from on_lines, adjusted to 1-index
---@param new_lastline integer new_lastline from on_lines, adjusted to 1-index
---@param offset_encoding string utf-8|utf-16|utf-32|nil (fallback to utf-8)
----@returns table<int, int> line_idx, byte_idx, and char_idx of first change position
+---@return table result table include line_idx, byte_idx, and char_idx of first change position
local function compute_start_range(
prev_lines,
curr_lines,
@@ -209,7 +210,8 @@ end
---@param lastline integer
---@param new_lastline integer
---@param offset_encoding string
----@returns (int, int) end_line_idx and end_col_idx of range
+---@return integer|table end_line_idx and end_col_idx of range
+---@return table|nil end_col_idx of range
local function compute_end_range(
prev_lines,
curr_lines,
@@ -310,7 +312,7 @@ end
---@param lines table list of lines
---@param start_range table table returned by first_difference
---@param end_range table new_end_range returned by last_difference
----@returns string text extracted from defined region
+---@return string text extracted from defined region
local function extract_text(lines, start_range, end_range, line_ending)
if not lines[start_range.line_idx] then
return ''
@@ -392,7 +394,7 @@ end
---@param lastline integer line to begin search in old_lines for last difference
---@param new_lastline integer line to begin search in new_lines for last difference
---@param offset_encoding string encoding requested by language server
----@returns table TextDocumentContentChangeEvent see https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#textDocumentContentChangeEvent
+---@return table TextDocumentContentChangeEvent see https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#textDocumentContentChangeEvent
function M.compute_diff(
prev_lines,
curr_lines,