health: migrate to Lua #21661

* refactor: remove all vimscript from nvim/health
* fixup: previous method broke if you had a folder named 'x-lua'
This commit is contained in:
TJ DeVries
2023-01-16 04:55:24 -05:00
committed by GitHub
parent 8a5dad44a7
commit 307efe4906
2 changed files with 236 additions and 211 deletions

View File

@@ -23,7 +23,20 @@ end
local path2name = function(path)
if path:match('%.lua$') then
-- Lua: transform "../lua/vim/lsp/health.lua" into "vim.lsp"
return path:gsub('.-lua[%\\%/]', '', 1):gsub('[%\\%/]', '.'):gsub('%.health.-$', '')
-- Get full path, make sure all slashes are '/'
path = vim.fs.normalize(path)
-- Remove everything up to the last /lua/ folder
path = path:gsub('^.*/lua/', '')
-- Remove the filename (health.lua)
path = vim.fn.fnamemodify(path, ':h')
-- Change slashes to dots
path = path:gsub('/', '.')
return path
else
-- Vim: transform "../autoload/health/provider.vim" into "provider"
return vim.fn.fnamemodify(path, ':t:r')