nvim/lua/G.lua
2023-11-22 23:19:24 +08:00

58 lines
1.1 KiB
Lua

local G = {}
G.g = vim.g
G.b = vim.b
G.o = vim.o
G.fn = vim.fn
G.api = vim.api
G.opt = vim.opt
G.loop = vim.loop
G.lb = vim.lsp.buf
G.dic = vim.diagnostic
G.cgp = vim.nvim_create_augroup
function G.map(maps)
for _,map in pairs(maps) do
if #map == 3 then
vim.keymap.set(map[1], map[2], map[3], {noremap = true})
elseif #map == 4 then
vim.keymap.set(map[1], map[2], map[3], map[4])
else
print("太多变量了")
end
--G.api.nvim_set_keymap(map[1], map[2], map[3], map[4])
end
end
function G.delmap(maps)
for _,map in pairs(maps) do
if #map == 2 then
vim.keymap.del(map[1], map[2], {})
elseif #map == 3 then
vim.keymap.del(map[1], map[2], map[3])
else
print("太多变量了")
end
end
end
function G.cmd(cmd)
G.api.nvim_command(cmd)
end
function G.exec(c)
G.api.nvim_exec(c)
end
function G.eval(c)
return G.api.nvim_eval(c)
end
function G.au(even, opts)
return G.api.nvim_create_autocmd(even, opts)
end
G.g.mapleader = ' '
return G