nvim/lua/G.lua
2023-10-04 17:04:01 +08:00

48 lines
927 B
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
G.api.nvim_set_keymap(map[1], map[2], map[3], map[4])
end
end
function G.hi(hls)
for group,color in pairs(hls) do
local fg = color.fg and ' ctermfg=' .. color.fg or ' ctermfg=NONE'
local bg = color.bg and ' ctermbg=' .. color.bg or ' ctermbg=NONE'
local sp = color.sp and ' cterm=' .. color.sp or ''
G.api.nvim_command('highlight ' .. group .. fg .. bg .. sp)
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(c)
return G.api.nvim_create_autocmd(c)
end
G.g.mapleader = ' '
return G