1

Update generated nvim config

This commit is contained in:
2024-06-05 22:05:42 +02:00
parent 859ee3a2ba
commit 075fe5f587
1292 changed files with 152601 additions and 0 deletions

View File

@ -0,0 +1,22 @@
local session_dir = vim.loop.cwd() .. "/tests/dummy_data/"
require("persisted").setup({
save_dir = session_dir,
autoload = true,
autosave = true,
allowed_dirs = { vim.loop.cwd() },
})
describe("Autoloading", function()
it("autoloads a file with allowed_dirs config option present", function()
local co = coroutine.running()
vim.defer_fn(function()
coroutine.resume(co)
local content = vim.fn.getline(1, "$")
assert.equals("If you're reading this, I guess auto-loading works", content[1])
end, 1000)
coroutine.yield()
end)
end)

View File

@ -0,0 +1,47 @@
describe("Autoloading", function()
it("autoloads a file", function()
local co = coroutine.running()
vim.defer_fn(function()
coroutine.resume(co)
end, 2000)
local session_dir = vim.fn.getcwd() .. "/tests/dummy_data/"
require("persisted").setup({
save_dir = session_dir,
autoload = true,
autosave = true,
})
coroutine.yield()
local content = vim.fn.getline(1, "$")
assert.equals("If you're reading this, I guess auto-loading works", content[1])
end)
it("autoloads the a child directory of ignored_dirs exact", function()
local co = coroutine.running()
vim.defer_fn(function()
coroutine.resume(co)
end, 2000)
local fp_sep = vim.loop.os_uname().sysname:lower():match("windows") and "\\" or "/" -- \ for windows, mac and linux both use \
local session_dir = vim.fn.getcwd() .. "/test/dummy_data/"
require("persisted").setup({
save_dir = session_dir,
autoload = true,
autosave = true,
ignored_dirs = {
-- Setting the parent of our current to an ignored directory
{
string.format("%s%s..%s", vim.fn.getcwd(), fp_sep, fp_sep),
exact = true,
},
},
})
coroutine.yield()
local content = vim.fn.getline(1, "$")
assert.equals("If you're reading this, I guess auto-loading works", content[1])
end)
end)

View File

@ -0,0 +1,20 @@
local session_dir = vim.fn.getcwd() .. "/tests/dummy_data/"
require("persisted").setup({
save_dir = session_dir,
autoload = true,
ignored_dirs = { vim.fn.getcwd() },
})
describe("Autoloading", function()
it("is stopped if an ignored dir is present", function()
local co = coroutine.running()
vim.defer_fn(function()
coroutine.resume(co)
end, 1000)
coroutine.yield()
local content = vim.fn.getline(1, "$")
assert.equals(content[1], "")
end)
end)

View File

@ -0,0 +1,77 @@
local session_dir = vim.fn.getcwd() .. "/tests/default_data/"
require("persisted").setup({
save_dir = session_dir,
})
describe("With default settings:", function()
after_each(function()
-- vim.fn.system("rm -rf " .. e(session_dir))
end)
it("it saves a session", function()
-- Check no file exists
assert.equals(vim.fn.system("ls tests/default_data | wc -l"):gsub("%s+", ""), "0")
-- Edit a buffer
vim.cmd(":e tests/stubs/test.txt")
vim.cmd(":w")
-- Save the session
require("persisted").save()
-- Check that the session is written to disk
assert.equals(vim.g.persisting, true)
assert.equals("1", vim.fn.system("ls tests/default_data | wc -l"):gsub("%s+", ""))
end)
it("it loads a session", function()
-- Load a session
require("persisted").load()
-- Read the buffers contents
local content = vim.fn.getline(1, "$")
assert.equals("This is a test file", content[1])
assert.equals(vim.g.persisting, true)
end)
it("it stops a session", function()
require("persisted").stop()
assert.equals(vim.g.persisting, false)
end)
it("it starts a session", function()
require("persisted").start()
assert.equals(vim.g.persisting, true)
end)
it("it lists sessions", function()
local sessions = require("persisted").list()
local path = require("plenary.path"):new(sessions[1].file_path)
assert.equals(path:is_path(), true)
end)
end)
local async = require("plenary.async.tests")
local util = require("plenary.async.util")
async.describe("With default settings:", function()
async.it("it deletes a session", function()
require("persisted").delete()
util.scheduler()
assert.equals("0", vim.fn.system("ls tests/default_data | wc -l"):gsub("%s+", ""))
end)
end)
describe("Utilities", function()
it("can make derive the session name", function()
local session = "%home%username%projects%front@@user%fix-analytics-export-null-values.vim"
local data = require("persisted.utils").make_session_data(session)
assert.equals("home/username/projects/front@@user/fix-analytics-export-null-values", data.name)
end)
end)

