aboutsummaryrefslogtreecommitdiff
path: root/runtime/lua/vim/_meta
diff options
context:
space:
mode:
authorLewis Russell <lewis6991@gmail.com>2024-04-26 14:07:47 +0100
committerLewis Russell <me@lewisr.dev>2024-04-26 15:13:06 +0100
commitb8273c9a339626078d49e706d882878090b07d42 (patch)
tree92684f3aff0b70b317119f1b955e93b5a25b7e90 /runtime/lua/vim/_meta
parentc5b9fb2f256516398592c81f496dae75a036b18e (diff)
downloadrneovim-b8273c9a339626078d49e706d882878090b07d42.tar.gz
rneovim-b8273c9a339626078d49e706d882878090b07d42.tar.bz2
rneovim-b8273c9a339626078d49e706d882878090b07d42.zip
fix: lua annotations
Diffstat (limited to 'runtime/lua/vim/_meta')
-rw-r--r--runtime/lua/vim/_meta/base64.lua4
-rw-r--r--runtime/lua/vim/_meta/builtin.lua25
-rw-r--r--runtime/lua/vim/_meta/diff.lua85
-rw-r--r--runtime/lua/vim/_meta/re.lua4
-rw-r--r--runtime/lua/vim/_meta/spell.lua6
5 files changed, 62 insertions, 62 deletions
diff --git a/runtime/lua/vim/_meta/base64.lua b/runtime/lua/vim/_meta/base64.lua
index f25b4af234..8ba59e1703 100644
--- a/runtime/lua/vim/_meta/base64.lua
+++ b/runtime/lua/vim/_meta/base64.lua
@@ -3,11 +3,11 @@
--- Encode {str} using Base64.
---
--- @param str string String to encode
---- @return string Encoded string
+--- @return string : Encoded string
function vim.base64.encode(str) end
--- Decode a Base64 encoded string.
---
--- @param str string Base64 encoded string
---- @return string Decoded string
+--- @return string : Decoded string
function vim.base64.decode(str) end
diff --git a/runtime/lua/vim/_meta/builtin.lua b/runtime/lua/vim/_meta/builtin.lua
index 20b6d9dabe..75737bd040 100644
--- a/runtime/lua/vim/_meta/builtin.lua
+++ b/runtime/lua/vim/_meta/builtin.lua
@@ -119,15 +119,15 @@ function vim.stricmp(a, b) end
--- An {index} in the middle of a UTF-16 sequence is rounded upwards to
--- the end of that sequence.
--- @param str string
---- @param index number
---- @param use_utf16? any
+--- @param index integer
+--- @param use_utf16? boolean
function vim.str_byteindex(str, index, use_utf16) end
--- Gets a list of the starting byte positions of each UTF-8 codepoint in the given string.
---
--- Embedded NUL bytes are treated as terminating the string.
--- @param str string
---- @return table
+--- @return integer[]
function vim.str_utf_pos(str) end
--- Gets the distance (in bytes) from the starting byte of the codepoint (character) that {index}
@@ -148,8 +148,8 @@ function vim.str_utf_pos(str) end
--- ```
---
--- @param str string
---- @param index number
---- @return number
+--- @param index integer
+--- @return integer
function vim.str_utf_start(str, index) end
--- Gets the distance (in bytes) from the last byte of the codepoint (character) that {index} points
@@ -168,8 +168,8 @@ function vim.str_utf_start(str, index) end
--- ```
---
--- @param str string
---- @param index number
---- @return number
+--- @param index integer
+--- @return integer
function vim.str_utf_end(str, index) end
--- Convert byte index to UTF-32 and UTF-16 indices. If {index} is not
@@ -180,7 +180,7 @@ function vim.str_utf_end(str, index) end
--- {index} in the middle of a UTF-8 sequence is rounded upwards to the end of
--- that sequence.
--- @param str string
---- @param index? number
+--- @param index? integer
--- @return integer UTF-32 index
--- @return integer UTF-16 index
function vim.str_utfindex(str, index) end
@@ -193,15 +193,14 @@ function vim.str_utfindex(str, index) end
--- can accept, see ":Man 3 iconv".
---
--- @param str string Text to convert
---- @param from number Encoding of {str}
---- @param to number Target encoding
---- @param opts? table<string,any>
---- @return string|nil Converted string if conversion succeeds, `nil` otherwise.
+--- @param from string Encoding of {str}
+--- @param to string Target encoding
+--- @return string? : Converted string if conversion succeeds, `nil` otherwise.
function vim.iconv(str, from, to, opts) end
--- Schedules {fn} to be invoked soon by the main event-loop. Useful
--- to avoid |textlock| or other temporary restrictions.
---- @param fn function
+--- @param fn fun()
function vim.schedule(fn) end
--- Wait for {time} in milliseconds until {callback} returns `true`.
diff --git a/runtime/lua/vim/_meta/diff.lua b/runtime/lua/vim/_meta/diff.lua
index f265139448..617bc87f59 100644
--- a/runtime/lua/vim/_meta/diff.lua
+++ b/runtime/lua/vim/_meta/diff.lua
@@ -1,5 +1,46 @@
---@meta
+--- Optional parameters:
+--- @class vim.diff.Opts
+--- @inlinedoc
+---
+--- Invoked for each hunk in the diff. Return a negative number
+--- to cancel the callback for any remaining hunks.
+--- Arguments:
+--- - `start_a` (`integer`): Start line of hunk in {a}.
+--- - `count_a` (`integer`): Hunk size in {a}.
+--- - `start_b` (`integer`): Start line of hunk in {b}.
+--- - `count_b` (`integer`): Hunk size in {b}.
+--- @field on_hunk fun(start_a: integer, count_a: integer, start_b: integer, count_b: integer): integer
+---
+--- Form of the returned diff:
+--- - `unified`: String in unified format.
+--- - `indices`: Array of hunk locations.
+--- Note: This option is ignored if `on_hunk` is used.
+--- (default: `'unified'`)
+--- @field result_type 'unified'|'indices'
+---
+--- Run linematch on the resulting hunks from xdiff. When integer, only hunks
+--- upto this size in lines are run through linematch.
+--- Requires `result_type = indices`, ignored otherwise.
+--- @field linematch boolean|integer
+---
+--- Diff algorithm to use. Values:
+--- - `myers`: the default algorithm
+--- - `minimal`: spend extra time to generate the smallest possible diff
+--- - `patience`: patience diff algorithm
+--- - `histogram`: histogram diff algorithm
+--- (default: `'myers'`)
+--- @field algorithm 'myers'|'minimal'|'patience'|'histogram'
+--- @field ctxlen integer Context length
+--- @field interhunkctxlen integer Inter hunk context length
+--- @field ignore_whitespace boolean Ignore whitespace
+--- @field ignore_whitespace_change boolean Ignore whitespace change
+--- @field ignore_whitespace_change_at_eol boolean Ignore whitespace change at end-of-line.
+--- @field ignore_cr_at_eol boolean Ignore carriage return at end-of-line
+--- @field ignore_blank_lines boolean Ignore blank lines
+--- @field indent_heuristic boolean Use the indent heuristic for the internal diff library.
+
-- luacheck: no unused args
--- Run diff on strings {a} and {b}. Any indices returned by this function,
@@ -24,47 +65,7 @@
---
---@param a string First string to compare
---@param b string Second string to compare
----@param opts table<string,any> Optional parameters:
---- - `on_hunk` (callback):
---- Invoked for each hunk in the diff. Return a negative number
---- to cancel the callback for any remaining hunks.
---- Args:
---- - `start_a` (integer): Start line of hunk in {a}.
---- - `count_a` (integer): Hunk size in {a}.
---- - `start_b` (integer): Start line of hunk in {b}.
---- - `count_b` (integer): Hunk size in {b}.
---- - `result_type` (string): Form of the returned diff:
---- - "unified": (default) String in unified format.
---- - "indices": Array of hunk locations.
---- Note: This option is ignored if `on_hunk` is used.
---- - `linematch` (boolean|integer): Run linematch on the resulting hunks
---- from xdiff. When integer, only hunks upto this size in
---- lines are run through linematch. Requires `result_type = indices`,
---- ignored otherwise.
---- - `algorithm` (string):
---- Diff algorithm to use. Values:
---- - "myers" the default algorithm
---- - "minimal" spend extra time to generate the
---- smallest possible diff
---- - "patience" patience diff algorithm
---- - "histogram" histogram diff algorithm
---- - `ctxlen` (integer): Context length
---- - `interhunkctxlen` (integer):
---- Inter hunk context length
---- - `ignore_whitespace` (boolean):
---- Ignore whitespace
---- - `ignore_whitespace_change` (boolean):
---- Ignore whitespace change
---- - `ignore_whitespace_change_at_eol` (boolean)
---- Ignore whitespace change at end-of-line.
---- - `ignore_cr_at_eol` (boolean)
---- Ignore carriage return at end-of-line
---- - `ignore_blank_lines` (boolean)
---- Ignore blank lines
---- - `indent_heuristic` (boolean):
---- Use the indent heuristic for the internal
---- diff library.
----
----@return string|table|nil
+---@param opts vim.diff.Opts
+---@return string|integer[][]?
--- See {opts.result_type}. `nil` if {opts.on_hunk} is given.
function vim.diff(a, b, opts) end
diff --git a/runtime/lua/vim/_meta/re.lua b/runtime/lua/vim/_meta/re.lua
index 14c94c7824..9721e6f8c8 100644
--- a/runtime/lua/vim/_meta/re.lua
+++ b/runtime/lua/vim/_meta/re.lua
@@ -30,8 +30,8 @@ function vim.re.compile(string, defs) end
--- @param subject string
--- @param pattern vim.lpeg.Pattern|string
--- @param init? integer
---- @return integer|nil the index where the occurrence starts, nil if no match
---- @return integer|nil the index where the occurrence ends, nil if no match
+--- @return integer|nil : the index where the occurrence starts, nil if no match
+--- @return integer|nil : the index where the occurrence ends, nil if no match
function vim.re.find(subject, pattern, init) end
--- Does a global substitution, replacing all occurrences of {pattern} in the given {subject} by
diff --git a/runtime/lua/vim/_meta/spell.lua b/runtime/lua/vim/_meta/spell.lua
index 57f2180895..c636db3b53 100644
--- a/runtime/lua/vim/_meta/spell.lua
+++ b/runtime/lua/vim/_meta/spell.lua
@@ -3,11 +3,11 @@
-- luacheck: no unused args
--- Check {str} for spelling errors. Similar to the Vimscript function
---- |spellbadword()|.
+--- [spellbadword()].
---
--- Note: The behaviour of this function is dependent on: 'spelllang',
--- 'spellfile', 'spellcapcheck' and 'spelloptions' which can all be local to
---- the buffer. Consider calling this with |nvim_buf_call()|.
+--- the buffer. Consider calling this with [nvim_buf_call()].
---
--- Example:
---
@@ -20,7 +20,7 @@
--- ```
---
--- @param str string
---- @return {[1]: string, [2]: string, [3]: string}[]
+--- @return {[1]: string, [2]: 'bad'|'rare'|'local'|'caps', [3]: integer}[]
--- List of tuples with three items:
--- - The badly spelled word.
--- - The type of the spelling error: