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
|
|
|
|
2017-10-15 11:31:12 -07:00
|
|
|
health.vim is a minimal framework to help with troubleshooting user
|
|
|
|
configuration. Nvim ships with healthchecks for configuration, performance,
|
|
|
|
python support, ruby support, clipboard support, and more.
|
2016-06-16 14:01:47 -07:00
|
|
|
|
2017-10-15 11:31:12 -07:00
|
|
|
To run the healthchecks, use this command: >
|
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
|
|
|
|
2021-10-05 15:37:39 -07:00
|
|
|
*:checkhealth* *:CheckHealth*
|
2017-10-15 11:31:12 -07:00
|
|
|
:checkhealth 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
|
|
|
|
|
|
|
:checkhealth {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
|
|
|
|
(assuming these plugins are on 'runtimepath' or 'packpath' and
|
|
|
|
they have implemented the Lua or Vimscript interface
|
|
|
|
require("foo.health").check() and health#bar#check(),
|
|
|
|
respectively): >
|
|
|
|
:checkhealth foo bar
|
2021-09-10 11:35:05 -07:00
|
|
|
<
|
2021-10-05 15:37:39 -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` >
|
|
|
|
:checkhealth vim.lsp vim.treesitter
|
|
|
|
:checkhealth vim*
|
2021-09-10 11:35:05 -07:00
|
|
|
<
|
|
|
|
==============================================================================
|
2022-05-31 11:10:18 -07:00
|
|
|
Lua Functions *health-functions-lua* *health-lua* *vim.health*
|
2021-09-10 11:35:05 -07:00
|
|
|
|
|
|
|
The Lua "health" module can be used to create new healthchecks (see also
|
2022-05-31 11:10:18 -07:00
|
|
|
|health-functions-vim|). To get started, simply use:
|
|
|
|
|
|
|
|
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()*
|
2021-10-05 15:37:39 -07:00
|
|
|
Reports a warning. {advice} is an optional List of suggestions.
|
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()*
|
2021-10-05 15:37:39 -07:00
|
|
|
Reports an error. {advice} is an optional List of suggestions.
|
2021-09-10 11:35:05 -07:00
|
|
|
|
|
|
|
==============================================================================
|
2021-10-05 15:37:39 -07:00
|
|
|
Create a Lua healthcheck *health-dev-lua*
|
2021-09-10 11:35:05 -07:00
|
|
|
|
|
|
|
Healthchecks are functions that check the user environment, configuration,
|
|
|
|
etc. Nvim has built-in healthchecks in $VIMRUNTIME/autoload/health/.
|
|
|
|
|
|
|
|
To add a new healthcheck for your own plugin, simply define a Lua module in
|
|
|
|
your plugin that returns a table with a "check()" function. |:checkhealth|
|
|
|
|
will automatically find and invoke this function.
|
|
|
|
|
|
|
|
If your plugin is named "foo", then its healthcheck module should be a file in
|
|
|
|
one of these locations on 'runtimepath' or 'packpath':
|
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
|
|
|
|
|
|
|
If your plugin provides a submodule named "bar" for which you want a separate
|
|
|
|
healthcheck, define the healthcheck at one of these locations on 'runtimepath'
|
|
|
|
or 'packpath':
|
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
|
|
|
|
|
|
|
All submodules should return a Lua table containing the method `check()`.
|
|
|
|
|
|
|
|
Copy this sample code into `lua/foo/health/init.lua` or `lua/foo/health.lua`,
|
|
|
|
replacing "foo" in the path with your plugin name: >
|
|
|
|
|
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-05-31 11:10:18 -07:00
|
|
|
vim.health.report_ok("Setup function is correct")
|
2021-10-05 15:37:39 -07:00
|
|
|
else
|
2022-05-31 11:10:18 -07:00
|
|
|
vim.health.report_error("Setup function 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
|
|
|
|
2017-10-15 11:31:12 -07:00
|
|
|
==============================================================================
|
2021-10-05 15:37:39 -07:00
|
|
|
Vimscript Functions *health-functions-vimscript* *health-vimscript*
|
2016-06-16 14:01:47 -07:00
|
|
|
|
2021-09-10 11:35:05 -07:00
|
|
|
health.vim functions are for creating new healthchecks. (See also
|
|
|
|
|health-functions-lua|)
|
2016-06-16 14:01:47 -07:00
|
|
|
|
2021-10-05 15:37:39 -07:00
|
|
|
health#report_start({name}) *health#report_start*
|
|
|
|
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.
|
2016-06-16 14:01:47 -07:00
|
|
|
|
2021-10-05 15:37:39 -07:00
|
|
|
health#report_info({msg}) *health#report_info*
|
|
|
|
Reports an informational message.
|
2016-06-16 14:01:47 -07:00
|
|
|
|
2021-10-05 15:37:39 -07:00
|
|
|
health#report_ok({msg}) *health#report_ok*
|
|
|
|
Reports a "success" message.
|
2016-06-16 14:01:47 -07:00
|
|
|
|
2021-10-05 15:37:39 -07:00
|
|
|
health#report_warn({msg} [, {advice}]) *health#report_warn*
|
|
|
|
Reports a warning. {advice} is an optional List of suggestions.
|
2016-06-16 14:01:47 -07:00
|
|
|
|
2021-10-05 15:37:39 -07:00
|
|
|
health#report_error({msg} [, {advice}]) *health#report_error*
|
|
|
|
Reports an error. {advice} is an optional List of suggestions.
|
2016-06-16 14:01:47 -07:00
|
|
|
|
2021-10-05 15:37:39 -07:00
|
|
|
health#{plugin}#check() *health.user_checker*
|
|
|
|
Healthcheck function for {plugin}. Called by |:checkhealth|
|
|
|
|
automatically. Example: >
|
2016-06-16 14:01:47 -07:00
|
|
|
|
2021-10-05 15:37:39 -07:00
|
|
|
function! health#my_plug#check() abort
|
|
|
|
silent call s:check_environment_vars()
|
|
|
|
silent call s:check_python_configuration()
|
|
|
|
endfunction
|
2016-06-16 14:01:47 -07:00
|
|
|
<
|
|
|
|
==============================================================================
|
2021-10-05 15:37:39 -07:00
|
|
|
Create a healthcheck *health-dev-vim*
|
2016-06-16 14:01:47 -07:00
|
|
|
|
2017-10-15 11:31:12 -07:00
|
|
|
Healthchecks are functions that check the user environment, configuration,
|
|
|
|
etc. Nvim has built-in healthchecks in $VIMRUNTIME/autoload/health/.
|
2016-06-16 14:01:47 -07:00
|
|
|
|
2017-10-15 11:31:12 -07:00
|
|
|
To add a new healthcheck for your own plugin, simply define a
|
2016-08-07 11:16:30 -07:00
|
|
|
health#{plugin}#check() function in autoload/health/{plugin}.vim.
|
2017-10-15 11:31:12 -07:00
|
|
|
|:checkhealth| automatically finds and invokes such functions.
|
2016-06-16 14:01:47 -07:00
|
|
|
|
2017-10-15 11:31:12 -07:00
|
|
|
If your plugin is named "foo", then its healthcheck function must be >
|
2021-10-05 15:37:39 -07:00
|
|
|
health#foo#check()
|
2016-06-16 14:01:47 -07:00
|
|
|
|
2021-10-05 15:37:39 -07:00
|
|
|
defined in this file on 'runtimepath' or 'packpath':
|
|
|
|
- autoload/health/foo.vim
|
2016-08-07 11:16:30 -07:00
|
|
|
|
2017-10-15 11:31:12 -07:00
|
|
|
Copy this sample code into autoload/health/foo.vim and replace "foo" with your
|
|
|
|
plugin name: >
|
2021-10-05 15:37:39 -07:00
|
|
|
function! health#foo#check() abort
|
|
|
|
call health#report_start('sanity checks')
|
|
|
|
" perform arbitrary checks
|
|
|
|
" ...
|
|
|
|
|
|
|
|
if looks_good
|
|
|
|
call health#report_ok('found required dependencies')
|
|
|
|
else
|
|
|
|
call health#report_error('cannot find foo',
|
|
|
|
\ ['npm install --save foo'])
|
|
|
|
endif
|
|
|
|
endfunction
|
|
|
|
|
|
|
|
vim:et:tw=78:ts=8:ft=help:fdm=marker
|