1
0
mirror of https://github.com/jdhao/nvim-config.git synced 2025-06-08 14:14:33 +02:00

refactor: theme.vim --> theme.lua

This commit is contained in:
jdhao
2022-08-26 18:42:30 +08:00
parent 6539e72a5d
commit 59525c5577
5 changed files with 150 additions and 126 deletions

View File

@@ -31,4 +31,30 @@ function M.get_nvim_version()
return nvim_ver_str
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
function M.rand_int(low, high)
-- Use lua to generate random int, see also: https://stackoverflow.com/a/20157671/6064933
math.randomseed(os.time())
return math.random(low, high)
end
--- Select a random element from a sequence/list.
--- @seq: 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