aboutsummaryrefslogtreecommitdiff
path: root/runtime/doc/pi_health.txt
blob: 69833103d1ecedaeb783f7e75382973421ae6e91 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
*pi_health.txt*   Healthcheck framework

Author: TJ DeVries <devries.timothyj@gmail.com>

==============================================================================
1. Introduction				|health.vim-intro|
2. Commands and functions		|health.vim-manual|
3. Create a healthcheck			|health.vim-dev|

==============================================================================
Introduction				*healthcheck* *health.vim-intro*

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: >

        :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: >

	You have not installed the Neovim Python module
	You might want to try `pip install Neovim`
< 
Plugin authors are encouraged to add healthchecks, see |health.vim-dev|.

==============================================================================
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
------------------------------------------------------------------------------

health.vim functions are for creating new healthchecks. They mostly just do
some layout and formatting, to give users a consistent presentation.

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.

health#report_info({msg})				*health#report_info*
	Displays an informational message.

health#report_ok({msg})					*health#report_ok*
	Displays a "success" message.

health#report_warn({msg}, [{suggestions}])		*health#report_warn*
        Displays a warning. {suggestions} is an optional List of suggestions.

health#report_error({msg}, [{suggestions}])		*health#report_error*
        Displays an error. {suggestions} is an optional List of suggestions.

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: >

                function! health#my_plug#check() abort
                  silent call s:check_environment_vars()
                  silent call s:check_python_configuration()
                endfunction
<
        The function will be found and called automatically when the user
        invokes |:CheckHealth|.

	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.

==============================================================================
Create a healthcheck			*health.vim-dev*

Healthchecks are functions that check the health of the system. Neovim has
built-in checkers, found in $VIMRUNTIME/autoload/health/.

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.

If your plugin is named "jslint", then its healthcheck function must be >

        health#jslint#check()
<
defined in this file on 'runtimepath': >

        autoload/health/jslint.vim
<
Here's a sample to get started: >

        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
<
==============================================================================

vim:tw=78:ts=8:ft=help:fdm=marker