-
-
Notifications
You must be signed in to change notification settings - Fork 240
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(recipes): add auto-session-restore
- Loading branch information
Showing
2 changed files
with
41 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# AstroLSP - Automatically Restore Previous Session | ||
|
||
**Website:** <https://docs.astronvim.com/recipes/sessions/#automatically-restore-previous-session> | ||
|
||
This plugin specification configures AstroLSP to automatically | ||
restore their previous session for a given directory when opening Neovim with no arguments. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
local read_from_stdin = false | ||
return { | ||
{ | ||
"AstroNvim/astrocore", | ||
---@type AstroCoreOpts | ||
opts = { | ||
autocmds = { | ||
-- disable alpha autostart | ||
alpha_autostart = false, | ||
restore_session = { | ||
{ | ||
event = "StdinReadPost", | ||
desc = "Check if we are reading from stdin", | ||
nested = true, | ||
callback = function() | ||
read_from_stdin = true | ||
end, | ||
}, | ||
{ | ||
event = "VimEnter", | ||
desc = "Restore previous directory session if neovim opened with no arguments", | ||
nested = true, -- trigger other autocommands as buffers open | ||
callback = function() | ||
-- Only load the session if nvim was started with no args | ||
if not read_from_stdin and vim.fn.argc(-1) == 0 then | ||
-- try to load a directory session using the current working directory | ||
require("resession").load(vim.fn.getcwd(), { dir = "dirsession", silence_errors = true }) | ||
end | ||
end, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
} |