Skip to content

Commit 998c8b3

Browse files
committed
feat: Add minimal configurations for testing
1 parent a35c0ba commit 998c8b3

File tree

3 files changed

+123
-0
lines changed

3 files changed

+123
-0
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
lua/.tests

lua/spec/minimal_init_fzf.lua

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
local M = {}
2+
3+
function M.root(root)
4+
local f = debug.getinfo(1, "S").source:sub(2)
5+
return vim.fn.fnamemodify(f, ":p:h:h") .. "/" .. (root or "")
6+
end
7+
8+
---@param plugin string
9+
function M.load(plugin)
10+
local name = plugin:match(".*/(.*)")
11+
local package_root = M.root(".tests/site/pack/deps/start/")
12+
if not vim.loop.fs_stat(package_root .. name) then
13+
print("Installing " .. plugin)
14+
vim.fn.mkdir(package_root, "p")
15+
vim.fn.system({
16+
"git",
17+
"clone",
18+
"--depth=1",
19+
"https://github.com/" .. plugin .. ".git",
20+
package_root .. "/" .. name,
21+
})
22+
end
23+
end
24+
25+
function M.setup()
26+
vim.cmd([[set runtimepath=$VIMRUNTIME]])
27+
vim.opt.runtimepath:append(M.root())
28+
vim.opt.runtimepath:append("./")
29+
vim.opt.packpath = { M.root(".tests/site") }
30+
31+
-- dependencies
32+
M.load("ibhagwan/fzf-lua")
33+
M.load("tpope/vim-fugitive")
34+
M.load("tpope/vim-rhubarb")
35+
M.load("sindrest/diffview.nvim")
36+
37+
vim.env.XDG_CONFIG_HOME = M.root(".tests/config")
38+
vim.env.XDG_DATA_HOME = M.root(".tests/data")
39+
vim.env.XDG_STATE_HOME = M.root(".tests/state")
40+
vim.env.XDG_CACHE_HOME = M.root(".tests/cache")
41+
42+
print("Setup complete...\n")
43+
require("fzf-lua").setup({
44+
"telescope",
45+
winopts = {
46+
hl_border = "Normal",
47+
},
48+
fzf_layout = "default",
49+
})
50+
51+
require("advanced_git_search.fzf").setup({
52+
git_flags = { "-c", "delta.side-by-side=false" },
53+
git_diff_flags = {},
54+
show_builtin_git_pickers = true,
55+
diff_plugin = "diffview",
56+
entry_default_author_or_date = "author",
57+
})
58+
59+
print("Config complete...\n")
60+
end
61+
62+
M.setup()
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
local M = {}
2+
3+
function M.root(root)
4+
local f = debug.getinfo(1, "S").source:sub(2)
5+
return vim.fn.fnamemodify(f, ":p:h:h") .. "/" .. (root or "")
6+
end
7+
8+
---@param plugin string
9+
function M.load(plugin)
10+
local name = plugin:match(".*/(.*)")
11+
local package_root = M.root(".tests/site/pack/deps/start/")
12+
if not vim.loop.fs_stat(package_root .. name) then
13+
print("Installing " .. plugin)
14+
vim.fn.mkdir(package_root, "p")
15+
vim.fn.system({
16+
"git",
17+
"clone",
18+
"--depth=1",
19+
"https://github.com/" .. plugin .. ".git",
20+
package_root .. "/" .. name,
21+
})
22+
end
23+
end
24+
25+
function M.setup()
26+
vim.cmd([[set runtimepath=$VIMRUNTIME]])
27+
vim.opt.runtimepath:append(M.root())
28+
vim.opt.runtimepath:append("./")
29+
vim.opt.packpath = { M.root(".tests/site") }
30+
31+
-- dependencies
32+
M.load("nvim-lua/plenary.nvim")
33+
M.load("nvim-telescope/telescope.nvim")
34+
M.load("tpope/vim-fugitive")
35+
M.load("tpope/vim-rhubarb")
36+
M.load("sindrest/diffview.nvim")
37+
38+
vim.env.XDG_CONFIG_HOME = M.root(".tests/config")
39+
vim.env.XDG_DATA_HOME = M.root(".tests/data")
40+
vim.env.XDG_STATE_HOME = M.root(".tests/state")
41+
vim.env.XDG_CACHE_HOME = M.root(".tests/cache")
42+
43+
print("Setup complete...\n")
44+
45+
require("telescope").setup({
46+
extensions = {
47+
advanced_git_search = {
48+
git_flags = { "-c", "delta.side-by-side=false" },
49+
git_diff_flags = {},
50+
show_builtin_git_pickers = true,
51+
diff_plugin = "diffview",
52+
},
53+
},
54+
})
55+
require("telescope").load_extension("advanced_git_search")
56+
57+
print("Config complete...\n")
58+
end
59+
60+
M.setup()

0 commit comments

Comments
 (0)