Skip to content

Commit 7bb5e54

Browse files
test: update get_path to take string[] and check mini.nvim before mini.icons
1 parent a5b71e2 commit 7bb5e54

1 file changed

Lines changed: 7 additions & 18 deletions

File tree

tests/minimal_init.lua

Lines changed: 7 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,10 @@
1-
---@param name string
2-
---@param optional? boolean
3-
---@return string
4-
local function get_path(name, optional)
5-
local paths = vim.fs.find(name, { path = vim.fn.stdpath('data') })
6-
if not optional then
7-
assert(#paths == 1, 'plugin must have one path')
8-
end
9-
return paths[1]
10-
end
11-
121
---@param names string[]
132
---@return string
14-
local function get_first_path(names)
3+
local function get_path(names)
154
for _, name in ipairs(names) do
16-
local path = get_path(name, true)
17-
if path then
18-
return path
5+
local paths = vim.fs.find(name, { path = vim.fn.stdpath('data') })
6+
if #paths == 1 then
7+
return paths[1]
198
end
209
end
2110
error(table.concat(names, ' or ') .. ' must be installed')
@@ -28,16 +17,16 @@ vim.o.tabstop = 4
2817
vim.o.wrap = false
2918

3019
-- source dependencies first
31-
vim.opt.rtp:prepend(get_path('nvim-treesitter'))
20+
vim.opt.rtp:prepend(get_path({ 'nvim-treesitter' }))
3221
vim.cmd.runtime('plugin/nvim-treesitter.lua')
33-
vim.opt.rtp:prepend(get_first_path({ 'mini.icons', 'mini.nvim' }))
22+
vim.opt.rtp:prepend(get_path({ 'mini.nvim', 'mini.icons' }))
3423

3524
-- source this plugin
3625
vim.opt.rtp:prepend('.')
3726
vim.cmd.runtime('plugin/render-markdown.lua')
3827

3928
-- used for unit testing
40-
vim.opt.rtp:prepend(get_path('plenary.nvim'))
29+
vim.opt.rtp:prepend(get_path({ 'plenary.nvim' }))
4130
vim.cmd.runtime('plugin/plenary.vim')
4231

4332
require('nvim-treesitter')

0 commit comments

Comments
 (0)