vim.on("VimResized", "@ivy.editor.window.autoresize", { desc = "Automatically resize windows when the host window size changes.", }, function() vim.cmd([[ wincmd = ]]) end) vim.on({ "RecordingEnter", "RecordingLeave" }, "@ivy.editor.macro.print", { desc = "Notify when recording macro", }, function(ev) local done = ev.event == "RecordingLeave" local msg = done and "Macro recorded" or "Recording macro..." vim.api.nvim_echo({ { msg, "MsgArea" } }, false, { title = "Macro", kind = "progress", status = done and "success" or "running", source = "ivy", }) end) vim.on({ "WinEnter", "TermOpen" }, "@ivy.editor.terminal.startinsert", { pattern = "term://*", desc = "start insert mode in terminal", }, function(ev) if vim.api.nvim_get_current_buf() ~= ev.buf or vim.bo[ev.buf].buftype ~= "terminal" then return end vim.cmd("startinsert") end) vim.on("BufWritePre", "@ivy.editor.file.auto_create_parent_path", { desc = "create path to file", }, function() local dir = vim.fn.expand(":p:h") ---@cast dir string if dir:find("%l+://") == 1 then return end if vim.fn.isdirectory(dir) == 0 then vim.fn.mkdir(dir, "p") end end) vim.on("FileType", "@ivy.editor.ft.help", { pattern = "help", desc = "allow editing local help files", }, function(ev) if vim.fs.relpath(vim.fn.getcwd(), vim.fn.bufname(ev.buf)) then vim._with({ buf = ev.buf }, function() vim.bo.buftype = "" vim.bo.readonly = false vim.bo.modifiable = true -- assuming there is only one window with the open buffer vim.wo.conceallevel = 0 end) end end)