mirror of
https://github.com/SpaceVim/SpaceVim.git
synced 2025-01-24 09:30:04 +08:00
27 lines
631 B
Lua
Vendored
27 lines
631 B
Lua
Vendored
---@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(0, 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 args = tbl.pack(...)
|
|
args[#args+1] = first
|
|
return tbl.unpack(args)
|
|
end
|
|
|
|
local function rotate(nargs, ...)
|
|
return (rotate_lookup[nargs] or rotate_n)(...)
|
|
end
|
|
|
|
return rotate
|