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-05-01 08:09:29 -07:00
|
|
|
Type <M-]> to see the table of contents.
|
2016-06-16 14:01:47 -07:00
|
|
|
|
|
|
|
==============================================================================
|
2016-08-07 11:16:30 -07:00
|
|
|
Introduction *healthcheck* *health.vim-intro*
|
2016-06-16 14:01:47 -07:00
|
|
|
|
2016-08-07 11:16:30 -07:00
|
|
|
Troubleshooting user configuration problems is a time-consuming task that
|
|
|
|
developers want to minimize. health.vim provides a simple framework for plugin
|
|
|
|
authors to hook into, and for users to invoke, to check and report the user's
|
|
|
|
configuration and environment. Type this command to try it: >
|
2016-06-16 14:01:47 -07:00
|
|
|
|
2016-08-07 11:16:30 -07:00
|
|
|
:CheckHealth
|
|
|
|
<
|
|
|
|
For example, some users have broken or unusual Python setups, which breaks the
|
|
|
|
|:python| command. |:CheckHealth| detects several common Python configuration
|
|
|
|
problems and reports them. If the Neovim Python module is not installed, it
|
|
|
|
shows a warning: >
|
2016-06-16 14:01:47 -07:00
|
|
|
|
|
|
|
You have not installed the Neovim Python module
|
2016-08-07 11:16:30 -07:00
|
|
|
You might want to try `pip install Neovim`
|
2016-06-16 14:01:47 -07:00
|
|
|
<
|
2016-08-07 11:16:30 -07:00
|
|
|
Plugin authors are encouraged to add healthchecks, see |health.vim-dev|.
|
2016-06-16 14:01:47 -07:00
|
|
|
|
|
|
|
==============================================================================
|
2016-08-07 11:16:30 -07:00
|
|
|
Commands and functions *health.vim-manual*
|
|
|
|
|
|
|
|
Commands
|
|
|
|
------------------------------------------------------------------------------
|
|
|
|
*:CheckHealth*
|
|
|
|
:CheckHealth Run all healthchecks and show the output in a new
|
|
|
|
tabpage. These healthchecks are included by default:
|
|
|
|
- python2
|
|
|
|
- python3
|
|
|
|
- ruby
|
|
|
|
- remote plugin
|
|
|
|
|
|
|
|
:CheckHealth {plugins}
|
|
|
|
Run healthchecks for one or more plugins. E.g. to run
|
|
|
|
only the standard Nvim healthcheck: >
|
|
|
|
:CheckHealth nvim
|
|
|
|
< To run the healthchecks for the "foo" and "bar" plugins
|
|
|
|
(assuming these plugins are on your 'runtimepath' and
|
|
|
|
they have implemented health#foo#check() and
|
|
|
|
health#bar#check(), respectively): >
|
|
|
|
:CheckHealth foo bar
|
|
|
|
<
|
|
|
|
Functions
|
|
|
|
------------------------------------------------------------------------------
|
2016-06-16 14:01:47 -07:00
|
|
|
|
2016-08-07 11:16:30 -07:00
|
|
|
health.vim functions are for creating new healthchecks. They mostly just do
|
|
|
|
some layout and formatting, to give users a consistent presentation.
|
2016-06-16 14:01:47 -07:00
|
|
|
|
2016-08-07 11:16:30 -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
|
|
|
|
2016-08-07 11:16:30 -07:00
|
|
|
health#report_info({msg}) *health#report_info*
|
|
|
|
Displays an informational message.
|
2016-06-16 14:01:47 -07:00
|
|
|
|
2016-08-07 11:16:30 -07:00
|
|
|
health#report_ok({msg}) *health#report_ok*
|
|
|
|
Displays a "success" message.
|
2016-06-16 14:01:47 -07:00
|
|
|
|
2016-08-07 11:16:30 -07:00
|
|
|
health#report_warn({msg}, [{suggestions}]) *health#report_warn*
|
|
|
|
Displays a warning. {suggestions} is an optional List of suggestions.
|
2016-06-16 14:01:47 -07:00
|
|
|
|
2016-08-07 11:16:30 -07:00
|
|
|
health#report_error({msg}, [{suggestions}]) *health#report_error*
|
|
|
|
Displays an error. {suggestions} is an optional List of suggestions.
|
2016-06-16 14:01:47 -07:00
|
|
|
|
2016-08-07 11:16:30 -07:00
|
|
|
health#{plugin}#check() *health.user_checker*
|
|
|
|
This is the form of a healthcheck definition. Call the above functions
|
|
|
|
from this function, then |:CheckHealth| does the rest. Example: >
|
2016-06-16 14:01:47 -07:00
|
|
|
|
2016-08-07 11:16:30 -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
|
|
|
<
|
2016-08-07 11:16:30 -07:00
|
|
|
The function will be found and called automatically when the user
|
|
|
|
invokes |:CheckHealth|.
|
2016-06-16 14:01:47 -07:00
|
|
|
|
2016-08-07 11:16:30 -07:00
|
|
|
All output will be captured from the healthcheck. Use the
|
|
|
|
health#report_* functions so that your healthcheck has a format
|
|
|
|
consistent with the standard healthchecks.
|
2016-06-16 14:01:47 -07:00
|
|
|
|
|
|
|
==============================================================================
|
2016-08-07 11:16:30 -07:00
|
|
|
Create a healthcheck *health.vim-dev*
|
2016-06-16 14:01:47 -07:00
|
|
|
|
2016-08-07 11:16:30 -07:00
|
|
|
Healthchecks are functions that check the health of the system. Neovim has
|
|
|
|
built-in checkers, found in $VIMRUNTIME/autoload/health/.
|
2016-06-16 14:01:47 -07:00
|
|
|
|
2016-08-07 11:16:30 -07:00
|
|
|
To add a new checker for your own plugin, simply define a
|
|
|
|
health#{plugin}#check() function in autoload/health/{plugin}.vim.
|
|
|
|
|:CheckHealth| automatically finds and invokes such functions.
|
2016-06-16 14:01:47 -07:00
|
|
|
|
2016-08-07 11:16:30 -07:00
|
|
|
If your plugin is named "jslint", then its healthcheck function must be >
|
|
|
|
health#jslint#check()
|
2016-06-16 14:01:47 -07:00
|
|
|
|
2017-05-01 08:09:29 -07:00
|
|
|
defined in this file on 'runtimepath': >
|
2016-08-07 11:16:30 -07:00
|
|
|
autoload/health/jslint.vim
|
|
|
|
|
2017-05-01 08:09:29 -07:00
|
|
|
Here's a sample to get started: >
|
2016-08-07 11:16:30 -07:00
|
|
|
function! health#jslint#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 jslint',
|
|
|
|
\ ['npm install --save jslint'])
|
|
|
|
endif
|
|
|
|
endfunction
|
2017-05-01 08:09:29 -07:00
|
|
|
|
2016-06-16 14:01:47 -07:00
|
|
|
==============================================================================
|
|
|
|
|
|
|
|
vim:tw=78:ts=8:ft=help:fdm=marker
|