local G = {} G.use_ssh = false 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 -- 批量设置键映射,3 元素自动加 { noremap = true },4 元素用传入的 opts function G.map(maps) for _, map in pairs(maps) do vim.keymap.set(map[1], map[2], map[3], map[4] or { noremap = true }) end end function G.delmap(maps) for _, map in pairs(maps) do vim.keymap.del(map[1], map[2], map[3] or {}) 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 -- :R 命令工厂:在下方分屏开终端运行指定命令,省去 5 个 LSP 文件的重复代码 function G.run_cmd(cmd) return function() G.cmd [[set splitbelow | sp]] G.cmd("term " .. cmd) G.cmd [[resize 10 | startinsert]] end end G.g.mapleader = ' ' return G