Some checks failed
Detach Plugins / check (FlyGrep.vim) (push) Has been cancelled
Detach Plugins / check (GitHub.vim) (push) Has been cancelled
Detach Plugins / check (JavaUnit.vim) (push) Has been cancelled
Detach Plugins / check (SourceCounter.vim) (push) Has been cancelled
Detach Plugins / check (cpicker.nvim) (push) Has been cancelled
Detach Plugins / check (dein-ui.vim) (push) Has been cancelled
Detach Plugins / check (git.vim) (push) Has been cancelled
Detach Plugins / check (iedit.vim) (push) Has been cancelled
Detach Plugins / check (scrollbar.vim) (push) Has been cancelled
Detach Plugins / check (vim-chat) (push) Has been cancelled
Detach Plugins / check (vim-cheat) (push) Has been cancelled
Detach Plugins / check (vim-todo) (push) Has been cancelled
Detach Plugins / check (xmake.vim) (push) Has been cancelled
test / Linux (nvim, nightly) (push) Has been cancelled
test / Linux (nvim, v0.3.8) (push) Has been cancelled
test / Linux (nvim, v0.4.0) (push) Has been cancelled
test / Linux (nvim, v0.4.2) (push) Has been cancelled
test / Linux (nvim, v0.4.3) (push) Has been cancelled
test / Linux (nvim, v0.4.4) (push) Has been cancelled
test / Linux (nvim, v0.5.0) (push) Has been cancelled
test / Linux (nvim, v0.5.1) (push) Has been cancelled
test / Linux (nvim, v0.6.0) (push) Has been cancelled
test / Linux (nvim, v0.6.1) (push) Has been cancelled
test / Linux (nvim, v0.7.0) (push) Has been cancelled
test / Linux (nvim, v0.7.2) (push) Has been cancelled
test / Linux (nvim, v0.8.0) (push) Has been cancelled
test / Linux (nvim, v0.8.1) (push) Has been cancelled
test / Linux (nvim, v0.8.2) (push) Has been cancelled
test / Linux (nvim, v0.8.3) (push) Has been cancelled
test / Linux (nvim, v0.9.0) (push) Has been cancelled
test / Linux (nvim, v0.9.1) (push) Has been cancelled
test / Linux (true, vim, v7.4.052) (push) Has been cancelled
test / Linux (true, vim, v7.4.1689) (push) Has been cancelled
test / Linux (true, vim, v7.4.629) (push) Has been cancelled
test / Linux (true, vim, v8.0.0027) (push) Has been cancelled
test / Linux (true, vim, v8.0.0183) (push) Has been cancelled
test / Linux (vim, nightly) (push) Has been cancelled
test / Linux (vim, v8.0.0184) (push) Has been cancelled
test / Linux (vim, v8.0.1453) (push) Has been cancelled
test / Linux (vim, v8.1.2269) (push) Has been cancelled
test / Linux (vim, v8.2.2434) (push) Has been cancelled
test / Linux (vim, v8.2.3995) (push) Has been cancelled
test / Windows (nvim, nightly) (push) Has been cancelled
test / Windows (nvim, v0.3.8) (push) Has been cancelled
test / Windows (nvim, v0.4.2) (push) Has been cancelled
test / Windows (nvim, v0.4.3) (push) Has been cancelled
test / Windows (nvim, v0.4.4) (push) Has been cancelled
test / Windows (nvim, v0.5.0) (push) Has been cancelled
test / Windows (nvim, v0.5.1) (push) Has been cancelled
test / Windows (nvim, v0.6.0) (push) Has been cancelled
test / Windows (nvim, v0.6.1) (push) Has been cancelled
test / Windows (nvim, v0.7.0) (push) Has been cancelled
test / Windows (nvim, v0.7.2) (push) Has been cancelled
test / Windows (nvim, v0.8.0) (push) Has been cancelled
test / Windows (nvim, v0.8.1) (push) Has been cancelled
test / Windows (nvim, v0.8.2) (push) Has been cancelled
test / Windows (nvim, v0.8.3) (push) Has been cancelled
test / Windows (nvim, v0.9.0) (push) Has been cancelled
test / Windows (nvim, v0.9.1) (push) Has been cancelled
test / Windows (vim, nightly) (push) Has been cancelled
test / Windows (vim, v7.4.1185) (push) Has been cancelled
test / Windows (vim, v7.4.1689) (push) Has been cancelled
test / Windows (vim, v8.0.0027) (push) Has been cancelled
test / Windows (vim, v8.0.1453) (push) Has been cancelled
test / Windows (vim, v8.1.2269) (push) Has been cancelled
test / Windows (vim, v8.2.2434) (push) Has been cancelled
test / Windows (vim, v8.2.3995) (push) Has been cancelled
docker / docker (push) Has been cancelled
mirror / check (coding) (push) Has been cancelled
mirror / check (gitee) (push) Has been cancelled
mirror / check (gitlab) (push) Has been cancelled
101 lines
2.4 KiB
Lua
101 lines
2.4 KiB
Lua
local M = {}
|
|
|
|
|
|
function M.eval(l)
|
|
if vim.api ~= nil then
|
|
return vim.api.nvim_eval(l)
|
|
else
|
|
return vim.eval(l)
|
|
end
|
|
end
|
|
|
|
if vim.command ~= nil then
|
|
function M.cmd(command)
|
|
return vim.command(command)
|
|
end
|
|
else
|
|
function M.cmd(command)
|
|
return vim.api.nvim_command(command)
|
|
end
|
|
end
|
|
|
|
-- there is no want to call viml function in old vim and neovim
|
|
|
|
local function build_argv(...)
|
|
local str = ''
|
|
for index, value in ipairs(...) do
|
|
if str ~= '' then
|
|
str = str .. ','
|
|
end
|
|
if type(value) == 'string' then
|
|
str = str .. '"' .. value .. '"'
|
|
elseif type(value) == 'number' then
|
|
str = str .. value
|
|
end
|
|
end
|
|
return str
|
|
end
|
|
|
|
function M.call(funcname, ...)
|
|
if vim.call ~= nil then
|
|
return vim.call(funcname, ...)
|
|
else
|
|
if vim.api ~= nil then
|
|
return vim.api.nvim_call_function(funcname, {...})
|
|
else
|
|
-- call not call vim script function in lua
|
|
vim.command('let g:lua_rst = ' .. funcname .. '(' .. build_argv({...}) .. ')')
|
|
return M.eval('g:lua_rst')
|
|
end
|
|
end
|
|
end
|
|
|
|
-- this is for Vim and old neovim
|
|
M.fn = setmetatable({}, {
|
|
__index = function(t, key)
|
|
local _fn
|
|
if vim.api ~= nil and vim.api[key] ~= nil then
|
|
_fn = function()
|
|
error(string.format("Tried to call API function with vim.fn: use vim.api.%s instead", key))
|
|
end
|
|
else
|
|
_fn = function(...)
|
|
return M.call(key, ...)
|
|
end
|
|
end
|
|
t[key] = _fn
|
|
return _fn
|
|
end
|
|
})
|
|
|
|
-- This is for vim and old neovim to use vim.o
|
|
M.vim_options = setmetatable({}, {
|
|
__index = function(t, key)
|
|
local _fn
|
|
if vim.api ~= nil then
|
|
-- for neovim
|
|
return vim.api.nvim_get_option(key)
|
|
else
|
|
-- for vim
|
|
_fn = M.eval('&' .. key)
|
|
end
|
|
t[key] = _fn
|
|
return _fn
|
|
end
|
|
})
|
|
|
|
-- this function is only for vim
|
|
function M.has(feature)
|
|
return M.eval('float2nr(has("' .. feature .. '"))')
|
|
end
|
|
|
|
function M.echo(msg)
|
|
if vim.api ~= nil then
|
|
vim.api.nvim_echo({{msg}}, false, {})
|
|
else
|
|
vim.command('echo ' .. build_argv({msg}))
|
|
end
|
|
end
|
|
|
|
return M
|