diff --git a/lua/config/session.lua b/lua/config/session.lua index 0358a84..9db2dd0 100644 --- a/lua/config/session.lua +++ b/lua/config/session.lua @@ -75,9 +75,13 @@ end --- VimEnter entry point: restore this worktree/branch session, or fall back to --- the file picker when none has been saved yet. +--- +--- Exception: when nvim was started with file arguments (`nvim foo.lua`, a +--- directory, or `-`) the requested buffer is what the user asked for, so +--- neither the session nor the picker may take the screen. function M.restore() - local name = M.name() - if M.exists(name) then + if vim.fn.argc(-1) > 0 then return end + if M.exists(M.name()) then M.load { silence_errors = true } else -- defer so the picker opens after startup finished drawing the UI diff --git a/lua/plugins/astrocore.lua b/lua/plugins/astrocore.lua index 7f4b4c8..9580009 100644 --- a/lua/plugins/astrocore.lua +++ b/lua/plugins/astrocore.lua @@ -169,10 +169,8 @@ return { event = "VimEnter", desc = "Restore worktree/branch session, else open the git files picker", nested = true, -- trigger other autocommands as buffers open - callback = function() - -- only when nvim was started without file arguments - if vim.fn.argc(-1) == 0 then require("config.session").restore() end - end, + -- no-op when nvim was started with file arguments, see config.session + callback = function() require("config.session").restore() end, }, }, },