mirror of
https://github.com/neovim/neovim
synced 2025-07-15 16:51:49 +00:00
fix(checkhealth): handle nested lua/ directory #32918
Problem: :checkhealth fails if plugin has nested "lua/" directory Solution: trim `{runtimepath}/lua` from fullpath to get subpath (`./**/{health, health/init.lua}`)
This commit is contained in:
@ -118,7 +118,13 @@ local function filepath_to_healthcheck(path)
|
||||
func = 'health#' .. name .. '#check'
|
||||
filetype = 'v'
|
||||
else
|
||||
local subpath = path:gsub('.*/lua/', '')
|
||||
local rtp = vim
|
||||
.iter(vim.api.nvim_list_runtime_paths())
|
||||
:map(vim.fs.normalize)
|
||||
:find(function(rtp0)
|
||||
return vim.fs.relpath(rtp0, path)
|
||||
end)
|
||||
local subpath = path:gsub('^' .. vim.pesc(rtp .. '/lua/'), '')
|
||||
if vim.fs.basename(subpath) == 'health.lua' then
|
||||
-- */health.lua
|
||||
name = vim.fs.dirname(subpath)
|
||||
|
8
test/functional/fixtures/lua/test_plug/lua/health.lua
Normal file
8
test/functional/fixtures/lua/test_plug/lua/health.lua
Normal file
@ -0,0 +1,8 @@
|
||||
local M = {}
|
||||
|
||||
M.check = function()
|
||||
vim.health.start('nested lua/ directory')
|
||||
vim.health.ok('everything is ok')
|
||||
end
|
||||
|
||||
return M
|
@ -212,6 +212,18 @@ describe('vim.health', function()
|
||||
n.expect([[
|
||||
ERROR: No healthchecks found.]])
|
||||
end)
|
||||
|
||||
it('nested lua/ directory', function()
|
||||
command('checkhealth lua')
|
||||
n.expect([[
|
||||
|
||||
==============================================================================
|
||||
test_plug.lua: require("test_plug.lua.health").check()
|
||||
|
||||
nested lua/ directory ~
|
||||
- OK everything is ok
|
||||
]])
|
||||
end)
|
||||
end)
|
||||
end)
|
||||
|
||||
|
Reference in New Issue
Block a user