fix: #4 use vim.o.sessionoptions
parent
38cf66b8f8
commit
6cefecd2bb
|
|
@ -6,7 +6,6 @@ local defaults = {
|
|||
use_git_branch = false, -- create session files based on the branch of the git enabled repository
|
||||
autosave = true, -- automatically save session files when exiting Neovim
|
||||
autoload = false, -- automatically load the session for the cwd on Neovim startup
|
||||
options = { "buffers", "curdir", "tabpages", "winsize" }, -- session options used for saving
|
||||
allowed_dirs = nil, -- table of dirs that the plugin will auto-save and auto-load from
|
||||
ignored_dirs = nil, -- table of dirs that are ignored for auto-saving and auto-loading
|
||||
before_save = function() end, -- function to run before the session is saved to disk
|
||||
|
|
@ -18,6 +17,10 @@ M.options = {}
|
|||
|
||||
function M.setup(opts)
|
||||
M.options = vim.tbl_deep_extend("force", {}, defaults, opts or {})
|
||||
if M.options.options then
|
||||
vim.cmd('echohl WarningMsg | echom "Persisted.nvim: The `option` config variable has now been replaced by vim.o.sessionoptions" | echohl NONE')
|
||||
vim.cmd('echohl WarningMsg | echom "Persisted.nvim: Please set vim.o.sessionoptions accordingly" | echohl NONE')
|
||||
end
|
||||
vim.fn.mkdir(M.options.dir, "p")
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -86,6 +86,7 @@ local function get_branch()
|
|||
for s in branch:gmatch("[^\r\n]+") do
|
||||
table.insert(lines, "_" .. s)
|
||||
end
|
||||
|
||||
return lines[2]:gsub("/", "%%")
|
||||
end
|
||||
|
||||
|
|
@ -163,10 +164,7 @@ end
|
|||
function M.save()
|
||||
config.options.before_save()
|
||||
|
||||
local tmp = vim.o.sessionoptions
|
||||
vim.o.sessionoptions = table.concat(config.options.options, ",")
|
||||
vim.cmd("mks! " .. e(get_current()))
|
||||
vim.o.sessionoptions = tmp
|
||||
vim.g.persisting = true
|
||||
|
||||
config.options.after_save()
|
||||
|
|
|
|||
Loading…
Reference in New Issue