nvim/lua/G.lua

58 lines
1.1 KiB
Lua
Raw Normal View History

2023-01-24 22:27:07 +08:00
local G = {}
2023-10-02 22:05:38 +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
2023-03-19 00:22:18 +08:00
G.loop = vim.loop
2023-10-02 22:05:38 +08:00
G.lb = vim.lsp.buf
2023-10-04 17:04:01 +08:00
G.dic = vim.diagnostic
G.cgp = vim.nvim_create_augroup
2023-01-24 22:27:07 +08:00
function G.map(maps)
for _,map in pairs(maps) do
2023-11-22 23:19:24 +08:00
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
2023-10-09 16:48:02 +08:00
--G.api.nvim_set_keymap(map[1], map[2], map[3], map[4])
2023-01-24 22:27:07 +08:00
end
end
2023-11-22 23:19:24 +08:00
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
2023-01-24 22:27:07 +08:00
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
2023-10-09 17:01:31 +08:00
function G.au(even, opts)
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