2022-07-10 20:51:19 +08:00
|
|
|
local M = {}
|
|
|
|
|
|
|
|
function M.getchar(...)
|
2023-07-09 01:26:40 +08:00
|
|
|
local status, ret = pcall(vim.fn.getchar, ...)
|
|
|
|
if not status then
|
|
|
|
ret = 3
|
|
|
|
end
|
|
|
|
if type(ret) == 'number' then
|
|
|
|
return vim.fn.nr2char(ret)
|
|
|
|
else
|
|
|
|
return ret
|
|
|
|
end
|
2022-07-10 20:51:19 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
function M.getchar2nr(...)
|
2023-07-09 01:26:40 +08:00
|
|
|
local status, ret = pcall(vim.fn.getchar, ...)
|
|
|
|
if not status then
|
|
|
|
ret = 3
|
|
|
|
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
|
2022-07-10 20:51:19 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
return M
|