health.txt 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. *health.txt* Nvim
  2. NVIM REFERENCE MANUAL
  3. Type |gO| to see the table of contents.
  4. ==============================================================================
  5. Checkhealth *vim.health* *health*
  6. vim.health is a minimal framework to help users troubleshoot configuration and
  7. any other environment conditions that a plugin might care about. Nvim ships
  8. with healthchecks for configuration, performance, python support, ruby
  9. support, clipboard support, and more.
  10. To run all healthchecks, use: >vim
  11. :checkhealth
  12. <
  13. Plugin authors are encouraged to write new healthchecks. |health-dev|
  14. COMMANDS *health-commands*
  15. *:che* *:checkhealth*
  16. :che[ckhealth] Run all healthchecks.
  17. *E5009*
  18. Nvim depends on |$VIMRUNTIME|, 'runtimepath' and 'packpath' to
  19. find the standard "runtime files" for syntax highlighting,
  20. filetype-specific behavior, and standard plugins (including
  21. :checkhealth). If the runtime files cannot be found then
  22. those features will not work.
  23. :che[ckhealth] {plugins}
  24. Run healthcheck(s) for one or more plugins. E.g. to run only
  25. the standard Nvim healthcheck: >vim
  26. :checkhealth vim.health
  27. <
  28. To run the healthchecks for the "foo" and "bar" plugins
  29. (assuming they are on 'runtimepath' and they have implemented
  30. the Lua `require("foo.health").check()` interface): >vim
  31. :checkhealth foo bar
  32. <
  33. To run healthchecks for Lua submodules, use dot notation or
  34. "*" to refer to all submodules. For example Nvim provides
  35. `vim.lsp` and `vim.treesitter`: >vim
  36. :checkhealth vim.lsp vim.treesitter
  37. :checkhealth vim*
  38. <
  39. USAGE *health-usage*
  40. Local mappings in the healthcheck buffer:
  41. q Closes the window.
  42. Global configuration:
  43. *g:health*
  44. g:health Dictionary with the following optional keys:
  45. - `style` (`'float'|nil`) Set to "float" to display :checkhealth in
  46. a floating window instead of the default behavior.
  47. Example: >lua
  48. vim.g.health = { style = 'float' }
  49. --------------------------------------------------------------------------------
  50. Create a healthcheck *health-dev*
  51. Healthchecks are functions that check the user environment, configuration, or
  52. any other prerequisites that a plugin cares about. Nvim ships with
  53. healthchecks in:
  54. - $VIMRUNTIME/autoload/health/
  55. - $VIMRUNTIME/lua/vim/lsp/health.lua
  56. - $VIMRUNTIME/lua/vim/treesitter/health.lua
  57. - and more...
  58. To add a new healthcheck for your own plugin, simply create a "health.lua"
  59. module on 'runtimepath' that returns a table with a "check()" function. Then
  60. |:checkhealth| will automatically find and invoke the function.
  61. For example if your plugin is named "foo", define your healthcheck module at
  62. one of these locations (on 'runtimepath'):
  63. - lua/foo/health/init.lua
  64. - lua/foo/health.lua
  65. If your plugin also provides a submodule named "bar" for which you want
  66. a separate healthcheck, define the healthcheck at one of these locations:
  67. - lua/foo/bar/health/init.lua
  68. - lua/foo/bar/health.lua
  69. All such health modules must return a Lua table containing a `check()`
  70. function.
  71. Copy this sample code into `lua/foo/health.lua`, replacing "foo" in the path
  72. with your plugin name: >lua
  73. local M = {}
  74. M.check = function()
  75. vim.health.start("foo report")
  76. -- make sure setup function parameters are ok
  77. if check_setup() then
  78. vim.health.ok("Setup is correct")
  79. else
  80. vim.health.error("Setup is incorrect")
  81. end
  82. -- do some more checking
  83. -- ...
  84. end
  85. return M
  86. error({msg}, {...}) *vim.health.error()*
  87. Reports an error.
  88. Parameters: ~
  89. • {msg} (`string`)
  90. • {...} (`string|string[]`) Optional advice
  91. info({msg}) *vim.health.info()*
  92. Reports an informational message.
  93. Parameters: ~
  94. • {msg} (`string`)
  95. ok({msg}) *vim.health.ok()*
  96. Reports a "success" message.
  97. Parameters: ~
  98. • {msg} (`string`)
  99. start({name}) *vim.health.start()*
  100. Starts a new report. Most plugins should call this only once, but if you
  101. want different sections to appear in your report, call this once per
  102. section.
  103. Parameters: ~
  104. • {name} (`string`)
  105. warn({msg}, {...}) *vim.health.warn()*
  106. Reports a warning.
  107. Parameters: ~
  108. • {msg} (`string`)
  109. • {...} (`string|string[]`) Optional advice
  110. vim:tw=78:ts=8:sw=4:sts=4:et:ft=help:norl: