fix: type fixes

Type fixes caught by emmylua
This commit is contained in:
Lewis Russell
2025-06-05 11:31:51 +01:00
committed by Lewis Russell
parent 4c333fdbb7
commit 3b6084ddf4
51 changed files with 421 additions and 355 deletions

View File

@ -41,7 +41,6 @@ lsp._resolve_to_request = {
-- TODO improve handling of scratch buffers with LSP attached.
---@private
--- Called by the client when trying to call a method that's not
--- supported in any of the servers registered for the current buffer.
---@param method (vim.lsp.protocol.Method.ClientToServer) name of the method
@ -54,7 +53,6 @@ function lsp._unsupported_method(method)
return msg
end
---@private
---@param workspace_folders string|lsp.WorkspaceFolder[]?
---@return lsp.WorkspaceFolder[]?
function lsp._get_workspace_folders(workspace_folders)
@ -78,8 +76,7 @@ local format_line_ending = {
['mac'] = '\r',
}
---@private
---@param bufnr (number)
---@param bufnr integer
---@return string
function lsp._buf_get_line_ending(bufnr)
return format_line_ending[vim.bo[bufnr].fileformat] or '\n'
@ -110,10 +107,9 @@ lsp.client_errors = vim.tbl_extend(
client_error('ON_EXIT_CALLBACK_ERROR')
)
---@private
--- Returns full text of buffer {bufnr} as a string.
---
---@param bufnr (number) Buffer handle, or 0 for current.
---@param bufnr integer Buffer handle, or 0 for current.
---@return string # Buffer text as string.
function lsp._buf_get_full_text(bufnr)
local line_ending = lsp._buf_get_line_ending(bufnr)
@ -284,7 +280,7 @@ end
---
--- Predicate which decides if a client should be re-used. Used on all running clients. The default
--- implementation re-uses a client if name and root_dir matches.
--- @field reuse_client? fun(client: vim.lsp.Client, config: vim.lsp.ClientConfig): boolean
--- @field reuse_client? fun(client: vim.lsp.Client, config: vim.lsp.ClientConfig): boolean #
---
--- [lsp-root_dir()]()
--- Decides the workspace root: the directory where the LSP server will base its workspaceFolders,
@ -832,7 +828,6 @@ local function is_empty_or_default(bufnr, option)
return vim.startswith(scriptinfo[1].name, vim.fn.expand('$VIMRUNTIME'))
end
---@private
---@param client vim.lsp.Client
---@param bufnr integer
function lsp._set_defaults(client, bufnr)
@ -1101,8 +1096,8 @@ end
--- Checks if a buffer is attached for a particular client.
---
---@param bufnr (integer) Buffer handle, or 0 for current
---@param client_id (integer) the client id
---@param bufnr integer Buffer handle, or 0 for current
---@param client_id integer the client id
function lsp.buf_is_attached(bufnr, client_id)
return lsp.get_clients({ bufnr = bufnr, id = client_id, _uninitialized = true })[1] ~= nil
end
@ -1112,7 +1107,7 @@ end
---
---@param client_id integer client id
---
---@return (nil|vim.lsp.Client) client rpc object
---@return vim.lsp.Client? client rpc object
function lsp.get_client_by_id(client_id)
return all_clients[client_id]
end
@ -1207,7 +1202,6 @@ function lsp.get_clients(filter)
return clients
end
---@private
---@deprecated
function lsp.get_active_clients(filter)
vim.deprecate('vim.lsp.get_active_clients()', 'vim.lsp.get_clients()', '0.12')
@ -1263,7 +1257,7 @@ api.nvim_create_autocmd('VimLeavePre', {
end,
})
---@private
---@nodoc
--- Sends an async request for all active clients attached to the
--- buffer.
---
@ -1401,9 +1395,9 @@ end
---
---@since 7
---
---@param bufnr (integer|nil) The number of the buffer
---@param method (vim.lsp.protocol.Method.ClientToServer.Notification) Name of the request method
---@param params (any) Arguments to send to the server
---@param bufnr integer? The number of the buffer
---@param method vim.lsp.protocol.Method.ClientToServer.Notification Name of the request method
---@param params any Arguments to send to the server
---
---@return boolean success true if any client returns true; false otherwise
function lsp.buf_notify(bufnr, method, params)
@ -1573,7 +1567,7 @@ end
---@deprecated Use |vim.lsp.get_client_by_id()| instead.
---Checks whether a client is stopped.
---
---@param client_id (integer)
---@param client_id integer
---@return boolean stopped true if client is stopped, false otherwise.
function lsp.client_is_stopped(client_id)
vim.deprecate('vim.lsp.client_is_stopped()', 'vim.lsp.get_client_by_id()', '0.14')
@ -1584,7 +1578,7 @@ end
--- Gets a map of client_id:client pairs for the given buffer, where each value
--- is a |vim.lsp.Client| object.
---
---@param bufnr (integer|nil): Buffer handle, or 0 for current
---@param bufnr integer? Buffer handle, or 0 for current
---@return table result is table of (client_id, client) pairs
---@deprecated Use |vim.lsp.get_clients()| instead.
function lsp.buf_get_clients(bufnr)
@ -1630,7 +1624,7 @@ function lsp.get_log_path()
return log.get_filename()
end
---@private
---@nodoc
--- Invokes a function for each LSP client attached to a buffer.
---
---@param bufnr integer Buffer number