robin/laufey

git clone https://git.robinwobin.dev/robin/laufey

flatplumdocs(health): avoid warnings for dynamic filetypes #410367b34bca2a6

master
5.7 KiB163 linesraw
1*health.txt*               Nvim
2
3
4                 NVIM REFERENCE MANUAL
5
6
7                                       Type |gO| to see the table of contents.
8
9==============================================================================
10Checkhealth                                                *vim.health* *health*
11
12vim.health is a minimal framework to help users troubleshoot configuration and
13any other environment conditions that a plugin might care about. Nvim ships
14with healthchecks for configuration, performance, python support, ruby
15support, clipboard support, and more.
16
17To run all healthchecks, use: >vim
18    :checkhealth
19<
20
21Plugin authors are encouraged to write new healthchecks. |health-dev|
22
23COMMANDS                                                     *health-commands*
24
25                                                           *:che* *:checkhealth*
26:che[ckhealth]  Run all healthchecks.
27                                                                       *E5009*
28                Nvim depends on |$VIMRUNTIME|, 'runtimepath' and 'packpath' to
29                find the standard "runtime files" for syntax highlighting,
30                filetype-specific behavior, and standard plugins (including
31                :checkhealth).  If the runtime files cannot be found then
32                those features will not work.
33
34:che[ckhealth] {plugins}
35                Run healthcheck(s) for one or more plugins. E.g. to run only
36                the standard Nvim healthcheck: >vim
37                        :checkhealth vim.health
38<
39                To run the healthchecks for the "foo" and "bar" plugins
40                (assuming they are on 'runtimepath' and they have implemented
41                the Lua `require("foo.health").check()` interface): >vim
42                        :checkhealth foo bar
43<
44                To run healthchecks for Lua submodules, use dot notation or
45                "*" to refer to all submodules. For example Nvim provides
46                `vim.lsp` and `vim.treesitter`:  >vim
47                        :checkhealth vim.lsp vim.treesitter
48                        :checkhealth vim*
49<
50
51USAGE                                                           *health-usage*
52
53Local mappings in the healthcheck buffer:
54
55q               Closes the window.
56
57Global configuration:
58                                                                    *g:health*
59g:health  Dictionary with the following optional keys:
60          - `style` (`'float'|nil`) Set to "float" to display :checkhealth in
61          a floating window instead of the default behavior.
62
63          Example: >lua
64            vim.g.health = { style = 'float' }
65
66
67Local configuration:
68
69Checkhealth sets its buffer filetype to "checkhealth". You can customize the
70buffer by handling the |FileType| event. For example if you don't want emojis
71in the health report: >vim
72    autocmd FileType checkhealth :set modifiable | silent! %s/\v( ?[^\x00-\x7F])//g
73<
74
75Sometimes you might need to suppress filetype warnings if you have specified
76them dynamically. For example with the yaml.ansible filetype: >vim
77    autocmd FileType checkhealth :set modifiable | silent! g/Unknown filetype 'yaml\.ansible'/d
78<
79
80--------------------------------------------------------------------------------
81Create a healthcheck                                              *health-dev*
82
83Healthchecks are functions that check the user environment, configuration, or
84any other prerequisites that a plugin cares about. Nvim ships with
85healthchecks in:
86• $VIMRUNTIME/autoload/health/
87• $VIMRUNTIME/lua/vim/lsp/health.lua
88• $VIMRUNTIME/lua/vim/treesitter/health.lua
89• and more...
90
91To add a new healthcheck for your own plugin, simply create a "health.lua"
92module on 'runtimepath' that returns a table with a "check()" function. Then
93|:checkhealth| will automatically find and invoke the function.
94
95For example if your plugin is named "foo", define your healthcheck module at
96one of these locations (on 'runtimepath'):
97• lua/foo/health/init.lua
98• lua/foo/health.lua
99
100If your plugin also provides a submodule named "bar" for which you want a
101separate healthcheck, define the healthcheck at one of these locations:
102• lua/foo/bar/health/init.lua
103• lua/foo/bar/health.lua
104
105All such health modules must return a Lua table containing a `check()`
106function.
107
108Copy this sample code into `lua/foo/health.lua`, replacing "foo" in the path
109with your plugin name: >lua
110    local M = {}
111
112    M.check = function()
113      vim.health.start("foo report")
114      -- make sure setup function parameters are ok
115      if check_setup() then
116        vim.health.ok("Setup is correct")
117      else
118        vim.health.error("Setup is incorrect")
119      end
120      -- do some more checking
121      -- ...
122    end
123
124    return M
125<
126
127
128error({msg}, {...})                                       *vim.health.error()*
129    Reports an error.
130
131    Parameters: ~
132      • {msg}  (`string`)
133      • {...}  (`string|string[]`) Optional advice
134
135info({msg})                                                *vim.health.info()*
136    Reports an informational message.
137
138    Parameters: ~
139      • {msg}  (`string`)
140
141ok({msg})                                                    *vim.health.ok()*
142    Reports a "success" message.
143
144    Parameters: ~
145      • {msg}  (`string`)
146
147start({name})                                             *vim.health.start()*
148    Starts a new report. Most plugins should call this only once, but if you
149    want different sections to appear in your report, call this once per
150    section.
151
152    Parameters: ~
153      • {name}  (`string`)
154
155warn({msg}, {...})                                         *vim.health.warn()*
156    Reports a warning.
157
158    Parameters: ~
159      • {msg}  (`string`)
160      • {...}  (`string|string[]`) Optional advice
161
162
163 vim:tw=78:ts=8:sw=4:sts=4:et:ft=help:norl: