test: cleanup ftplugin_spec.lua #32948

Problem:
- cannot run ftplugin_spec.lua by itself
- test leaves foo/ dir

Solution:
- fix setup and teardown
This commit is contained in:
Justin M. Keyes
2025-03-17 17:13:04 -07:00
committed by GitHub
parent 3b1d0e7f70
commit 1369d86812
2 changed files with 26 additions and 20 deletions

View File

@@ -3,18 +3,12 @@ local M = {}
--- @param module string
---@return string
function M.includeexpr(module)
---@param fname string
---@return boolean
local function filereadable(fname)
return vim.fn.filereadable(fname) == 1
end
local fname = module:gsub('%.', '/')
local root = vim.fs.root(vim.api.nvim_buf_get_name(0), 'lua') or vim.fn.getcwd()
for _, suf in ipairs { '.lua', '/init.lua' } do
local path = vim.fs.joinpath(root, 'lua', fname .. suf)
if filereadable(path) then
if vim.uv.fs_stat(path) then
return path
end
end