From 3b33a604d82184df14495f96b92ef9102a22a047 Mon Sep 17 00:00:00 2001 From: Squibid Date: Fri, 4 Jul 2025 05:25:06 -0400 Subject: [PATCH] commands get rerun by default now --- doc/dep.txt | 9 ++++++++- lua/dep/lazy/loader/init.lua | 8 ++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/doc/dep.txt b/doc/dep.txt index f8b8024..be5151d 100644 --- a/doc/dep.txt +++ b/doc/dep.txt @@ -217,10 +217,17 @@ is equivalent to the following: load:cmd("Command", { callback = function() load:cleanup() + + if (rerun) then + vim.cmd("Command") + end end }) < -If you wish the second argument may be completely ommitted. +If you wish the second argument may be completely ommitted. Note the inclusion +of a `rerun` field, this is a parameter which may be passed into the options table +to re-run the binding after loading the package. You may choose to disable the +built-in logic by passing false. ------------------------------------------------------------------------------ LOAD:AUTO *dep-lazy-loading-api-auto* diff --git a/lua/dep/lazy/loader/init.lua b/lua/dep/lazy/loader/init.lua index 886204e..c901b0a 100644 --- a/lua/dep/lazy/loader/init.lua +++ b/lua/dep/lazy/loader/init.lua @@ -37,6 +37,9 @@ end function lazy_loader:cmd(name, opts) opts = opts or {} + -- rerun is on by default + opts["rerun"] = opts["rerun"] or true + -- load the plugin on completion if not opts["complete"] then opts["complete"] = function(_, line, _) @@ -52,6 +55,11 @@ function lazy_loader:cmd(name, opts) vim.api.nvim_create_user_command(name, opts['callback'] or function(_) self:cleanup() + + -- attempt to rerun the command + if not opts["rerun"] then + pcall(vim.cmd, name) + end end, opts) table.insert(self.command_ids, name)