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
|
||||
|
||||
--- check whether a feature exists in Nvim
|
||||
--- @feat: string
|
||||
--- the feature name, like `nvim-0.7` or `unix`.
|
||||
--- return: bool
|
||||
--- @param feat string the feature name, like `nvim-0.7` or `unix`.
|
||||
--- @return boolean
|
||||
M.has = function(feat)
|
||||
if fn.has(feat) == 1 then
|
||||
return true
|
||||
@ -33,8 +32,9 @@ end
|
||||
|
||||
--- Generate random integers in the range [Low, High], inclusive,
|
||||
--- adapted from https://stackoverflow.com/a/12739441/6064933
|
||||
--- @low: the lower value for this range
|
||||
--- @high: the upper value for this range
|
||||
--- @param low integer the lower value for this range
|
||||
--- @param high integer the upper value for this range
|
||||
--- @return integer
|
||||
function M.rand_int(low, high)
|
||||
-- Use lua to generate random int, see also: https://stackoverflow.com/a/20157671/6064933
|
||||
math.randomseed(os.time())
|
||||
@ -43,17 +43,11 @@ function M.rand_int(low, high)
|
||||
end
|
||||
|
||||
--- 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)
|
||||
local idx = M.rand_int(1, #seq)
|
||||
|
||||
return seq[idx]
|
||||
end
|
||||
|
||||
function M.add_pack(name)
|
||||
local status, error = pcall(vim.cmd, "packadd " .. name)
|
||||
|
||||
return status
|
||||
end
|
||||
|
||||
return M
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user