telescope-frecency.nvim/lua/frecency/tests/util.lua
JINNOUCHI Yasushi 1f32091e2b
refactor!: use OO & add tests (#100)
* I did an overhall for all codes and added typing by Lua-language-server and tests. It also works on CI.
* Now it searches files on the workspace completely asynchronously. It does not block your text input. (Fix #106)
Make count = 1 when you open a file you've never opened (Fix #107)
2023-08-06 16:02:37 +09:00

18 lines
486 B
Lua

local uv = vim.uv or vim.loop
local Path = require "plenary.path"
---@param entries string[]
---@return PlenaryPath the top dir of tree
---@return fun(): nil sweep all entries
local function make_tree(entries)
local dir = Path:new(Path.new(assert(uv.fs_mkdtemp "tests_XXXXXX")):absolute())
for _, entry in ipairs(entries) do
dir:joinpath(entry):touch { parents = true }
end
return dir, function()
dir:rm { recursive = true }
end
end
return { make_tree = make_tree }