local root = "/tmp/persisted"
-- Set stdpaths to use root dir
for _, name in ipairs({ "config", "data", "state", "cache" }) do
vim.env[("XDG_%s_HOME"):format(name:upper())] = root .. "/" .. name
end
-- Bootstrap lazy
local lazypath = root .. "/plugins/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
vim.fn.system({
"git",
"clone",
"--filter=blob:none",
"--single-branch",
"https://github.com/folke/lazy.nvim.git",
lazypath,
})
end
vim.opt.runtimepath:prepend(lazypath)
vim.opt.sessionoptions = "buffers,curdir,folds,globals,tabpages,winpos,winsize" -- Session options to store in the session
-- Install plugins
local plugins = {
{
"olimorris/persisted.nvim",
opts = {
-- Your custom config here
}
},
-- Put any other plugins here
}
require("lazy").setup(plugins, {
root = root .. "/plugins",
})
Error messages
No response
Describe the bug
I found that when autoload=true, neovim's startup time becomes significantly longer.
After troubleshooting, I found that this was because of the git command
As for why the startup time increased so much, it's because I'm using pwsh as the shell:
vim.opt.shell = "pwsh -NoLogo"
If comment out the above, that is, use the windows default shell:
Then I checked the autoload function and found that if the get_branch function was changed from:
function M.get_branch()
vim.fn.system([[git rev-parse 2> /dev/null]])
local git_enabled = (vim.v.shell_error == 0)
if config.options.use_git_branch and git_enabled then
local branch = vim.fn.systemlist([[git rev-parse --abbrev-ref HEAD 2>/dev/null]])
...
to
function M.get_branch()
if config.options.use_git_branch then
vim.fn.system([[git rev-parse 2> /dev/null]])
local git_enabled = (vim.v.shell_error == 0)
if git_enabled then
local branch = vim.fn.systemlist([[git rev-parse --abbrev-ref HEAD 2>/dev/null]])
...
Then the startup time is normal:
Therefore, I think this code should be changed.
Reproduce the bug
No response
Final checks
[X] I have made sure this issue exists in the latest version of the plugin
[X] I have tested with the minimal.lua config file above and still get the issue
[X] I have used SessionSave to save the session before restarting Neovim and using SessionLoad
[X] I have made sure this is not a duplicate issue
Your
minimal.lua
configError messages
No response
Describe the bug
I found that when
After troubleshooting, I found that this was because of the git command
autoload=true
, neovim's startup time becomes significantly longer.As for why the startup time increased so much, it's because I'm using
pwsh
as the shell:If comment out the above, that is, use the windows default shell:![image](https://github.com/olimorris/persisted.nvim/assets/44764707/58d8b49a-feab-48ee-b5cc-9a86c1600101)
Then I checked the
autoload
function and found that if theget_branch
function was changed from:to
Then the startup time is normal:![image](https://github.com/olimorris/persisted.nvim/assets/44764707/ae6a7e24-e5ac-49c3-a51b-97cb144c5c65)
Therefore, I think this code should be changed.
Reproduce the bug
No response
Final checks
minimal.lua
config file above and still get the issueSessionSave
to save the session before restarting Neovim and usingSessionLoad