nvim/lua/G.lua
2023-10-05 23:21:33 +08:00

74 lines
1.5 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
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 = ' '
local lazypath = G.fn.stdpath("data") .. "/lazy/lazy.nvim"
if not G.loop.fs_stat(lazypath) then
G.fn.system({
"git",
"clone",
"--filter=blob:none",
"http://git.qqnewbie.top/newbieQQ/lazy.nvim.git",
"--branch=stable", -- latest stable release
lazypath,
})
end
G.opt.rtp:prepend(lazypath)
local normalplugs = require('normal.plug')
local vscodeplugs = require('vscode.plug')
local neovimplugs = require('neovim.plug')
if G.g.vscode then
plugs = {vscodeplugs, normalplugs}
else
plugs = {neovimplugs, normalplugs}
end
require("lazy").setup(plugs)
return G