1
0
mirror of https://github.com/SpaceVim/SpaceVim.git synced 2025-01-23 13:40:05 +08:00

feat(vim): add functions

This commit is contained in:
wsdjeg 2023-07-09 01:26:40 +08:00
parent b3906e4eaf
commit 609f3a7674

View File

@ -1,20 +1,35 @@
local M = {} local M = {}
function M.getchar(...) function M.getchar(...)
local status, ret = pcall(vim.fn.getchar, ...) local status, ret = pcall(vim.fn.getchar, ...)
if not status then if not status then
ret = 3 ret = 3
end end
if type(ret) == 'number' then return vim.fn.nr2char(ret) else return ret end if type(ret) == 'number' then
return vim.fn.nr2char(ret)
else
return ret
end
end end
function M.getchar2nr(...) function M.getchar2nr(...)
local status, ret = pcall(vim.fn.getchar, ...) local status, ret = pcall(vim.fn.getchar, ...)
if not status then if not status then
ret = 3 ret = 3
end end
if type(ret) == 'number' then return ret else return vim.fn.char2nr(ret) end if type(ret) == 'number' then
return ret
else
return vim.fn.char2nr(ret)
end
end
function M.empty(expr)
return vim.fn.empty(expr) == 1
end
function M.executable(bin)
return vim.fn.executable(bin) == 1
end end
return M return M