robin/ivy

my custom neovim config

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

robinlua: refactor init8d3fece

main
1.6 KiB61 linesraw
1vim.on("VimResized", "@ivy.editor.window.autoresize", {
2  desc = "Automatically resize windows when the host window size changes.",
3}, function()
4  vim.cmd([[ wincmd = ]])
5end)
6
7vim.on({ "RecordingEnter", "RecordingLeave" }, "@ivy.editor.macro.print", {
8  desc = "Notify when recording macro",
9}, function(ev)
10  local done = ev.event == "RecordingLeave"
11  local msg = done and "Macro recorded" or "Recording macro..."
12  vim.api.nvim_echo({ { msg, "MsgArea" } }, false, {
13    title = "Macro",
14    kind = "progress",
15    status = done and "success" or "running",
16    source = "ivy",
17  })
18end)
19
20vim.on({ "WinEnter", "TermOpen" }, "@ivy.editor.terminal.startinsert", {
21  pattern = "term://*",
22  desc = "start insert mode in terminal",
23}, function(ev)
24  if
25    vim.api.nvim_get_current_buf() ~= ev.buf
26    or vim.bo[ev.buf].buftype ~= "terminal"
27  then
28    return
29  end
30  vim.cmd("startinsert")
31end)
32
33vim.on("BufWritePre", "@ivy.editor.file.auto_create_parent_path", {
34  desc = "create path to file",
35}, function()
36  local dir = vim.fn.expand("<afile>:p:h")
37  ---@cast dir string
38
39  if dir:find("%l+://") == 1 then
40    return
41  end
42
43  if vim.fn.isdirectory(dir) == 0 then
44    vim.fn.mkdir(dir, "p")
45  end
46end)
47
48vim.on("FileType", "@ivy.editor.ft.help", {
49  pattern = "help",
50  desc = "allow editing local help files",
51}, function(ev)
52  if vim.fs.relpath(vim.fn.getcwd(), vim.fn.bufname(ev.buf)) then
53    vim._with({ buf = ev.buf }, function()
54      vim.bo.buftype = ""
55      vim.bo.readonly = false
56      vim.bo.modifiable = true
57      -- assuming there is only one window with the open buffer
58      vim.wo.conceallevel = 0
59    end)
60  end
61end)