View File

@ -0,0 +1,61 @@
pcall(vim.fn.system, "rm -rf tests/dummy_data")
local session_dir = vim.fn.getcwd() .. "/tests/dummy_data/"
-- follow_cwd = true
require("persisted").setup({
save_dir = session_dir,
follow_cwd = true,
})
describe("Follow cwd change", function()
it("creates two sessions with change in cwd", function()
vim.cmd(":e tests/stubs/test_autoload.txt")
vim.cmd(":w")
require("persisted").save()
vim.cmd(":cd tests/stubs")
vim.cmd(":w")
require("persisted").save()
vim.cmd(":bdelete")
end)
it("ensures both sessions were created", function()
local pattern = "/"
local name1 = vim.fn.getcwd():gsub(pattern, "%%") .. require("persisted").get_branch() .. ".vim"
vim.cmd(":cd ../..")
local name2 = vim.fn.getcwd():gsub(pattern, "%%") .. require("persisted").get_branch() .. ".vim"
local sessions = vim.fn.readdir(session_dir)
assert.equals(sessions[1], name1)
assert.equals(sessions[2], name2)
end)
end)
-- follow_cwd = false
pcall(vim.fn.system, "rm -rf tests/dummy_data")
require("persisted").setup({
save_dir = session_dir,
follow_cwd = false,
})
describe("Don't follow cwd change", function()
it("creates two sessions with change in cwd", function()
vim.cmd(":e tests/stubs/test_autoload.txt")
vim.cmd(":w")
require("persisted").save()
require("persisted").load()
vim.cmd(":cd tests/stubs")
vim.cmd(":w")
require("persisted").save()
vim.cmd(":bdelete")
end)
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 sessions = vim.fn.readdir(session_dir)
assert.equals(#sessions, 1)
assert.equals(name, sessions[1])
end)
end)

View File

@ -0,0 +1,33 @@
pcall(vim.fn.system, "rm -rf tests/git_branch_data")
local session_dir = vim.fn.getcwd() .. "/tests/git_branch_data/"
require("persisted").setup({
save_dir = session_dir,
use_git_branch = true,
})
describe("Git Branching", function()
it("creates a session", function()
vim.fn.system("mkdir tests/git_branch_data")
vim.fn.system("cd tests/git_branch_data && git init")
assert.equals(vim.fn.system("ls tests/git_branch_data | wc -l"):gsub("%s+", ""), "0")
vim.cmd(":e tests/stubs/test_git_branching.txt")
vim.cmd(":w tests/git_branch_data/test_git_branching.txt")
require("persisted").save()
assert.equals(vim.fn.system("ls tests/git_branch_data | wc -l"):gsub("%s+", ""), "2")
end)
it("ensures the session has the branch name in", function()
-- Workout what the name should be
local pattern = "/"
local name = vim.fn.getcwd():gsub(pattern, "%%") .. require("persisted").get_branch() .. ".vim"
local session = vim.fn.glob(session_dir .. "*.vim", true, true)[1]
session:gsub(session_dir .. "/", "")
assert.equals(session, vim.fn.getcwd() .. "/tests/git_branch_data/" .. name)
-- assert.equals(sessions[1]:gsub(pattern, "%%"), name)
end)
end)

View File

@ -0,0 +1,10 @@
set rtp+=.
set rtp+=./misc/plenary
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 TestDefaults PlenaryBustedFile tests/default_settings_spec.lua
command TearDown PlenaryBustedFile tests/teardown/clean_up_dirs.lua

View File

@ -0,0 +1,17 @@
pcall(vim.fn.system, "rm -rf tests/dummy_data")
local session_dir = vim.fn.getcwd() .. "/tests/dummy_data/"
require("persisted").setup({
save_dir = session_dir,
autoload = true,
autosave = true,
})
describe("As part of the setup", function()
it("creates a session to autoload from", function()
vim.cmd(":e tests/stubs/test_autoload.txt")
vim.cmd(":w")
require("persisted").save()
end)
end)

View File

@ -0,0 +1 @@
This is a test file

View File

@ -0,0 +1 @@
If you're reading this, I guess auto-loading works

View File

@ -0,0 +1 @@
Git branching is awesome

View File

@ -0,0 +1,7 @@
describe("As part of the teardown", function()
it("dummy data is deleted", function()
pcall(vim.fn.system, "rm -rf tests/dummy_data")
pcall(vim.fn.system, "rm -rf tests/git_branch_data")
pcall(vim.fn.system, "rm -rf tests/default_data")
end)
end)