···11-vim.api.nvim_create_autocmd("VimResized", {
22- group = vim.api.nvim_create_augroup("editor:window:autoresize", { clear = true }),
33- pattern = "*",
44- command = [[ wincmd = ]],
11+vim.augroup("editor:window:autoresize", true)("VimResized", nil, {
52 desc = "Automatically resize windows when the host window size changes.",
66-})
33+}, [[ wincmd = ]])
7488-vim.api.nvim_create_autocmd({ "RecordingEnter", "RecordingLeave" }, {
99- group = vim.api.nvim_create_augroup("editor:macro:print", { clear = true }),
1010- callback = function(ev)
1111- local done = ev.event == "RecordingLeave"
1212- local msg = done and "Macro recorded" or "Recording macro..."
1313- vim.api.nvim_echo({ { msg, "MsgArea" } }, false, {
1414- title = "Macro",
1515- kind = "progress",
1616- status = done and "success" or "running",
1717- })
1818- end,
55+vim.augroup("editor:macro:print", true)({ "RecordingEnter", "RecordingLeave" }, nil, {
196 desc = "Notify when recording macro",
2020-})
77+}, function(ev)
88+ local done = ev.event == "RecordingLeave"
99+ local msg = done and "Macro recorded" or "Recording macro..."
1010+ vim.api.nvim_echo({ { msg, "MsgArea" } }, false, {
1111+ title = "Macro",
1212+ kind = "progress",
1313+ status = done and "success" or "running",
1414+ })
1515+end)
21162222-vim.api.nvim_create_autocmd("WinEnter", {
2323- group = vim.api.nvim_create_augroup("editor:terminal:startinsert", { clear = true }),
2424- pattern = "term://*",
2525- callback = function(ev)
2626- if vim.bo[ev.buf].buftype ~= "terminal" then
2727- return
2828- end
2929- vim.cmd("startinsert")
3030- end,
3131-})
1717+vim.augroup("editor:terminal:startinsert", true)("WinEnter", "term://*", {
1818+ desc = "start insert mode in terminal",
1919+}, function(ev)
2020+ if vim.bo[ev.buf].buftype ~= "terminal" then
2121+ return
2222+ end
2323+ vim.cmd("startinsert")
2424+end)
32253333-vim.api.nvim_create_autocmd("BufWritePre", {
3434- group = vim.api.nvim_create_augroup("editor:file:auto_create_parent_path", { clear = true }),
2626+vim.augroup("editor:file:auto_create_parent_path", true)("BufWritePre", nil, {
3527 desc = "create path to file",
3636- callback = function()
3737- local dir = vim.fn.expand("<afile>:p:h")
2828+}, function()
2929+ local dir = vim.fn.expand("<afile>:p:h")
38303939- if dir:find("%l+://") == 1 then
4040- return
4141- end
3131+ if dir:find("%l+://") == 1 then
3232+ return
3333+ end
42344343- if vim.fn.isdirectory(dir) == 0 then
4444- vim.fn.mkdir(dir, "p")
4545- end
4646- end,
4747-})
3535+ if vim.fn.isdirectory(dir) == 0 then
3636+ vim.fn.mkdir(dir, "p")
3737+ end
3838+end)
+11-14
config/lua/ivy/config/ft.lua
···2222 },
2323})
24242525-vim.api.nvim_create_autocmd("FileType", {
2626- pattern = "*",
2727- callback = function(ev)
2828- if not vim.api.nvim_buf_is_loaded(ev.buf) then
2929- return
3030- end
2525+vim.on("FileType", "*", {}, function(ev)
2626+ if not vim.api.nvim_buf_is_loaded(ev.buf) then
2727+ return
2828+ end
31293232- local ok, _ = pcall(vim.treesitter.start, ev.buf)
3333- if not ok then
3434- return
3535- end
3636- vim.o.foldmethod = "expr"
3737- vim.o.foldexpr = "v:lua.vim.treesitter.foldexpr()"
3838- end,
3939-})
3030+ local ok, _ = pcall(vim.treesitter.start, ev.buf)
3131+ if not ok then
3232+ return
3333+ end
3434+ vim.o.foldmethod = "expr"
3535+ vim.o.foldexpr = "v:lua.vim.treesitter.foldexpr()"
3636+end)
+12-15
config/lua/ivy/config/neovide.lua
···1818 vim.g.neovide_normal_opacity = 0.9
1919end
20202121-vim.api.nvim_create_autocmd("ColorScheme", {
2222- group = vim.api.nvim_create_augroup("neovide:background", { clear = true }),
2323- callback = function()
2424- local normal = vim.api.nvim_get_hl(0, { name = "Normal" }) or { bg = 0, fg = 0 }
2525- local bg = normal.bg and string.format("%x", normal.bg)
2626- local fg = normal.fg and string.format("%x", normal.fg)
2727- if bg then
2828- vim.g.neovide_background_color = bg .. _G.neovide_alpha()
2929- vim.g.neovide_title_background_color = bg
3030- end
3131- if fg then
3232- vim.g.neovide_title_text_color = fg
3333- end
3434- end,
3535-})
2121+vim.once.ColorScheme(function()
2222+ local normal = vim.api.nvim_get_hl(0, { name = "Normal" }) or { bg = 0, fg = 0 }
2323+ local bg = normal.bg and string.format("%x", normal.bg)
2424+ local fg = normal.fg and string.format("%x", normal.fg)
2525+ if bg then
2626+ vim.g.neovide_background_color = bg .. _G.neovide_alpha()
2727+ vim.g.neovide_title_background_color = bg
2828+ end
2929+ if fg then
3030+ vim.g.neovide_title_text_color = fg
3131+ end
3232+end)
36333734-- font & cursor --
3835
+8-14
config/lua/ivy/config/options.lua
···5353-- folding
5454local function setfolds()
5555 if vim.bo.buftype ~= "" then
5656+ vim.o.foldenable = false
5657 return
5758 end
5859 vim.o.foldenable = true
···6364 vim.o.foldmethod = "indent"
6465end
65666666-local foldgroup = vim.api.nvim_create_augroup("ivy:folds:init", { clear = true })
6767-vim.api.nvim_create_autocmd("BufWinEnter", {
6868- group = foldgroup,
6969- callback = function(ev)
7070- vim.api.nvim_buf_call(ev.buf, setfolds)
7171- end,
7272-})
7373-vim.api.nvim_create_autocmd("OptionSet", {
7474- group = foldgroup,
7575- pattern = "buftype",
7676- callback = function(ev)
7777- vim.api.nvim_buf_call(ev.buf, setfolds)
7878- end,
7979-})
6767+local foldgroup = vim.augroup("ivy:folds:init", true)
6868+foldgroup("BufWinEnter", nil, {}, function(ev)
6969+ vim.api.nvim_buf_call(ev.buf, setfolds)
7070+end)
7171+foldgroup("OptionSet", "buftype", {}, function(ev)
7272+ vim.api.nvim_buf_call(ev.buf, setfolds)
7373+end)
80748175-- redefine word boundaries - '_' is a word separator, this helps with snake_case
8276vim.opt.iskeyword:remove("_")