2016-08-07 11:16:30 -07:00
|
|
|
*pi_health.txt* Healthcheck framework
|
2016-06-16 14:01:47 -07:00
|
|
|
|
|
|
|
Author: TJ DeVries <devries.timothyj@gmail.com>
|
|
|
|
|
2017-10-20 17:33:58 -07:00
|
|
|
Type |gO| to see the table of contents.
|
2016-06-16 14:01:47 -07:00
|
|
|
|
|
|
|
==============================================================================
|
2021-10-05 15:37:39 -07:00
|
|
|
Introduction *health*
|
2016-06-16 14:01:47 -07:00
|
|
|
|
2022-09-11 02:15:06 -07:00
|
|
|
health.vim is a minimal framework to help users troubleshoot configuration and
|
|
|
|
any other environment conditions that a plugin might care about. Nvim ships
|
|
|
|
with healthchecks for configuration, performance, python support, ruby
|
|
|
|
support, clipboard support, and more.
|
2016-06-16 14:01:47 -07:00
|
|
|
|
2022-09-11 02:15:06 -07:00
|
|
|
To run all healthchecks, use: >
|
2016-06-16 14:01:47 -07:00
|
|
|
|
2021-10-05 15:37:39 -07:00
|
|
|
:checkhealth
|
2017-10-15 11:31:12 -07:00
|
|
|
<
|
|
|
|
Plugin authors are encouraged to write new healthchecks. |health-dev|
|
2016-06-16 14:01:47 -07:00
|
|
|
|
|
|
|
==============================================================================
|
2021-10-05 15:37:39 -07:00
|
|
|
Commands *health-commands*
|
2017-10-15 11:31:12 -07:00
|
|
|
|
2022-10-23 04:04:23 -07:00
|
|
|
*:che* *:checkhealth* *:CheckHealth*
|
|
|
|
:che[ckhealth] Run all healthchecks.
|
2021-10-05 15:37:39 -07:00
|
|
|
*E5009*
|
|
|
|
Nvim depends on |$VIMRUNTIME|, 'runtimepath' and 'packpath' to
|
|
|
|
find the standard "runtime files" for syntax highlighting,
|
|
|
|
filetype-specific behavior, and standard plugins (including
|
|
|
|
:checkhealth). If the runtime files cannot be found then
|
|
|
|
those features will not work.
|
2017-10-15 11:31:12 -07:00
|
|
|
|
2022-10-23 04:04:23 -07:00
|
|
|
:che[ckhealth] {plugins}
|
2021-10-05 15:37:39 -07:00
|
|
|
Run healthcheck(s) for one or more plugins. E.g. to run only
|
|
|
|
the standard Nvim healthcheck: >
|
|
|
|
:checkhealth nvim
|
2016-08-07 11:16:30 -07:00
|
|
|
<
|
2021-10-05 15:37:39 -07:00
|
|
|
To run the healthchecks for the "foo" and "bar" plugins
|
2022-09-11 02:15:06 -07:00
|
|
|
(assuming they are on 'runtimepath' and they have implemented
|
|
|
|
the Lua `require("foo.health").check()` interface): >
|
2021-10-05 15:37:39 -07:00
|
|
|
:checkhealth foo bar
|
2021-09-10 11:35:05 -07:00
|
|
|
<
|
2022-09-11 02:15:06 -07:00
|
|
|
To run healthchecks for Lua submodules, use dot notation or
|
|
|
|
"*" to refer to all submodules. For example Nvim provides
|
|
|
|
`vim.lsp` and `vim.treesitter`: >
|
2021-10-05 15:37:39 -07:00
|
|
|
:checkhealth vim.lsp vim.treesitter
|
|
|
|
:checkhealth vim*
|
2021-09-10 11:35:05 -07:00
|
|
|
<
|
|
|
|
==============================================================================
|
2022-09-11 02:15:06 -07:00
|
|
|
Functions *health-functions* *vim.health*
|
2021-09-10 11:35:05 -07:00
|
|
|
|
2022-09-11 02:15:06 -07:00
|
|
|
The Lua "health" module can be used to create new healthchecks. To get started
|
|
|
|
see |health-dev|.
|
2022-05-31 11:10:18 -07:00
|
|
|
|
|
|
|
vim.health.report_start({name}) *vim.health.report_start()*
|
2021-10-05 15:37:39 -07:00
|
|
|
Starts a new report. Most plugins should call this only once, but if
|
|
|
|
you want different sections to appear in your report, call this once
|
|
|
|
per section.
|
2021-09-10 11:35:05 -07:00
|
|
|
|
2022-05-31 11:10:18 -07:00
|
|
|
vim.health.report_info({msg}) *vim.health.report_info()*
|
2021-10-05 15:37:39 -07:00
|
|
|
Reports an informational message.
|
2021-09-10 11:35:05 -07:00
|
|
|
|
2022-05-31 11:10:18 -07:00
|
|
|
vim.health.report_ok({msg}) *vim.health.report_ok()*
|
2021-10-05 15:37:39 -07:00
|
|
|
Reports a "success" message.
|
2021-09-10 11:35:05 -07:00
|
|
|
|
2022-05-31 11:10:18 -07:00
|
|
|
vim.health.report_warn({msg} [, {advice}]) *vim.health.report_warn()*
|
2022-09-11 02:15:06 -07:00
|
|
|
Reports a warning. {advice} is an optional list of suggestions to
|
|
|
|
present to the user.
|
2021-09-10 11:35:05 -07:00
|
|
|
|
2022-05-31 11:10:18 -07:00
|
|
|
vim.health.report_error({msg} [, {advice}]) *vim.health.report_error()*
|
2022-09-11 02:15:06 -07:00
|
|
|
Reports an error. {advice} is an optional list of suggestions to
|
|
|
|
present to the user.
|
2021-09-10 11:35:05 -07:00
|
|
|
|
|
|
|
==============================================================================
|
2022-09-11 02:15:06 -07:00
|
|
|
Create a healthcheck *health-dev*
|
|
|
|
|
|
|
|
Healthchecks are functions that check the user environment, configuration, or
|
|
|
|
any other prerequisites that a plugin cares about. Nvim ships with
|
|
|
|
healthchecks in:
|
|
|
|
- $VIMRUNTIME/autoload/health/
|
|
|
|
- $VIMRUNTIME/lua/vim/lsp/health.lua
|
|
|
|
- $VIMRUNTIME/lua/vim/treesitter/health.lua
|
|
|
|
- and more...
|
|
|
|
|
|
|
|
To add a new healthcheck for your own plugin, simply create a "health.lua"
|
|
|
|
module on 'runtimepath' that returns a table with a "check()" function. Then
|
|
|
|
|:checkhealth| will automatically find and invoke the function.
|
|
|
|
|
|
|
|
For example if your plugin is named "foo", define your healthcheck module at
|
|
|
|
one of these locations (on 'runtimepath'):
|
2021-10-05 15:37:39 -07:00
|
|
|
- lua/foo/health/init.lua
|
|
|
|
- lua/foo/health.lua
|
2021-09-10 11:35:05 -07:00
|
|
|
|
2022-09-11 02:15:06 -07:00
|
|
|
If your plugin also provides a submodule named "bar" for which you want
|
|
|
|
a separate healthcheck, define the healthcheck at one of these locations:
|
2021-10-05 15:37:39 -07:00
|
|
|
- lua/foo/bar/health/init.lua
|
|
|
|
- lua/foo/bar/health.lua
|
2021-09-10 11:35:05 -07:00
|
|
|
|
2022-09-11 02:15:06 -07:00
|
|
|
All such health modules must return a Lua table containing a `check()`
|
|
|
|
function.
|
2021-09-10 11:35:05 -07:00
|
|
|
|
2022-09-11 02:15:06 -07:00
|
|
|
Copy this sample code into `lua/foo/health.lua`, replacing "foo" in the path
|
|
|
|
with your plugin name: >
|
2021-09-10 11:35:05 -07:00
|
|
|
|
2021-10-05 15:37:39 -07:00
|
|
|
local M = {}
|
2021-09-10 11:35:05 -07:00
|
|
|
|
2021-10-05 15:37:39 -07:00
|
|
|
M.check = function()
|
2022-05-31 11:10:18 -07:00
|
|
|
vim.health.report_start("my_plugin report")
|
2021-10-05 15:37:39 -07:00
|
|
|
-- make sure setup function parameters are ok
|
|
|
|
if check_setup() then
|
2022-09-11 02:15:06 -07:00
|
|
|
vim.health.report_ok("Setup is correct")
|
2021-10-05 15:37:39 -07:00
|
|
|
else
|
2022-09-11 02:15:06 -07:00
|
|
|
vim.health.report_error("Setup is incorrect")
|
2021-10-05 15:37:39 -07:00
|
|
|
end
|
|
|
|
-- do some more checking
|
|
|
|
-- ...
|
|
|
|
end
|
2021-09-10 11:35:05 -07:00
|
|
|
|
2021-10-05 15:37:39 -07:00
|
|
|
return M
|
2021-09-10 11:35:05 -07:00
|
|
|
|
2021-10-05 15:37:39 -07:00
|
|
|
|
|
|
|
vim:et:tw=78:ts=8:ft=help:fdm=marker
|