diff --git a/.gitignore b/.gitignore index fbb8fee..1780178 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,4 @@ -plenary.nvim/ +misc/ !tests/**/* .luarc.json todo.md diff --git a/Makefile b/Makefile index d1b9c15..73aa951 100644 --- a/Makefile +++ b/Makefile @@ -1,11 +1,42 @@ -all: test +PANVIMDOC_DIR = misc/panvimdoc +PANVIMDOC_URL = https://github.com/kdheepak/panvimdoc +PLENARY_DIR = misc/plenary +PLENARY_URL = https://github.com/nvim-lua/plenary.nvim -test: +all: format test docs + +docs: $(PANVIMDOC_DIR) + @cd $(PANVIMDOC_DIR) && \ + pandoc \ + --metadata="project:persisted.nvim" \ + --metadata="description:Simple session management for Neovim" \ + --metadata="toc:true" \ + --metadata="incrementheadinglevelby:0" \ + --metadata="treesitter:true" \ + --lua-filter scripts/skip-blocks.lua \ + --lua-filter scripts/include-files.lua \ + --lua-filter scripts/remove-emojis.lua \ + -t scripts/panvimdoc.lua \ + ../../README.md \ + -o ../../doc/persisted.nvim.txt + +$(PANVIMDOC_DIR): + git clone --depth=1 --no-single-branch $(PANVIMDOC_URL) $(PANVIMDOC_DIR) + @rm -rf doc/panvimdoc/.git + +check: + stylua --check lua/ tests/ -f ./stylua.toml + +format: + stylua lua/ tests/ -f ./stylua.toml + +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 +TestDefaults nvim --headless --noplugin -u tests/minimal.vim +TearDown -check: - stylua --color always --check . +$(PLENARY_DIR): + git clone --depth=1 --no-single-branch $(PLENARY_URL) $(PLENARY_DIR) + @rm -rf $(PLENARY_DIR)/.git diff --git a/tests/follow_cwd/follow_cwd_spec.lua b/tests/follow_cwd/follow_cwd_spec.lua index 85a705a..9f6bf99 100644 --- a/tests/follow_cwd/follow_cwd_spec.lua +++ b/tests/follow_cwd/follow_cwd_spec.lua @@ -4,13 +4,12 @@ local session_dir = vim.fn.getcwd() .. "/tests/dummy_data/" -- follow_cwd = true require("persisted").setup({ - save_dir = session_dir, - follow_cwd = true, + 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") @@ -19,7 +18,6 @@ describe("Follow cwd change", function() vim.cmd(":w") require("persisted").save() vim.cmd(":bdelete") - end) it("ensures both sessions were created", function() local pattern = "/" @@ -36,13 +34,12 @@ end) -- follow_cwd = false pcall(vim.fn.system, "rm -rf tests/dummy_data") require("persisted").setup({ - save_dir = session_dir, - follow_cwd = false, + 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() @@ -51,7 +48,6 @@ describe("Don't follow cwd change", function() vim.cmd(":w") require("persisted").save() vim.cmd(":bdelete") - end) it("ensures only one session was created", function() local pattern = "/" diff --git a/tests/git_branching/git_branching_spec.lua b/tests/git_branching/git_branching_spec.lua index 55a9096..87e9ad5 100644 --- a/tests/git_branching/git_branching_spec.lua +++ b/tests/git_branching/git_branching_spec.lua @@ -18,7 +18,6 @@ describe("Git Branching", function() 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() diff --git a/tests/minimal.vim b/tests/minimal.vim index 6b990f6..b902ea8 100644 --- a/tests/minimal.vim +++ b/tests/minimal.vim @@ -1,13 +1,7 @@ -if !isdirectory('plenary.nvim') - !git clone https://github.com/nvim-lua/plenary.nvim.git plenary.nvim - " !git -C plenary.nvim reset --hard 4b7e52044bbb84242158d977a50c4cbcd85070c7 -endif +set rtp+=. +set rtp+=./misc/plenary -set runtimepath+=plenary.nvim,. -set noswapfile -set noundofile - -runtime plugin/plenary.vim +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'} diff --git a/tests/setup/create_sessions_spec.lua b/tests/setup/create_sessions_spec.lua index 51916d4..3a1921d 100644 --- a/tests/setup/create_sessions_spec.lua +++ b/tests/setup/create_sessions_spec.lua @@ -9,7 +9,6 @@ require("persisted").setup({ 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")