health.txt 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  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. Create a healthcheck *health-dev*
  40. Healthchecks are functions that check the user environment, configuration, or
  41. any other prerequisites that a plugin cares about. Nvim ships with
  42. healthchecks in:
  43. - $VIMRUNTIME/autoload/health/
  44. - $VIMRUNTIME/lua/vim/lsp/health.lua
  45. - $VIMRUNTIME/lua/vim/treesitter/health.lua
  46. - and more...
  47. To add a new healthcheck for your own plugin, simply create a "health.lua"
  48. module on 'runtimepath' that returns a table with a "check()" function. Then
  49. |:checkhealth| will automatically find and invoke the function.
  50. For example if your plugin is named "foo", define your healthcheck module at
  51. one of these locations (on 'runtimepath'):
  52. - lua/foo/health/init.lua
  53. - lua/foo/health.lua
  54. If your plugin also provides a submodule named "bar" for which you want
  55. a separate healthcheck, define the healthcheck at one of these locations:
  56. - lua/foo/bar/health/init.lua
  57. - lua/foo/bar/health.lua
  58. All such health modules must return a Lua table containing a `check()`
  59. function.
  60. Copy this sample code into `lua/foo/health.lua`, replacing "foo" in the path
  61. with your plugin name: >lua
  62. local M = {}
  63. M.check = function()
  64. vim.health.start("foo report")
  65. -- make sure setup function parameters are ok
  66. if check_setup() then
  67. vim.health.ok("Setup is correct")
  68. else
  69. vim.health.error("Setup is incorrect")
  70. end
  71. -- do some more checking
  72. -- ...
  73. end
  74. return M
  75. error({msg}, {...}) *vim.health.error()*
  76. Reports an error.
  77. Parameters: ~
  78. • {msg} (`string`)
  79. • {...} (`string|string[]`) Optional advice
  80. info({msg}) *vim.health.info()*
  81. Reports an informational message.
  82. Parameters: ~
  83. • {msg} (`string`)
  84. ok({msg}) *vim.health.ok()*
  85. Reports a "success" message.
  86. Parameters: ~
  87. • {msg} (`string`)
  88. start({name}) *vim.health.start()*
  89. Starts a new report. Most plugins should call this only once, but if you
  90. want different sections to appear in your report, call this once per
  91. section.
  92. Parameters: ~
  93. • {name} (`string`)
  94. warn({msg}, {...}) *vim.health.warn()*
  95. Reports a warning.
  96. Parameters: ~
  97. • {msg} (`string`)
  98. • {...} (`string|string[]`) Optional advice
  99. vim:tw=78:ts=8:sw=4:sts=4:et:ft=help:norl: