mirror of
https://github.com/jdhao/nvim-config.git
synced 2025-06-08 14:14:33 +02:00
update type hint for functions
This commit is contained in:
parent
acc3ed7829
commit
b728b39784
@ -11,9 +11,8 @@ function M.executable(name)
|
|||||||
end
|
end
|
||||||
|
|
||||||
--- check whether a feature exists in Nvim
|
--- check whether a feature exists in Nvim
|
||||||
--- @feat: string
|
--- @param feat string the feature name, like `nvim-0.7` or `unix`.
|
||||||
--- the feature name, like `nvim-0.7` or `unix`.
|
--- @return boolean
|
||||||
--- return: bool
|
|
||||||
M.has = function(feat)
|
M.has = function(feat)
|
||||||
if fn.has(feat) == 1 then
|
if fn.has(feat) == 1 then
|
||||||
return true
|
return true
|
||||||
@ -33,8 +32,9 @@ end
|
|||||||
|
|
||||||
--- Generate random integers in the range [Low, High], inclusive,
|
--- Generate random integers in the range [Low, High], inclusive,
|
||||||
--- adapted from https://stackoverflow.com/a/12739441/6064933
|
--- adapted from https://stackoverflow.com/a/12739441/6064933
|
||||||
--- @low: the lower value for this range
|
--- @param low integer the lower value for this range
|
||||||
--- @high: the upper value for this range
|
--- @param high integer the upper value for this range
|
||||||
|
--- @return integer
|
||||||
function M.rand_int(low, high)
|
function M.rand_int(low, high)
|
||||||
-- Use lua to generate random int, see also: https://stackoverflow.com/a/20157671/6064933
|
-- Use lua to generate random int, see also: https://stackoverflow.com/a/20157671/6064933
|
||||||
math.randomseed(os.time())
|
math.randomseed(os.time())
|
||||||
@ -43,17 +43,11 @@ function M.rand_int(low, high)
|
|||||||
end
|
end
|
||||||
|
|
||||||
--- Select a random element from a sequence/list.
|
--- Select a random element from a sequence/list.
|
||||||
--- @seq: the sequence to choose an element
|
--- @param seq any[] the sequence to choose an element
|
||||||
function M.rand_element(seq)
|
function M.rand_element(seq)
|
||||||
local idx = M.rand_int(1, #seq)
|
local idx = M.rand_int(1, #seq)
|
||||||
|
|
||||||
return seq[idx]
|
return seq[idx]
|
||||||
end
|
end
|
||||||
|
|
||||||
function M.add_pack(name)
|
|
||||||
local status, error = pcall(vim.cmd, "packadd " .. name)
|
|
||||||
|
|
||||||
return status
|
|
||||||
end
|
|
||||||
|
|
||||||
return M
|
return M
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user