1
0
mirror of https://github.com/SpaceVim/SpaceVim.git synced 2025-02-03 22:40:05 +08:00
SpaceVim/lua/spacevim/api/vim.lua

51 lines
977 B
Lua
Raw Normal View History

2022-07-10 20:51:19 +08:00
local M = {}
function M.getchar(...)
2023-08-09 03:43:53 +08:00
if vim.fn.empty(vim.g._spacevim_input_list) == 0 then
local input_list = vim.g._spacevim_input_list
local input_timeout = vim.g._spacevim_input_timeout or 0
if input_timeout > 0 then
vim.cmd('sleep ' .. input_timeout .. 'm')
end
local char = table.remove(input_list, 1)
vim.g._spacevim_input_list = input_list
return char
end
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.setbufvar(buf, opts)
end
2022-07-10 20:51:19 +08:00
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