robin/ivy

my custom neovim config

git clone https://git.robinwobin.dev/robin/ivy

robininit: protect use of globals using `provide`082b337

main
1011 B44 linesraw
1-- prelude =====================================================================
2
3local datadir = vim.fn.stdpath("data")
4vim.opt.rtp:prepend({
5  datadir .. "/site/pack/*/start/*",
6  datadir .. "/site/pack/*/start/*/after",
7})
8vim.opt.packpath:prepend({
9  datadir .. "/site",
10})
11
12---@param t table<string,any?>
13_G.provide = function(t)
14  for k, v in pairs(t) do
15    if _G[k] then
16      vim.notify(
17        ("tried to provide global '%s' but a global variable with this name already exists"):format(
18          k
19        ),
20        vim.log.levels.ERROR
21      )
22    else
23      _G[k] = v
24    end
25  end
26end
27
28---@param name string
29---@param clear boolean
30vim.augroup = function(name, clear)
31  ---@diagnostic disable-next-line: return-type-mismatch
32  return setmetatable({
33    groupid = vim.api.nvim_create_augroup(name, { clear = clear }),
34  }, {
35    __call = function(self, event, ...)
36      return vim.on(event, self.groupid, ...)
37    end,
38  })
39end
40
41require("ivy.once")
42vim.once:init()
43
44require("ivy.notifs").init()