[Feature]: Autosave only when the session file of current working directory exists #95
Closed
MasouShizuka
started this conversation in
Ideas
Replies: 1 comment 1 reply
-
Currently, if I want to implement this feature, I must write in config: local persisted = require("persisted")
local save_dir = vim.fn.expand(variables.data_path .. "/lazy/persisted.nvim/sessions/")
opts["save_dir"] = save_dir
opts["should_autosave"] = function()
local name = vim.fn.getcwd():gsub(require("persisted.utils").get_dir_pattern(), "%%")
local session = save_dir .. name .. persisted.get_branch() .. ".vim"
return vim.fn.filereadable(session) ~= 0
end
persisted.setup(opts) In order for this to work, it must be consistent with the repository's code. EDIT: Oh, I found that |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
This feature is similar to
autosave_only_in_session
of the pluginneovim-session-manager
.With this feature, I can autoread the session of only my manually saved working directory.
Although there is currently a setting of
should_autosave
, I cannot determine through the API whether there is a session of the current working directory in the session directory.At present, it seems that can only compare each
file_path
with the current working path throughlist()
However, the naming of the session file may change with plug-in updates.
Therefore, perhaps an API should be provided to determine whether the session file of the current directory exists?
Beta Was this translation helpful? Give feedback.
All reactions