From 0ac3c4d6314df5fe40571a83e157a425ab7ce16d Mon Sep 17 00:00:00 2001 From: Lewis Russell Date: Sat, 15 Jul 2023 16:55:32 +0100 Subject: docs(lua): move function docs to lua files --- runtime/lua/vim/_meta/diff.lua | 67 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 runtime/lua/vim/_meta/diff.lua (limited to 'runtime/lua/vim/_meta/diff.lua') diff --git a/runtime/lua/vim/_meta/diff.lua b/runtime/lua/vim/_meta/diff.lua new file mode 100644 index 0000000000..8e8aaf8b64 --- /dev/null +++ b/runtime/lua/vim/_meta/diff.lua @@ -0,0 +1,67 @@ +---@meta + +--- Run diff on strings {a} and {b}. Any indices returned by this function, +--- either directly or via callback arguments, are 1-based. +--- +--- Examples: +---
lua
+---     vim.diff('a\\n', 'b\\nc\\n')
+---     -- =>
+---     -- @@ -1 +1,2 @@
+---     -- -a
+---     -- +b
+---     -- +c
+---
+---     vim.diff('a\\n', 'b\\nc\\n', {result_type = 'indices'})
+---     -- =>
+---     -- {
+---     --   {1, 1, 1, 2}
+---     -- }
+--- 
+--- +--- @param a string First string to compare +--- @param b string Second string to compare +--- @param opts table 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 +--- See {opts.result_type}. `nil` if {opts.on_hunk} is given. +function vim.diff(a, b, opts) end -- cgit v1.3-3-g829e From 69d49727d7766d799aa1989bf67e763258b868e6 Mon Sep 17 00:00:00 2001 From: Lewis Russell Date: Mon, 17 Jul 2023 16:32:56 +0100 Subject: fix: luacheck --- runtime/lua/vim/_meta/builtin.lua | 2 ++ runtime/lua/vim/_meta/diff.lua | 2 ++ runtime/lua/vim/_meta/json.lua | 2 ++ runtime/lua/vim/_meta/misc.lua | 2 ++ runtime/lua/vim/_meta/mpack.lua | 2 ++ runtime/lua/vim/_meta/regex.lua | 4 +++- runtime/lua/vim/_meta/spell.lua | 2 ++ runtime/lua/vim/_options.lua | 8 ++++---- 8 files changed, 19 insertions(+), 5 deletions(-) (limited to 'runtime/lua/vim/_meta/diff.lua') diff --git a/runtime/lua/vim/_meta/builtin.lua b/runtime/lua/vim/_meta/builtin.lua index a1786b2cdb..1d7b1071b7 100644 --- a/runtime/lua/vim/_meta/builtin.lua +++ b/runtime/lua/vim/_meta/builtin.lua @@ -1,5 +1,7 @@ ---@meta +-- luacheck: no unused args + ---@defgroup vim.builtin --- ---@brief
help
diff --git a/runtime/lua/vim/_meta/diff.lua b/runtime/lua/vim/_meta/diff.lua
index 8e8aaf8b64..246ac0c75a 100644
--- a/runtime/lua/vim/_meta/diff.lua
+++ b/runtime/lua/vim/_meta/diff.lua
@@ -1,5 +1,7 @@
 ---@meta
 
+-- luacheck: no unused args
+
 --- Run diff on strings {a} and {b}. Any indices returned by this function,
 --- either directly or via callback arguments, are 1-based.
 ---
diff --git a/runtime/lua/vim/_meta/json.lua b/runtime/lua/vim/_meta/json.lua
index 2580b56870..76a6c7b733 100644
--- a/runtime/lua/vim/_meta/json.lua
+++ b/runtime/lua/vim/_meta/json.lua
@@ -1,5 +1,7 @@
 --- @meta
 
+-- luacheck: no unused args
+
 --- @defgroup vim.json
 ---
 --- This module provides encoding and decoding of Lua objects to and
