init
This commit is contained in:
30
.config/nvim/pack/vendor/start/plenary.nvim/scripts/vararg/rotate.lua
vendored
Normal file
30
.config/nvim/pack/vendor/start/plenary.nvim/scripts/vararg/rotate.lua
vendored
Normal file
@@ -0,0 +1,30 @@
|
||||
---@brief [[
|
||||
---Do not edit this file, it was generated!
|
||||
---Provides a function to rotate a lua vararg
|
||||
---@brief ]]
|
||||
|
||||
local tbl = require('plenary.tbl')
|
||||
|
||||
local rotate_lookup = {}
|
||||
|
||||
{% for n in range(1, amount) %}
|
||||
rotate_lookup[{{n}}] = function ({% for n in range(n) %} A{{n}} {{ ", " if not loop.last else "" }} {% endfor %})
|
||||
return {% for n in range(1, n) %} A{{n}}, {% endfor %} A0
|
||||
end
|
||||
{% endfor %}
|
||||
|
||||
local function rotate_n(first, ...)
|
||||
local n = select("#", ...) + 1
|
||||
local args = tbl.pack(...)
|
||||
args[n] = first
|
||||
return tbl.unpack(args, 1, n)
|
||||
end
|
||||
|
||||
local function rotate(nargs, ...)
|
||||
if nargs == nil or nargs < 1 then
|
||||
return
|
||||
end
|
||||
return (rotate_lookup[nargs] or rotate_n)(...)
|
||||
end
|
||||
|
||||
return rotate
|
||||
Reference in New Issue
Block a user