feat(plugins): add git-branch-aware session handling and disable dashboard startup
This commit is contained in:
1 parent
6244488943
commit
8c010498c7
2 files changed
+29
-48
No files matched your search
@@ -71,9 +71,11 @@ return {
|
|||||||
---@type AstroCoreOpts
|
---@type AstroCoreOpts
|
||||||
opts = {
|
opts = {
|
||||||
sessions = {
|
sessions = {
|
||||||
|
-- cwd autosave is handled by the git_branch_sessions autocmd below so
|
||||||
|
-- the session name carries the worktree/branch, see config.session
|
||||||
autosave = {
|
autosave = {
|
||||||
last = true,
|
last = true,
|
||||||
cwd = true,
|
cwd = false,
|
||||||
},
|
},
|
||||||
ignore = {
|
ignore = {
|
||||||
dirs = {},
|
dirs = {},
|
||||||
@@ -153,18 +155,23 @@ return {
|
|||||||
end,
|
end,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
restore_session = {
|
git_branch_sessions = {
|
||||||
|
{
|
||||||
|
event = "VimLeavePre",
|
||||||
|
desc = "Save the worktree/branch directory session on close",
|
||||||
|
callback = vim.schedule_wrap(function()
|
||||||
|
if require("astrocore.buffer").is_valid_session() then
|
||||||
|
require("config.session").save { notify = false }
|
||||||
|
end
|
||||||
|
end),
|
||||||
|
},
|
||||||
{
|
{
|
||||||
event = "VimEnter",
|
event = "VimEnter",
|
||||||
desc = "Restore previous directory session if neovim opened with no arguments",
|
desc = "Restore worktree/branch session, else open the git files picker",
|
||||||
nested = true, -- trigger other autocommands as buffers open
|
nested = true, -- trigger other autocommands as buffers open
|
||||||
callback = function()
|
callback = function()
|
||||||
if vim.fn.argc(-1) == 0 then
|
-- only when nvim was started without file arguments
|
||||||
require("resession").load(
|
if vim.fn.argc(-1) == 0 then require("config.session").restore() end
|
||||||
vim.fn.getcwd(),
|
|
||||||
{ dir = "dirsession", silence_errors = true }
|
|
||||||
)
|
|
||||||
end
|
|
||||||
end,
|
end,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -208,6 +215,16 @@ return {
|
|||||||
function() require("snacks").picker.git_files { transform = file_filter } end,
|
function() require("snacks").picker.git_files { transform = file_filter } end,
|
||||||
desc = "Find git files",
|
desc = "Find git files",
|
||||||
},
|
},
|
||||||
|
-- AstroNvim's dirsession maps key off the bare cwd; use the
|
||||||
|
-- worktree/branch-aware name instead
|
||||||
|
["<Leader>SS"] = {
|
||||||
|
function() require("config.session").save() end,
|
||||||
|
desc = "Save this dirsession",
|
||||||
|
},
|
||||||
|
["<Leader>S."] = {
|
||||||
|
function() require("config.session").load() end,
|
||||||
|
desc = "Load current dirsession",
|
||||||
|
},
|
||||||
["<leader><leader>"] = {
|
["<leader><leader>"] = {
|
||||||
function() require("snacks").picker.smart() end,
|
function() require("snacks").picker.smart() end,
|
||||||
desc = "Find files",
|
desc = "Find files",
|
||||||
|
|||||||
+3
-39
@@ -53,45 +53,9 @@ return {
|
|||||||
jump = { reuse_win = true },
|
jump = { reuse_win = true },
|
||||||
sources = picker_sources,
|
sources = picker_sources,
|
||||||
},
|
},
|
||||||
dashboard = {
|
-- no dashboard: startup either restores the worktree/branch session or
|
||||||
enabled = true,
|
-- opens the git files picker (see config.session)
|
||||||
preset = {
|
dashboard = { enabled = false },
|
||||||
-- "prdlk.nvim" in ansi_regular block style
|
|
||||||
header = table.concat({
|
|
||||||
"██████ ██████ ██████ ██ ██ ██ ███ ██ ██ ██ ██ ███ ███",
|
|
||||||
"██ ██ ██ ██ ██ ██ ██ ██ ██ ████ ██ ██ ██ ██ ████ ████",
|
|
||||||
"██████ ██████ ██ ██ ██ █████ ██ ██ ██ ██ ██ ██ ██ ████ ██",
|
|
||||||
"██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██",
|
|
||||||
"██ ██ ██ ██████ ███████ ██ ██ ██ ██ ████ ████ ██ ██ ██",
|
|
||||||
}, "\n"),
|
|
||||||
},
|
|
||||||
sections = {
|
|
||||||
{ section = "header" },
|
|
||||||
{ section = "keys", gap = 1, padding = 1 },
|
|
||||||
{
|
|
||||||
icon = " ",
|
|
||||||
desc = "Browse Repo",
|
|
||||||
padding = 1,
|
|
||||||
key = "b",
|
|
||||||
action = function() Snacks.gitbrowse() end,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
icon = " ",
|
|
||||||
desc = "Projects (ghq)",
|
|
||||||
padding = 1,
|
|
||||||
key = "p",
|
|
||||||
action = function()
|
|
||||||
local repos = vim.fn.systemlist "ghq list -p"
|
|
||||||
vim.ui.select(repos, { prompt = "Select repository" }, function(dir)
|
|
||||||
if not dir then return end
|
|
||||||
vim.cmd.cd(dir)
|
|
||||||
Snacks.picker.files()
|
|
||||||
end)
|
|
||||||
end,
|
|
||||||
},
|
|
||||||
{ section = "startup" },
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user