diff --git a/runtime/lua/vim/_meta/misc.lua b/runtime/lua/vim/_meta/misc.lua
index 954e8b4675..8a76755962 100644
--- a/runtime/lua/vim/_meta/misc.lua
+++ b/runtime/lua/vim/_meta/misc.lua
@@ -1,5 +1,7 @@
 ---@meta
 
+-- luacheck: no unused args
+
 --- Invokes |vim-function| or |user-function| {func} with arguments {...}.
 --- See also |vim.fn|.
 --- Equivalent to:
diff --git a/runtime/lua/vim/_meta/mpack.lua b/runtime/lua/vim/_meta/mpack.lua
index 1bcb6845b9..54e097ad97 100644
--- a/runtime/lua/vim/_meta/mpack.lua
+++ b/runtime/lua/vim/_meta/mpack.lua
@@ -1,5 +1,7 @@
 --- @meta
 
+-- luacheck: no unused args
+
 --- @defgroup vim.mpack
 ---
 --- This module provides encoding and decoding of Lua objects to and
diff --git a/runtime/lua/vim/_meta/regex.lua b/runtime/lua/vim/_meta/regex.lua
index 0af1bccea5..4bca67797a 100644
--- a/runtime/lua/vim/_meta/regex.lua
+++ b/runtime/lua/vim/_meta/regex.lua
@@ -1,5 +1,7 @@
 --- @meta
 
+-- luacheck: no unused args
+
 --- @defgroup vim.regex
 ---
 --- @brief Vim regexes can be used directly from Lua. Currently they only allow
@@ -13,7 +15,7 @@
 function vim.regex(re) end
 
 --- @class vim.regex
-local regex = {}
+local regex = {} -- luacheck: no unused
 
 --- Match the string against the regex. If the string should match the regex
 --- precisely, surround the regex with `^` and `$`. If the was a match, the
diff --git a/runtime/lua/vim/_meta/spell.lua b/runtime/lua/vim/_meta/spell.lua
index 926c8a686d..d55867f769 100644
--- a/runtime/lua/vim/_meta/spell.lua
+++ b/runtime/lua/vim/_meta/spell.lua
@@ -1,5 +1,7 @@
 --- @meta
 
+-- luacheck: no unused args
+
 --- Check {str} for spelling errors. Similar to the Vimscript function
 --- |spellbadword()|.
 ---
diff --git a/runtime/lua/vim/_options.lua b/runtime/lua/vim/_options.lua
index d498ae0a2c..6dbe4cf64a 100644
--- a/runtime/lua/vim/_options.lua
+++ b/runtime/lua/vim/_options.lua
@@ -846,7 +846,7 @@ end
 ---
--- @diagnostic disable-next-line:unused-local used for gen_vimdoc -local Option = {} +local Option = {} -- luacheck: no unused ---Returns a Lua-representation of the option. Boolean, number and string ---values will be returned in exactly the same fashion. @@ -901,7 +901,7 @@ function Option:get() end --- ---@param value string Value to append --- @diagnostic disable-next-line:unused-local used for gen_vimdoc -function Option:append(value) end +function Option:append(value) end -- luacheck: no unused ---Prepend a value to string-style options. See |:set^=| --- @@ -911,7 +911,7 @@ function Option:append(value) end --- ---@param value string Value to prepend ---@diagnostic disable-next-line:unused-local used for gen_vimdoc -function Option:prepend(value) end +function Option:prepend(value) end -- luacheck: no unused ---Remove a value from string-style options. See |:set-=| --- @@ -921,7 +921,7 @@ function Option:prepend(value) end --- ---@param value string Value to remove ---@diagnostic disable-next-line:unused-local used for gen_vimdoc -function Option:remove(value) end +function Option:remove(value) end -- luacheck: no unused vim.opt = create_option_accessor() vim.opt_local = create_option_accessor('local') -- cgit v1.3-3-g829e