Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ Persistence comes with the following defaults:
-- Set to 0 to always save
need = 1,
branch = true, -- use git branch to save session
save_when = function() return true end, -- only save session if user defined function returns true
}
```

Expand Down
1 change: 1 addition & 0 deletions doc/persistence.nvim.txt
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ Persistence comes with the following defaults:
-- Set to 0 to always save
need = 1,
branch = true, -- use git branch to save session
save_when = function() return true end, -- only save session if user defined function returns true
}
<

Expand Down
1 change: 1 addition & 0 deletions lua/persistence/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ local defaults = {
-- Set to 0 to always save
need = 1,
branch = true, -- use git branch to save session
save_when = function() return true end, -- only save session if user defined function returns true
}

---@type Persistence.Config
Expand Down
4 changes: 4 additions & 0 deletions lua/persistence/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ function M.start()
end
end

if not Config.options.save_when() then
return
end

M.save()
M.fire("SavePost")
end,
Expand Down