mirror of
https://github.com/neovim/neovim.git
synced 2025-12-16 03:15:39 +00:00
fix: type fixes
Type fixes caught by emmylua
This commit is contained in:
committed by
Lewis Russell
parent
4c333fdbb7
commit
3b6084ddf4
@@ -154,7 +154,6 @@ local function lint_match(buf, match, query, lang_context, diagnostics)
|
||||
end
|
||||
end
|
||||
|
||||
--- @private
|
||||
--- @param buf integer Buffer to lint
|
||||
--- @param opts vim.treesitter.query.lint.Opts|QueryLinterNormalizedOpts|nil Options for linting
|
||||
function M.lint(buf, opts)
|
||||
@@ -193,13 +192,11 @@ function M.lint(buf, opts)
|
||||
vim.diagnostic.set(namespace, buf, diagnostics)
|
||||
end
|
||||
|
||||
--- @private
|
||||
--- @param buf integer
|
||||
function M.clear(buf)
|
||||
vim.diagnostic.reset(namespace, buf)
|
||||
end
|
||||
|
||||
--- @private
|
||||
--- @param findstart 0|1
|
||||
--- @param base string
|
||||
function M.omnifunc(findstart, base)
|
||||
|
||||
@@ -72,7 +72,6 @@ M.cmp_pos = {
|
||||
|
||||
setmetatable(M.cmp_pos, { __call = cmp_pos })
|
||||
|
||||
---@private
|
||||
---Check if a variable is a valid range object
|
||||
---@param r any
|
||||
---@return boolean
|
||||
@@ -92,7 +91,6 @@ function M.validate(r)
|
||||
return true
|
||||
end
|
||||
|
||||
---@private
|
||||
---@param r1 Range
|
||||
---@param r2 Range
|
||||
---@return boolean
|
||||
@@ -113,7 +111,6 @@ function M.intercepts(r1, r2)
|
||||
return true
|
||||
end
|
||||
|
||||
---@private
|
||||
---@param r1 Range6
|
||||
---@param r2 Range6
|
||||
---@return Range6?
|
||||
@@ -126,7 +123,6 @@ function M.intersection(r1, r2)
|
||||
return { rs[1], rs[2], rs[3], re[4], re[5], re[6] }
|
||||
end
|
||||
|
||||
---@private
|
||||
---@param r Range
|
||||
---@return integer, integer, integer, integer
|
||||
function M.unpack4(r)
|
||||
@@ -137,14 +133,12 @@ function M.unpack4(r)
|
||||
return r[1], r[2], r[3 + off_1], r[4 + off_1]
|
||||
end
|
||||
|
||||
---@private
|
||||
---@param r Range6
|
||||
---@return integer, integer, integer, integer, integer, integer
|
||||
function M.unpack6(r)
|
||||
return r[1], r[2], r[3], r[4], r[5], r[6]
|
||||
end
|
||||
|
||||
---@private
|
||||
---@param r1 Range
|
||||
---@param r2 Range
|
||||
---@return boolean whether r1 contains r2
|
||||
@@ -188,7 +182,6 @@ local function get_offset(source, index)
|
||||
return byte
|
||||
end
|
||||
|
||||
---@private
|
||||
---@param source integer|string
|
||||
---@param range Range
|
||||
---@return Range6
|
||||
|
||||
@@ -15,7 +15,7 @@ local TSTreeView = {}
|
||||
---@class (private) vim.treesitter.dev.TSTreeViewOpts
|
||||
---@field anon boolean If true, display anonymous nodes.
|
||||
---@field lang boolean If true, display the language alongside each node.
|
||||
---@field indent number Number of spaces to indent nested lines.
|
||||
---@field indent integer Number of spaces to indent nested lines.
|
||||
|
||||
---@class (private) vim.treesitter.dev.Node
|
||||
---@field node TSNode Treesitter node
|
||||
@@ -290,7 +290,7 @@ end
|
||||
--- The node number is dependent on whether or not anonymous nodes are displayed.
|
||||
---
|
||||
---@param i integer Node number to get
|
||||
---@return vim.treesitter.dev.Node
|
||||
---@return vim.treesitter.dev.Node?
|
||||
---@package
|
||||
function TSTreeView:get(i)
|
||||
local t = self.opts.anon and self.nodes or self.named
|
||||
@@ -329,8 +329,7 @@ end
|
||||
--- source buffer as its only argument and should return a string.
|
||||
--- @field title (string|fun(bufnr:integer):string|nil)
|
||||
|
||||
--- @private
|
||||
---
|
||||
--- @nodoc
|
||||
--- @param opts vim.treesitter.dev.inspect_tree.Opts?
|
||||
function M.inspect_tree(opts)
|
||||
vim.validate('opts', opts, 'table', true)
|
||||
@@ -401,7 +400,7 @@ function M.inspect_tree(opts)
|
||||
|
||||
-- update source window if original was closed
|
||||
if not api.nvim_win_is_valid(win) then
|
||||
win = vim.fn.win_findbuf(buf)[1]
|
||||
win = assert(vim.fn.win_findbuf(buf)[1])
|
||||
end
|
||||
|
||||
api.nvim_set_current_win(win)
|
||||
@@ -475,7 +474,7 @@ function M.inspect_tree(opts)
|
||||
|
||||
-- update source window if original was closed
|
||||
if not api.nvim_win_is_valid(win) then
|
||||
win = vim.fn.win_findbuf(buf)[1]
|
||||
win = assert(vim.fn.win_findbuf(buf)[1])
|
||||
end
|
||||
|
||||
local topline, botline = vim.fn.line('w0', win), vim.fn.line('w$', win)
|
||||
@@ -599,7 +598,7 @@ local function update_editor_highlights(query_win, base_win, lang)
|
||||
end
|
||||
end
|
||||
|
||||
--- @private
|
||||
--- @nodoc
|
||||
--- @param lang? string language to open the query editor for.
|
||||
--- @return boolean? `true` on success, `nil` on failure
|
||||
--- @return string? error message, if applicable
|
||||
|
||||
@@ -41,7 +41,7 @@ function M.get_lang(filetype)
|
||||
return ft_to_lang[filetype]
|
||||
end
|
||||
-- for subfiletypes like html.glimmer use only "main" filetype
|
||||
filetype = vim.split(filetype, '.', { plain = true })[1]
|
||||
filetype = assert(vim.split(filetype, '.', { plain = true })[1])
|
||||
return ft_to_lang[filetype] or filetype
|
||||
end
|
||||
|
||||
|
||||
@@ -49,7 +49,10 @@ local hrtime = vim.uv.hrtime
|
||||
local default_parse_timeout_ns = 3 * 1000000
|
||||
|
||||
---@type Range2
|
||||
local entire_document_range = { 0, math.huge }
|
||||
local entire_document_range = {
|
||||
0,
|
||||
math.huge --[[@as integer]],
|
||||
}
|
||||
|
||||
---@alias TSCallbackName
|
||||
---| 'changedtree'
|
||||
|
||||
@@ -193,7 +193,7 @@ function M.get_files(lang, query_name, is_included)
|
||||
local langlist = modeline:match(MODELINE_FORMAT)
|
||||
if langlist then
|
||||
---@diagnostic disable-next-line:param-type-mismatch
|
||||
for _, incllang in ipairs(vim.split(langlist, ',', true)) do
|
||||
for _, incllang in ipairs(vim.split(langlist, ',')) do
|
||||
local is_optional = incllang:match('%(.*%)')
|
||||
|
||||
if is_optional then
|
||||
@@ -778,7 +778,7 @@ local directive_handlers = {
|
||||
--- Adds a new predicate to be used in queries
|
||||
---
|
||||
---@param name string Name of the predicate, without leading #
|
||||
---@param handler fun(match: table<integer,TSNode[]>, pattern: integer, source: integer|string, predicate: any[], metadata: vim.treesitter.query.TSMetadata): boolean?
|
||||
---@param handler fun(match: table<integer,TSNode[]>, pattern: integer, source: integer|string, predicate: any[], metadata: vim.treesitter.query.TSMetadata): boolean? #
|
||||
--- - see |vim.treesitter.query.add_directive()| for argument meanings
|
||||
---@param opts? vim.treesitter.query.add_predicate.Opts
|
||||
function M.add_predicate(name, handler, opts)
|
||||
@@ -818,7 +818,7 @@ end
|
||||
--- metadata table `metadata[capture_id].key = value`
|
||||
---
|
||||
---@param name string Name of the directive, without leading #
|
||||
---@param handler fun(match: table<integer,TSNode[]>, pattern: integer, source: integer|string, predicate: any[], metadata: vim.treesitter.query.TSMetadata)
|
||||
---@param handler fun(match: table<integer,TSNode[]>, pattern: integer, source: integer|string, predicate: any[], metadata: vim.treesitter.query.TSMetadata) #
|
||||
--- - match: A table mapping capture IDs to a list of captured nodes
|
||||
--- - pattern: the index of the matching pattern in the query file
|
||||
--- - predicate: list of strings containing the full directive being called, e.g.
|
||||
|
||||
Reference in New Issue
Block a user