2023-01-24 22:27:07 +08:00
|
|
|
local G = {}
|
|
|
|
|
2024-01-16 20:16:19 +08:00
|
|
|
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
|
2023-01-24 22:27:07 +08:00
|
|
|
|
|
|
|
function G.map(maps)
|
2024-01-16 20:16:19 +08:00
|
|
|
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("太多变量了")
|
2023-01-24 22:27:07 +08:00
|
|
|
end
|
2024-01-16 20:16:19 +08:00
|
|
|
--G.api.nvim_set_keymap(map[1], map[2], map[3], map[4])
|
|
|
|
end
|
2023-01-24 22:27:07 +08:00
|
|
|
end
|
|
|
|
|
2023-11-22 23:19:24 +08:00
|
|
|
function G.delmap(maps)
|
2024-01-16 20:16:19 +08:00
|
|
|
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("太多变量了")
|
2023-11-22 23:19:24 +08:00
|
|
|
end
|
2024-01-16 20:16:19 +08:00
|
|
|
end
|
2023-11-22 23:19:24 +08:00
|
|
|
end
|
|
|
|
|
2023-01-24 22:27:07 +08:00
|
|
|
function G.cmd(cmd)
|
2024-01-16 20:16:19 +08:00
|
|
|
G.api.nvim_command(cmd)
|
2023-01-24 22:27:07 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
function G.exec(c)
|
2024-01-16 20:16:19 +08:00
|
|
|
G.api.nvim_exec(c)
|
2023-01-24 22:27:07 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
function G.eval(c)
|
2024-01-16 20:16:19 +08:00
|
|
|
return G.api.nvim_eval(c)
|
2023-01-24 22:27:07 +08:00
|
|
|
end
|
|
|
|
|
2023-10-09 17:01:31 +08:00
|
|
|
function G.au(even, opts)
|
2024-01-16 20:16:19 +08:00
|
|
|
return G.api.nvim_create_autocmd(even, opts)
|
2023-01-28 15:59:16 +08:00
|
|
|
end
|
|
|
|
|
2023-01-28 15:11:37 +08:00
|
|
|
G.g.mapleader = ' '
|
|
|
|
|
2023-01-24 22:27:07 +08:00
|
|
|
return G
|