Format with stylua

This commit is contained in:
FollieHiyuki
2022-02-22 22:29:24 +07:00
parent 142963e97c
commit d980dbf947
18 changed files with 875 additions and 830 deletions

View File

@@ -4,28 +4,33 @@ local M = {}
---@param keys table|string
---@param action string
function M.nmap(bufnr, keys, action)
if type(keys) == 'string' then keys = {keys} end
if type(keys) == 'string' then
keys = { keys }
end
for _, value in ipairs(keys) do
vim.api.nvim_buf_set_keymap(bufnr, "n", value, action,
{silent = true, noremap = true})
end
for _, value in ipairs(keys) do
vim.api.nvim_buf_set_keymap(bufnr, 'n', value, action, { silent = true, noremap = true })
end
end
--- @param f function
--- @param delay number
--- @return function
function M.debounce(f, delay)
local timer = vim.loop.new_timer()
local timer = vim.loop.new_timer()
return function (...)
local args = { ... }
return function(...)
local args = { ... }
timer:start(delay, 0, vim.schedule_wrap(function ()
timer:stop()
f(unpack(args))
end))
end
timer:start(
delay,
0,
vim.schedule_wrap(function()
timer:stop()
f(unpack(args))
end)
)
end
end
return M