pi_health.txt 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. *pi_health.txt* Healthcheck framework
  2. Author: TJ DeVries <devries.timothyj@gmail.com>
  3. Type |gO| to see the table of contents.
  4. ==============================================================================
  5. Introduction *health*
  6. health.vim 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: >
  11. :checkhealth
  12. <
  13. Plugin authors are encouraged to write new healthchecks. |health-dev|
  14. ==============================================================================
  15. Commands *health-commands*
  16. *:checkhealth* *:CheckHealth*
  17. :checkhealth Run all healthchecks.
  18. *E5009*
  19. Nvim depends on |$VIMRUNTIME|, 'runtimepath' and 'packpath' to
  20. find the standard "runtime files" for syntax highlighting,
  21. filetype-specific behavior, and standard plugins (including
  22. :checkhealth). If the runtime files cannot be found then
  23. those features will not work.
  24. :checkhealth {plugins}
  25. Run healthcheck(s) for one or more plugins. E.g. to run only
  26. the standard Nvim healthcheck: >
  27. :checkhealth nvim
  28. <
  29. To run the healthchecks for the "foo" and "bar" plugins
  30. (assuming they are on 'runtimepath' and they have implemented
  31. the Lua `require("foo.health").check()` interface): >
  32. :checkhealth foo bar
  33. <
  34. To run healthchecks for Lua submodules, use dot notation or
  35. "*" to refer to all submodules. For example Nvim provides
  36. `vim.lsp` and `vim.treesitter`: >
  37. :checkhealth vim.lsp vim.treesitter
  38. :checkhealth vim*
  39. <
  40. ==============================================================================
  41. Functions *health-functions* *vim.health*
  42. The Lua "health" module can be used to create new healthchecks. To get started
  43. see |health-dev|.
  44. vim.health.report_start({name}) *vim.health.report_start()*
  45. Starts a new report. Most plugins should call this only once, but if
  46. you want different sections to appear in your report, call this once
  47. per section.
  48. vim.health.report_info({msg}) *vim.health.report_info()*
  49. Reports an informational message.
  50. vim.health.report_ok({msg}) *vim.health.report_ok()*
  51. Reports a "success" message.
  52. vim.health.report_warn({msg} [, {advice}]) *vim.health.report_warn()*
  53. Reports a warning. {advice} is an optional list of suggestions to
  54. present to the user.
  55. vim.health.report_error({msg} [, {advice}]) *vim.health.report_error()*
  56. Reports an error. {advice} is an optional list of suggestions to
  57. present to the user.
  58. ==============================================================================
  59. Create a healthcheck *health-dev*
  60. Healthchecks are functions that check the user environment, configuration, or
  61. any other prerequisites that a plugin cares about. Nvim ships with
  62. healthchecks in:
  63. - $VIMRUNTIME/autoload/health/
  64. - $VIMRUNTIME/lua/vim/lsp/health.lua
  65. - $VIMRUNTIME/lua/vim/treesitter/health.lua
  66. - and more...
  67. To add a new healthcheck for your own plugin, simply create a "health.lua"
  68. module on 'runtimepath' that returns a table with a "check()" function. Then
  69. |:checkhealth| will automatically find and invoke the function.
  70. For example if your plugin is named "foo", define your healthcheck module at
  71. one of these locations (on 'runtimepath'):
  72. - lua/foo/health/init.lua
  73. - lua/foo/health.lua
  74. If your plugin also provides a submodule named "bar" for which you want
  75. a separate healthcheck, define the healthcheck at one of these locations:
  76. - lua/foo/bar/health/init.lua
  77. - lua/foo/bar/health.lua
  78. All such health modules must return a Lua table containing a `check()`
  79. function.
  80. Copy this sample code into `lua/foo/health.lua`, replacing "foo" in the path
  81. with your plugin name: >
  82. local M = {}
  83. M.check = function()
  84. vim.health.report_start("my_plugin report")
  85. -- make sure setup function parameters are ok
  86. if check_setup() then
  87. vim.health.report_ok("Setup is correct")
  88. else
  89. vim.health.report_error("Setup is incorrect")
  90. end
  91. -- do some more checking
  92. -- ...
  93. end
  94. return M
  95. vim:et:tw=78:ts=8:ft=help:fdm=marker