1
0

Compare commits

...

2 Commits

Author SHA1 Message Date
0578a3dede Update session save and restore behavior 2023-05-27 13:44:59 +02:00
19c453974f Add keymaps for neogit 2023-05-27 13:33:23 +02:00
3 changed files with 27 additions and 5 deletions

View File

@ -191,7 +191,10 @@ local function spec(use)
"TimUntersberger/neogit", "TimUntersberger/neogit",
requires = { requires = {
{ "nvim-lua/plenary.nvim" }, { "nvim-lua/plenary.nvim" },
} },
config = function ()
require("valeth.packer.neogit")
end
} }

View File

@ -0,0 +1,14 @@
local neogit = require("neogit")
local function git_status()
neogit.open()
end
local function git_commit()
neogit.open({ "commit" })
end
vim.keymap.set("n", "<Leader>vs", git_status)
vim.keymap.set("n", "<Leader>vc", git_commit)
neogit.setup()

View File

@ -10,11 +10,14 @@ local function session_name()
end end
end end
local function started_without_args()
return vim.fn.argc(-1) == 0
end
-- Only restore and save session if NeoVim was started without any arguments
vim.api.nvim_create_autocmd("VimEnter", { vim.api.nvim_create_autocmd("VimEnter", {
callback = function() callback = function()
local started_without_args = vim.fn.argc(-1) == 0 if started_without_args() then
if started_without_args then
resession.load(session_name(), { dir = "dirsession", silence_errors = true }) resession.load(session_name(), { dir = "dirsession", silence_errors = true })
end end
end end
@ -22,7 +25,9 @@ vim.api.nvim_create_autocmd("VimEnter", {
vim.api.nvim_create_autocmd("VimLeavePre", { vim.api.nvim_create_autocmd("VimLeavePre", {
callback = function() callback = function()
resession.save(session_name(), { dir = "dirsession", notify = false }) if started_without_args() then
resession.save(session_name(), { dir = "dirsession", notify = false })
end
end end
}) })