From b728b3978421048e8a0336ea7a09cfcc0507f92f Mon Sep 17 00:00:00 2001 From: jdhao Date: Mon, 5 Aug 2024 23:34:19 +0200 Subject: [PATCH] update type hint for functions --- lua/utils.lua | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/lua/utils.lua b/lua/utils.lua index fef41782..6b279d62 100644 --- a/lua/utils.lua +++ b/lua/utils.lua @@ -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