1

Refresh generated neovim config

This commit is contained in:
2024-07-14 21:12:36 +02:00
parent f215ce2ab5
commit 00464e0e65
731 changed files with 6780 additions and 31110 deletions

View File

@ -34,6 +34,7 @@ test: $(PLENARY_DIR)
nvim --headless --noplugin -u tests/minimal.vim +Setup
# nvim --headless --noplugin -u tests/minimal.vim +TestAutoloading
nvim --headless --noplugin -u tests/minimal.vim +TestGitBranching
nvim --headless --noplugin -u tests/minimal.vim +TestFollowCwd
nvim --headless --noplugin -u tests/minimal.vim +TestDefaults
nvim --headless --noplugin -u tests/minimal.vim +TearDown

View File

@ -203,21 +203,31 @@ end
function M.load(opt, dir)
opt = opt or {}
dir = dir or session_dir()
local branch = get_branchname()
local session = opt.session or (opt.last and get_last() or get_current(dir))
local session_exists = vim.fn.filereadable(session) ~= 0
local branch
local session
if opt.session then
session = opt.session
local session_data = utils.make_session_data(session)
branch = session_data and session_data.branch or ""
if not branch then
vim.notify(string.format("[Persisted.nvim]: Invalid session file %s", session), vim.log.levels.WARN)
end
else
branch = get_branchname()
session = opt.last and get_last() or get_current(dir)
end
if session then
if session_exists then
vim.g.persisting_session = config.options.follow_cwd and nil or session
if vim.fn.filereadable(session) ~= 0 then
vim.g.persisting_session = not config.options.follow_cwd and session or nil
utils.load_session(session, config.options.silent)
elseif type(config.options.on_autoload_no_session) == "function" then
config.options.on_autoload_no_session()
end
end
dir = session_dir()
if config.options.autosave and (allow_dir(dir) and not ignore_dir(dir)) and not ignore_branch(branch) then
M.start()
end

View File

@ -37,12 +37,11 @@ function M.make_session_data(session)
-- Split the session string into path and branch parts
local separator_index = session:find(config.branch_separator)
if not separator_index then
return nil
local branch = ""
if separator_index then
branch = session:sub(separator_index + 2):gsub("%.vim$", ""):gsub("%%", "/")
end
local branch = session:sub(separator_index + 2):gsub("%.vim$", ""):gsub("%%", "/")
-- Removing the home directory from the path and cleaning leading `/`
local name = session:gsub(config.save_dir, ""):gsub("%%", "/"):gsub(home, "")
-- Remove the .vim extension

View File

@ -1,7 +1,7 @@
local actions_state = require("telescope.actions.state")
local transform_mod = require("telescope.actions.mt").transform_mod
local utils = require("persisted.utils")
local persisted = require("persisted")
local M = {}
---Get the selected session from Telescope
@ -18,7 +18,7 @@ M.load_session = function(session, config)
vim.api.nvim_exec_autocmds("User", { pattern = "PersistedTelescopeLoadPre", data = session })
vim.schedule(function()
utils.load_session(session.file_path, config.silent)
persisted.load({ session = session.file_path })
end)
vim.api.nvim_exec_autocmds("User", { pattern = "PersistedTelescopeLoadPost", data = session })

View File

@ -20,10 +20,14 @@ describe("Follow cwd change", function()
vim.cmd(":bdelete")
end)
it("ensures both sessions were created", function()
require("persisted").load()
local pattern = "/"
local name1 = vim.fn.getcwd():gsub(pattern, "%%") .. require("persisted").get_branch() .. ".vim"
local branch1 = require("persisted").get_branch()
local name1 = vim.fn.getcwd():gsub(pattern, "%%") .. (branch1 or "") .. ".vim"
vim.cmd(":cd ../..")
local name2 = vim.fn.getcwd():gsub(pattern, "%%") .. require("persisted").get_branch() .. ".vim"
local branch2 = require("persisted").get_branch()
local name2 = vim.fn.getcwd():gsub(pattern, "%%") .. (branch2 or "") .. ".vim"
local sessions = vim.fn.readdir(session_dir)
assert.equals(sessions[1], name1)
@ -52,7 +56,8 @@ describe("Don't follow cwd change", function()
it("ensures only one session was created", function()
local pattern = "/"
vim.cmd(":cd ../..")
local name = vim.fn.getcwd():gsub(pattern, "%%") .. require("persisted").get_branch() .. ".vim"
local branch = require("persisted").get_branch()
local name = vim.fn.getcwd():gsub(pattern, "%%") .. (branch or "") .. ".vim"
local sessions = vim.fn.readdir(session_dir)
assert.equals(#sessions, 1)

View File

@ -5,6 +5,6 @@ runtime! plugin/plenary.vim
command Setup PlenaryBustedDirectory tests/setup {minimal_init = 'tests/minimal.vim'}
command TestAutoloading PlenaryBustedDirectory tests/autoload {minimal_init = 'tests/minimal.vim'}
command TestGitBranching PlenaryBustedDirectory tests/git_branching {minimal_init = 'tests/minimal.vim'}
command TestFollowCwd PlenaryBustedDirectory tests/follow_cwd/follow_cwd.lua {minimal_init = 'tests/minimal.vim'}
command TestFollowCwd PlenaryBustedDirectory tests/follow_cwd {minimal_init = 'tests/minimal.vim'}
command TestDefaults PlenaryBustedFile tests/default_settings_spec.lua
command TearDown PlenaryBustedFile tests/teardown/clean_up_dirs.lua