Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(checkhealth)!: rename to vim.health, move logic to Lua #18720
- Complete function: There was lots of unnecessary C code for the complete function, therefore moving it to Lua and use all the plumbing we have in place to retrieve the results. - Moving the module: It's important we keep nvim lua modules name spaced, avoids conflict with plugins, luarocks, etc.
- Loading branch information
Showing
8 changed files
with
90 additions
and
117 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,6 @@ | ||
local M = {} | ||
|
||
function M.report_start(msg) | ||
vim.fn['health#report_start'](msg) | ||
end | ||
|
||
function M.report_info(msg) | ||
vim.fn['health#report_info'](msg) | ||
end | ||
|
||
function M.report_ok(msg) | ||
vim.fn['health#report_ok'](msg) | ||
end | ||
|
||
function M.report_warn(msg, ...) | ||
vim.fn['health#report_warn'](msg, ...) | ||
end | ||
|
||
function M.report_error(msg, ...) | ||
vim.fn['health#report_error'](msg, ...) | ||
end | ||
|
||
return M | ||
return setmetatable({}, { | ||
__index = function(_, k) | ||
vim.deprecate("require('health')", 'vim.health', '0.9', false) | ||
return vim.health[k] | ||
end, | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
local M = {} | ||
|
||
function M.report_start(msg) | ||
vim.fn['health#report_start'](msg) | ||
end | ||
|
||
function M.report_info(msg) | ||
vim.fn['health#report_info'](msg) | ||
end | ||
|
||
function M.report_ok(msg) | ||
vim.fn['health#report_ok'](msg) | ||
end | ||
|
||
function M.report_warn(msg, ...) | ||
vim.fn['health#report_warn'](msg, ...) | ||
end | ||
|
||
function M.report_error(msg, ...) | ||
vim.fn['health#report_error'](msg, ...) | ||
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.-$', '') | ||
else | ||
-- Vim: transform "../autoload/health/provider.vim" into "provider" | ||
return vim.fn.fnamemodify(path, ':t:r') | ||
end | ||
end | ||
|
||
local PATTERNS = { '/autoload/health/*.vim', '/lua/**/**/health.lua', '/lua/**/**/health/init.lua' } | ||
-- :checkhealth completion function used by ex_getln.c get_healthcheck_names() | ||
M._complete = function() | ||
local names = vim.tbl_flatten(vim.tbl_map(function(pattern) | ||
return vim.tbl_map(path2name, vim.api.nvim_get_runtime_file(pattern, true)) | ||
end, PATTERNS)) | ||
-- Remove duplicates | ||
local unique = {} | ||
vim.tbl_map(function(f) | ||
unique[f] = true | ||
end, names) | ||
return vim.tbl_keys(unique) | ||
end | ||
|
||
return M |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,10 @@ | ||
local M = {} | ||
local health = require("health") | ||
|
||
M.check = function() | ||
health.report_start("report 1") | ||
health.report_ok("everything is fine") | ||
health.report_start("report 2") | ||
health.report_ok("nothing to see here") | ||
vim.health.report_start("report 1") | ||
vim.health.report_ok("everything is fine") | ||
vim.health.report_start("report 2") | ||
vim.health.report_ok("nothing to see here") | ||
end | ||
|
||
return M |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,10 @@ | ||
local M = {} | ||
local health = require("health") | ||
|
||
M.check = function() | ||
health.report_start("report 1") | ||
health.report_ok("everything is fine") | ||
health.report_start("report 2") | ||
health.report_ok("nothing to see here") | ||
vim.health.report_start("report 1") | ||
vim.health.report_ok("everything is fine") | ||
vim.health.report_start("report 2") | ||
vim.health.report_ok("nothing to see here") | ||
end | ||
|
||
return M |
7 changes: 3 additions & 4 deletions
7
test/functional/fixtures/lua/test_plug/submodule_failed/health.lua
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters