🪴 my neovim config:)
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

init: add `vim.on`, `vim.once` and `vim.later`

robin 3f23c9ea 6f0d52cf

+324 -238
+3 -6
config/config/lint.lua
··· 4 4 markdown = { "proselint" }, 5 5 } 6 6 7 - vim.api.nvim_create_autocmd({ "BufWritePost" }, { 8 - group = vim.api.nvim_create_augroup("nvim-lint:try_lint", { clear = true }), 9 - callback = function() 10 - require("lint").try_lint() 11 - end, 12 - }) 7 + vim.augroup("nvim-lint:try_lint", true)("BufWritePost", nil, {}, function() 8 + require("lint").try_lint() 9 + end)
+3 -7
config/config/neo-tree.lua
··· 39 39 local keymaps = require("keymaps").setup() 40 40 keymaps.normal["<space>n"] = { "<cmd>Neotree<cr>", "open tree view" } 41 41 42 - vim.api.nvim_create_autocmd("WinEnter", { 43 - pattern = "neo-tree *", 44 - group = vim.api.nvim_create_augroup("filetype:neo-tree:options", { clear = true }), 45 - callback = function(ev) 46 - vim.api.nvim_set_option_value("sidescrolloff", 0, { win = ev.win }) 47 - end, 48 - }) 42 + -- vim.augroup("filetype:neo-tree:options", true)("WinEnter", "neo-tree *", {}, function() 43 + -- vim.api.nvim_set_option_value("sidescrolloff", 0, { scope = "local" }) 44 + -- end)
+30 -39
config/lua/ivy/config/autocmds.lua
··· 1 - vim.api.nvim_create_autocmd("VimResized", { 2 - group = vim.api.nvim_create_augroup("editor:window:autoresize", { clear = true }), 3 - pattern = "*", 4 - command = [[ wincmd = ]], 1 + vim.augroup("editor:window:autoresize", true)("VimResized", nil, { 5 2 desc = "Automatically resize windows when the host window size changes.", 6 - }) 3 + }, [[ wincmd = ]]) 7 4 8 - vim.api.nvim_create_autocmd({ "RecordingEnter", "RecordingLeave" }, { 9 - group = vim.api.nvim_create_augroup("editor:macro:print", { clear = true }), 10 - callback = function(ev) 11 - local done = ev.event == "RecordingLeave" 12 - local msg = done and "Macro recorded" or "Recording macro..." 13 - vim.api.nvim_echo({ { msg, "MsgArea" } }, false, { 14 - title = "Macro", 15 - kind = "progress", 16 - status = done and "success" or "running", 17 - }) 18 - end, 5 + vim.augroup("editor:macro:print", true)({ "RecordingEnter", "RecordingLeave" }, nil, { 19 6 desc = "Notify when recording macro", 20 - }) 7 + }, function(ev) 8 + local done = ev.event == "RecordingLeave" 9 + local msg = done and "Macro recorded" or "Recording macro..." 10 + vim.api.nvim_echo({ { msg, "MsgArea" } }, false, { 11 + title = "Macro", 12 + kind = "progress", 13 + status = done and "success" or "running", 14 + }) 15 + end) 21 16 22 - vim.api.nvim_create_autocmd("WinEnter", { 23 - group = vim.api.nvim_create_augroup("editor:terminal:startinsert", { clear = true }), 24 - pattern = "term://*", 25 - callback = function(ev) 26 - if vim.bo[ev.buf].buftype ~= "terminal" then 27 - return 28 - end 29 - vim.cmd("startinsert") 30 - end, 31 - }) 17 + vim.augroup("editor:terminal:startinsert", true)("WinEnter", "term://*", { 18 + desc = "start insert mode in terminal", 19 + }, function(ev) 20 + if vim.bo[ev.buf].buftype ~= "terminal" then 21 + return 22 + end 23 + vim.cmd("startinsert") 24 + end) 32 25 33 - vim.api.nvim_create_autocmd("BufWritePre", { 34 - group = vim.api.nvim_create_augroup("editor:file:auto_create_parent_path", { clear = true }), 26 + vim.augroup("editor:file:auto_create_parent_path", true)("BufWritePre", nil, { 35 27 desc = "create path to file", 36 - callback = function() 37 - local dir = vim.fn.expand("<afile>:p:h") 28 + }, function() 29 + local dir = vim.fn.expand("<afile>:p:h") 38 30 39 - if dir:find("%l+://") == 1 then 40 - return 41 - end 31 + if dir:find("%l+://") == 1 then 32 + return 33 + end 42 34 43 - if vim.fn.isdirectory(dir) == 0 then 44 - vim.fn.mkdir(dir, "p") 45 - end 46 - end, 47 - }) 35 + if vim.fn.isdirectory(dir) == 0 then 36 + vim.fn.mkdir(dir, "p") 37 + end 38 + end)
+11 -14
config/lua/ivy/config/ft.lua
··· 22 22 }, 23 23 }) 24 24 25 - vim.api.nvim_create_autocmd("FileType", { 26 - pattern = "*", 27 - callback = function(ev) 28 - if not vim.api.nvim_buf_is_loaded(ev.buf) then 29 - return 30 - end 25 + vim.on("FileType", "*", {}, function(ev) 26 + if not vim.api.nvim_buf_is_loaded(ev.buf) then 27 + return 28 + end 31 29 32 - local ok, _ = pcall(vim.treesitter.start, ev.buf) 33 - if not ok then 34 - return 35 - end 36 - vim.o.foldmethod = "expr" 37 - vim.o.foldexpr = "v:lua.vim.treesitter.foldexpr()" 38 - end, 39 - }) 30 + local ok, _ = pcall(vim.treesitter.start, ev.buf) 31 + if not ok then 32 + return 33 + end 34 + vim.o.foldmethod = "expr" 35 + vim.o.foldexpr = "v:lua.vim.treesitter.foldexpr()" 36 + end)
+12 -15
config/lua/ivy/config/neovide.lua
··· 18 18 vim.g.neovide_normal_opacity = 0.9 19 19 end 20 20 21 - vim.api.nvim_create_autocmd("ColorScheme", { 22 - group = vim.api.nvim_create_augroup("neovide:background", { clear = true }), 23 - callback = function() 24 - local normal = vim.api.nvim_get_hl(0, { name = "Normal" }) or { bg = 0, fg = 0 } 25 - local bg = normal.bg and string.format("%x", normal.bg) 26 - local fg = normal.fg and string.format("%x", normal.fg) 27 - if bg then 28 - vim.g.neovide_background_color = bg .. _G.neovide_alpha() 29 - vim.g.neovide_title_background_color = bg 30 - end 31 - if fg then 32 - vim.g.neovide_title_text_color = fg 33 - end 34 - end, 35 - }) 21 + vim.once.ColorScheme(function() 22 + local normal = vim.api.nvim_get_hl(0, { name = "Normal" }) or { bg = 0, fg = 0 } 23 + local bg = normal.bg and string.format("%x", normal.bg) 24 + local fg = normal.fg and string.format("%x", normal.fg) 25 + if bg then 26 + vim.g.neovide_background_color = bg .. _G.neovide_alpha() 27 + vim.g.neovide_title_background_color = bg 28 + end 29 + if fg then 30 + vim.g.neovide_title_text_color = fg 31 + end 32 + end) 36 33 37 34 -- font & cursor -- 38 35
+8 -14
config/lua/ivy/config/options.lua
··· 53 53 -- folding 54 54 local function setfolds() 55 55 if vim.bo.buftype ~= "" then 56 + vim.o.foldenable = false 56 57 return 57 58 end 58 59 vim.o.foldenable = true ··· 63 64 vim.o.foldmethod = "indent" 64 65 end 65 66 66 - local foldgroup = vim.api.nvim_create_augroup("ivy:folds:init", { clear = true }) 67 - vim.api.nvim_create_autocmd("BufWinEnter", { 68 - group = foldgroup, 69 - callback = function(ev) 70 - vim.api.nvim_buf_call(ev.buf, setfolds) 71 - end, 72 - }) 73 - vim.api.nvim_create_autocmd("OptionSet", { 74 - group = foldgroup, 75 - pattern = "buftype", 76 - callback = function(ev) 77 - vim.api.nvim_buf_call(ev.buf, setfolds) 78 - end, 79 - }) 67 + local foldgroup = vim.augroup("ivy:folds:init", true) 68 + foldgroup("BufWinEnter", nil, {}, function(ev) 69 + vim.api.nvim_buf_call(ev.buf, setfolds) 70 + end) 71 + foldgroup("OptionSet", "buftype", {}, function(ev) 72 + vim.api.nvim_buf_call(ev.buf, setfolds) 73 + end) 80 74 81 75 -- redefine word boundaries - '_' is a word separator, this helps with snake_case 82 76 vim.opt.iskeyword:remove("_")
+8 -8
config/lua/ivy/init.lua
··· 1 + require("ivy.on") 2 + require("ivy.once") 1 3 require("ivy.notifs").init() 2 4 3 5 local config_base = "ivy.config" ··· 14 16 vim 15 17 .iter(ipairs({ 16 18 { "disable" }, 19 + { "options" }, 17 20 { "autocmds", event = "ConfigDone" }, 18 21 { "cmds", event = "VimEnter" }, 19 22 { "ft", event = "ConfigDone" }, 20 23 { "keybinds", event = "UIEnter" }, 21 - { "neovide", event = "UIEnter" }, 22 - { "options" }, 24 + { "neovide" }, 23 25 { "lsp", event = "ConfigDone" }, 24 26 })) 25 27 :each(function(_, opts) ··· 34 36 opts.event = "User" 35 37 pattern = "ConfigDone" 36 38 end 37 - vim.api.nvim_create_autocmd(opts.event, { 39 + vim.on(opts.event, pattern, { 38 40 group = vim.api.nvim_create_augroup("ivy:" .. vim.inspect(opts.event) .. "[" .. name .. "]", { clear = true }), 39 - pattern = pattern, 40 - callback = function(_) 41 - load_cfg(name) 42 - end, 43 41 once = true, 44 - }) 42 + }, function() 43 + load_cfg(name) 44 + end) 45 45 return 46 46 end 47 47 load_cfg(name)
+9 -12
config/lua/ivy/notifs.lua
··· 26 26 notifs.old_echo = vim.api.nvim_echo 27 27 vim.api.nvim_echo = notifs.nvim_echo 28 28 29 - vim.api.nvim_create_autocmd("UIEnter", { 30 - once = true, 31 - callback = function() 32 - notifs.did_ui_enter = true 29 + vim.once.UIEnter(function() 30 + notifs.did_ui_enter = true 33 31 34 - vim.api.nvim_echo = notifs.old_echo 32 + vim.api.nvim_echo = notifs.old_echo 35 33 36 - vim.schedule(function() 37 - for _, args in ipairs(notifs.queue) do 38 - vim.api.nvim_echo(unpack(args)) 39 - end 40 - end) 41 - end, 42 - }) 34 + vim.schedule(function() 35 + for _, args in ipairs(notifs.queue) do 36 + vim.api.nvim_echo(unpack(args)) 37 + end 38 + end) 39 + end) 43 40 44 41 notifs.did_init = true 45 42 end
+25
config/lua/ivy/on.lua
··· 1 + ---@alias vim.on fun(event: vim.api.keyset.events|vim.api.keyset.events[], pattern?: string, opts: table, f: fun(ev: vim.api.keyset.create_autocmd.callback_args)|string): integer 2 + 3 + ---@type vim.on 4 + vim.on = function(event, pattern, opts, f) 5 + return vim.api.nvim_create_autocmd( 6 + event, 7 + vim.tbl_extend("force", { 8 + pattern = pattern, 9 + callback = type(f) == "function" and f or nil, 10 + command = type(f) == "string" and f or nil, 11 + }, opts) 12 + ) 13 + end 14 + 15 + ---@param name string 16 + ---@param clear boolean 17 + ---@return vim.on 18 + vim.augroup = function(name, clear) 19 + local augroup = vim.api.nvim_create_augroup(name, { clear = clear }) 20 + 21 + return function(event, pattern, opts, f) 22 + opts.group = augroup 23 + return vim.on(event, pattern, opts, f) 24 + end 25 + end
+116
config/lua/ivy/once.lua
··· 1 + local laterproto = { 2 + __call = function(self, f) 3 + if not f then 4 + return 5 + end 6 + f = vim.schedule_wrap(f) 7 + 8 + if self.did then 9 + f() 10 + else 11 + table.insert(self, f) 12 + end 13 + end, 14 + __index = { 15 + ---@return Iter 16 + iter = function(self) 17 + return vim 18 + .iter(function() 19 + local next = table.remove(self, 1) 20 + if not next then 21 + return 22 + end 23 + return next 24 + end) 25 + :filter(function(f) 26 + if type(f) ~= "function" then 27 + return false 28 + end 29 + return true 30 + end) 31 + end, 32 + }, 33 + -- ignore override 34 + _set = function() end, 35 + } 36 + 37 + local augroup = vim.augroup("vim.once", true) 38 + 39 + ---@param event string 40 + ---@param props? table 41 + ---@return table 42 + local function makelaterproto(event, props) 43 + return vim.tbl_deep_extend("force", laterproto, { 44 + __index = { 45 + init = function() 46 + augroup(event, nil, { once = true }, function() 47 + vim.once[event].did = true 48 + vim.once[event]:iter():each(function(f) 49 + return f() 50 + end) 51 + end) 52 + end, 53 + }, 54 + }, props or {}) 55 + end 56 + 57 + --- queue function to be executed either after vimenter or immidiately 58 + ---@type fun(f: function) 59 + vim.once = nil 60 + 61 + vim.once = setmetatable({ 62 + VimEnter = setmetatable({ did = false }, makelaterproto("VimEnter")), 63 + UIEnter = setmetatable({ did = false }, makelaterproto("UIEnter")), 64 + ColorScheme = setmetatable( 65 + {}, 66 + makelaterproto("ColorScheme", { 67 + __call = function(self, f) 68 + if not f then 69 + return 70 + end 71 + vim.once.UIEnter(f) 72 + 73 + f = vim.schedule_wrap(f) 74 + 75 + table.insert(self, f) 76 + end, 77 + __index = { 78 + init = function() 79 + augroup("ColorScheme", nil, {}, function() 80 + vim.once.ColorScheme:iter():each(function(f) 81 + return f() 82 + end) 83 + end) 84 + end, 85 + ---@return Iter 86 + iter = function(self) 87 + return vim.iter(ipairs(self)):map(function(_, f) 88 + if type(f) ~= "function" then 89 + return 90 + end 91 + return f 92 + end) 93 + end, 94 + }, 95 + }) 96 + ), 97 + }, { 98 + __call = function(self, ...) 99 + return self.VimEnter(...) 100 + end, 101 + __index = { 102 + ---@return Iter 103 + iter = function(self) 104 + return vim.iter(pairs(self)):map(function(k, v) 105 + if k == "__metatable" then 106 + return 107 + end 108 + return type(v) == "table" and k or nil 109 + end) 110 + end, 111 + }, 112 + }) 113 + 114 + vim.once:iter():each(function(event) 115 + return vim.once[event]:init() 116 + end)
+3 -6
config/lua/ivy/plugins/tree-sitter.lua
··· 17 17 end, 18 18 }) 19 19 20 - vim.api.nvim_create_autocmd("ColorScheme", { 21 - group = vim.api.nvim_create_augroup("treesitter:context:highlight", { clear = true }), 22 - callback = function() 23 - vim.api.nvim_set_hl(0, "TreesitterContext", { link = "Normal" }) 24 - end, 25 - }) 20 + vim.once.ColorScheme(function() 21 + vim.api.nvim_set_hl(0, "TreesitterContext", { link = "Normal" }) 22 + end) 26 23 end, 27 24 }, 28 25
+13 -17
config/plugin/borderless.lua
··· 8 8 io.stdout:write("\027]111\027\\") 9 9 end 10 10 11 - vim.api.nvim_create_autocmd({ "UIEnter", "ColorScheme" }, { 12 - group = vim.api.nvim_create_augroup("ivy:borderless", { clear = true }), 13 - callback = function() 14 - local normal = vim.api.nvim_get_hl(0, { name = "Normal" }) 15 - if not (normal and normal.bg) then 16 - reset() 17 - return 18 - end 11 + local augroup = vim.augroup("ivy:borderless", true) 19 12 20 - io.stdout:write(string.format("\027]11;#%06x\027\\", normal.bg)) 21 - end, 22 - }) 23 - 24 - vim.api.nvim_create_autocmd("UILeave", { 25 - group = vim.api.nvim_create_augroup("ivy:borderless:leave", { clear = true }), 26 - callback = function() 13 + augroup({ "UIEnter", "ColorScheme" }, nil, {}, function() 14 + local normal = vim.api.nvim_get_hl(0, { name = "Normal" }) 15 + if not (normal and normal.bg) then 27 16 reset() 28 - end, 29 - }) 17 + return 18 + end 19 + 20 + io.stdout:write(string.format("\027]11;#%06x\027\\", normal.bg)) 21 + end) 22 + 23 + augroup("UILeave", nil, {}, function() 24 + reset() 25 + end)
-6
config/plugin/colorscheme.lua
··· 1 - vim.api.nvim_create_autocmd("UIEnter", { 2 - group = vim.api.nvim_create_augroup("ivy:colorscheme:event", { clear = true }), 3 - callback = function() 4 - vim.api.nvim_exec_autocmds("ColorScheme", {}) 5 - end, 6 - })
+3 -6
config/plugin/diff.lua
··· 24 24 return 25 25 end 26 26 27 - vim.api.nvim_create_autocmd("VimEnter", { 28 - group = vim.api.nvim_create_augroup("ivy:diff", { clear = true }), 29 - callback = function() 30 - diff() 31 - end, 32 - }) 27 + vim.on("VimEnter", nil, {}, function() 28 + diff() 29 + end)
+40 -38
config/plugin/guicursor.lua
··· 12 12 horizontal = "hor", 13 13 } 14 14 15 - local guicursor = vim.iter(pairs(vim.g.guicursor_config or {})):fold("", function(str, mode, opts) 16 - vim.validate("mode", mode, function(v) 17 - return vim.tbl_contains({ "normal", "insert", "replace", "operator", "showmatch" }, v) 18 - end, "valid mode") 19 - vim.validate("opts", opts, function(v) 20 - vim.validate("type", v.type, function(t) 21 - return vim.tbl_contains({ "block", "vertical", "horizontal" }, t) 22 - end, "valid type") 23 - if v.type ~= "block" then 24 - vim.validate("size", v.size, function(s) 25 - return type(s) == "number" 26 - end, "valid size with type ~= block") 27 - end 15 + vim.once(function() 16 + local guicursor = vim.iter(pairs(vim.g.guicursor_config or {})):fold("", function(str, mode, opts) 17 + vim.validate("mode", mode, function(v) 18 + return vim.tbl_contains({ "normal", "insert", "replace", "operator", "showmatch" }, v) 19 + end, "valid mode") 20 + vim.validate("opts", opts, function(v) 21 + vim.validate("type", v.type, function(t) 22 + return vim.tbl_contains({ "block", "vertical", "horizontal" }, t) 23 + end, "valid type") 24 + if v.type ~= "block" then 25 + vim.validate("size", v.size, function(s) 26 + return type(s) == "number" 27 + end, "valid size with type ~= block") 28 + end 28 29 29 - if v.animate then 30 - vim.validate("animate", v.animate, function(anim) 31 - vim.validate("wait", anim.wait, "number") 32 - vim.validate("on", anim.on, "number") 33 - vim.validate("off", anim.off, "number") 34 - return true 35 - end, "valid animation") 30 + if v.animate then 31 + vim.validate("animate", v.animate, function(anim) 32 + vim.validate("wait", anim.wait, "number") 33 + vim.validate("on", anim.on, "number") 34 + vim.validate("off", anim.off, "number") 35 + return true 36 + end, "valid animation") 37 + end 38 + 39 + return true 40 + end, "valid opts") 41 + if #str > 0 then 42 + str = str .. "," 36 43 end 44 + local s = string.format( 45 + "%s:%s", 46 + mode_lookup[mode], 47 + opts.type ~= "block" and string.format("%s%d", type_lookup[opts.type], opts.size) or type_lookup[opts.type] 48 + ) 37 49 38 - return true 39 - end, "valid opts") 40 - if #str > 0 then 41 - str = str .. "," 42 - end 43 - local s = string.format( 44 - "%s:%s", 45 - mode_lookup[mode], 46 - opts.type ~= "block" and string.format("%s%d", type_lookup[opts.type], opts.size) or type_lookup[opts.type] 47 - ) 50 + if opts.animate then 51 + local anim = opts.animate 52 + local anim_str = string.format("blinkwait%d-blinkon%d-blinkoff%d", anim.wait, anim.on, anim.off) 53 + s = s .. "-" .. anim_str 54 + end 48 55 49 - if opts.animate then 50 - local anim = opts.animate 51 - local anim_str = string.format("blinkwait%d-blinkon%d-blinkoff%d", anim.wait, anim.on, anim.off) 52 - s = s .. "-" .. anim_str 53 - end 56 + return str .. s 57 + end) 54 58 55 - return str .. s 59 + vim.opt.guicursor = guicursor 56 60 end) 57 - 58 - vim.opt.guicursor = guicursor
+28 -34
config/plugin/lsp.lua
··· 17 17 name = "document_highlight", 18 18 callback = function(client, buf) 19 19 if client.server_capabilities.documentHighlightProvider then 20 - local group = vim.api.nvim_create_augroup(string.format("lsp:document_highlight:%d", buf), { clear = true }) 21 - vim.api.nvim_create_autocmd({ "CursorHold", "CursorHoldI" }, { 22 - group = group, 20 + local augroup = vim.augroup(string.format("lsp:document_highlight:%d", buf), true) 21 + augroup({ "CursorHold", "CursorHoldI" }, nil, { 23 22 buffer = buf, 24 - callback = function() 25 - vim.lsp.buf.clear_references() 26 - vim.lsp.buf.document_highlight() 27 - end, 28 23 desc = "highlight lsp reference", 29 - }) 30 - vim.api.nvim_create_autocmd("CursorMoved", { 31 - group = group, 24 + }, function() 25 + vim.lsp.buf.clear_references() 26 + vim.lsp.buf.document_highlight() 27 + end) 28 + augroup("CursorMoved", nil, { 32 29 buffer = buf, 33 - callback = function() 34 - vim.lsp.buf.clear_references() 35 - end, 36 30 desc = "clear lsp references", 37 - }) 31 + }, function() 32 + vim.lsp.buf.clear_references() 33 + end) 38 34 end 39 35 end, 40 36 }, ··· 58 54 } 59 55 60 56 vim.iter(ipairs(components)):each(function(_, fn) 61 - vim.api.nvim_create_autocmd("LspAttach", { 62 - group = vim.api.nvim_create_augroup("lsp:" .. fn.name, { clear = true }), 63 - callback = function(ev) 64 - local client = vim.lsp.get_client_by_id(ev.data.client_id) 65 - if client == nil then 66 - return 67 - end 68 - local ok, result = pcall(fn.callback, client, ev.buf) 69 - if not ok then 70 - vim.api.nvim_echo( 71 - { { "unable to run on attach events for lsp server " }, { client.name }, { ":\n\t" }, { result } }, 72 - true, 73 - { err = true } 74 - ) 75 - return 76 - end 77 - end, 78 - }) 57 + vim.augroup("lsp:" .. fn.name, true)("LspAttach", nil, {}, function(ev) 58 + local client = vim.lsp.get_client_by_id(ev.data.client_id) 59 + if client == nil then 60 + return 61 + end 62 + local ok, result = pcall(fn.callback, client, ev.buf) 63 + if not ok then 64 + vim.notify( 65 + ("unable to run attach events for lsp server '%s':\n\t%s"):format(client.name, vim.inspect(result)), 66 + vim.log.levels.ERROR 67 + ) 68 + return 69 + end 70 + end) 79 71 end) 80 72 81 73 local common = props.common ··· 101 93 servers = servers() 102 94 end 103 95 104 - ---@diagnostic disable-next-line: param-type-mismatch 105 - vim.iter(pairs(servers)):each(setup_ls) 96 + vim.once(function() 97 + ---@diagnostic disable-next-line: param-type-mismatch 98 + vim.iter(pairs(servers)):each(setup_ls) 99 + end)
+12 -16
config/plugin/yankhl.lua
··· 1 - vim.api.nvim_create_autocmd("TextYankPost", { 2 - group = vim.api.nvim_create_augroup("editor:yank:highlight", { clear = true }), 3 - pattern = "*", 4 - callback = function() 5 - vim.highlight.on_yank({ higroup = "CurSearch", timeout = 200 }) 6 - end, 1 + vim.augroup("editor:yank:highlight", true)("TextYankPost", "*", { 7 2 desc = "highlight yanked text", 8 - }) 3 + }, function() 4 + vim.highlight.on_yank({ higroup = "CurSearch", timeout = 200 }) 5 + end) 9 6 10 - vim.api.nvim_create_autocmd("TextYankPost", { 11 - group = vim.api.nvim_create_augroup("editor:yank:buf", { clear = true }), 12 - callback = function() 13 - if vim.v.event.operator == "y" then 14 - for i = 9, 1, -1 do 15 - vim.fn.setreg(tostring(i), vim.fn.getreg(tostring(i - 1))) 16 - end 7 + vim.augroup("editor:yank:buf", true)("TextYankPost", nil, { 8 + desc = "rotate yank ringbuf", 9 + }, function() 10 + if vim.v.event.operator == "y" then 11 + for i = 9, 1, -1 do 12 + vim.fn.setreg(tostring(i), vim.fn.getreg(tostring(i - 1))) 17 13 end 18 - end, 19 - }) 14 + end 15 + end)