- If Nvim was just started, don't create a new tab.
- Name the buffer "health://".
- Use "help" syntax instead of "markdown". It fits better, and
eliminates various workarounds.
- Simplfy formatting, avoid visual noise.
- Don't print a "INFO" status, it is noisy.
- Drop the ":" after statuses, they are already UPPERCASE and highlighted.
Problem:
https://github.com/neovim/neovim/pull/18720#issuecomment-1142614996
The vim.health module is detected as a healthcheck, which produces spurious errors:
vim: require("vim.health").check()
========================================================================
- ERROR: Failed to run healthcheck for "vim" plugin. Exception:
function health#check, line 20
Vim(eval):E5108: Error executing lua [string "luaeval()"]:1: attempt to call field 'check' (a nil value)
stack traceback:
[string "luaeval()"]:1: in main chunk
Solution:
Skip vim.health when discovering healthchecks.
Problem: Some plugins have structure `lua/nvim-someplugin/..`
Since `-` is not allowed in vim function names, healthcheck names in
lua and in vim can not have the same name (typically vim will use `_`
instead of `-`).
Solution: Normalize the names before checking for duplicates.
* fix(runtime/health): mitigate issues with duplicate healthchecks
Previously if a healthcheck was found as Lua and Vim it was executed
both times.
This new implementations prefers Lua, therefore if two are found It only
runs the Lua one, this way a plugin can mantain both implementations the
Lua one with the method `check()` and the autoload function `#check()`
(for none HEAD nvim versions).
**Note: This will require plugins to use `check()` as the function name,
since the autoload function that wraps the lua implementation won't be
called**
* docs(health): use spaces and don't overuse backtics
followup to #15259
- Refactor health.vim to discover lua healthcheck in the runtime
directories lua/**/health{/init}.lua
- Support healthchecks for lua submodules e.g :checkhealth vim.lsp and
also support wildcard "*" at the end for all submodules
:checkhealth vim*
- Refactor health.vim to use variable scope instead of output capturing
- Create health.lua module to wrap report functions and future
extensibility.
- Move away from searching just in the runtimepath, use
`nvim_get_runtime_file` due to #15632
Example:
Plugin linter in rtp can declare it's checkhealts in lua module
`lua/linter/health{/init}.lua` that returns a table with a method
"check" that when executed calls the report functions provided by the
builtin lua module require("health").
The plugin also has a submodule `/lua/linter/providers` in which it
defines `/lua/linter/providers/health{/init}.lua`
This plugin healthcheck can now be run by the ex command:
`:checkhealth linter linter.providers`
Also calling all submodules can be done by:
`:checkhealth linter*
And "linter" and "linter.provider" would be discovered when:
`:checkhealth`
`:syntax keyword` is affected by 'iskeyword'. When we aligned
'iskeyword' to that of filetype=help, colon (:) is now included.
Simplest way to deal with this is to include colon (:) in the `:syntax
keyword` directive.
Also:
- change "SUGGESTIONS" mouthful to "ADVICE"
- change "SUCCESS" to "OK"
* health: Handle backslash path separators.
* health: brevity, consistency
* health: Do not set bufhidden=wipe.
In the context of CheckHealth, bufhidden=wipe loses data for no reason.
- By re-enabling code blocks (every line that doesn't begin with a "-" and is
indented by at least 4 spaces), we prevent the Markdown syntax to evaluate "_"
as beginning for italic text.
That's the case for `:CheckHealth deoplete` for instance. It would output:
$ cat /tmp/log_{PID}
Since the deoplete check gets run first, almost all of the following
`:CheckHealth` output would be italic.
- Since we re-enable code blocks, we now have to tell our custom syntax that it
can be part of markdownCodeBlock as well. Otherwise there would be no
highlithing for our keywords ERROR, INFO, etc. after 4 spaces of indent.
- Since we do the above anyway, we make it work for mkdListItemLine as well.
That's a highlight group from `plasticboy/vim-markdown` opposed to the shipped
markdown syntax (which essentially is `tpope/vim-markdown`). Before this patch
there was no highlighting at all in the `:CheckHealth` output.
* health.vim: Include v:throwpoint in error message
* health/provider.vim: Check for ruby executable
* health/provider.vim: Combine subprocess stdout and stderr
* test: Updated CheckHealth test
We can now use help links like in normal help pages. The bars around them will
be concealed as well.
* Health: link string "SUCCESS" to ModeMsg
So far we linked "SUCCESS" to the Function highlight group.
The newly introduced healthHelp group links to Idenfifier as it does for links
in normal help pages.
Now the problem is that the Function group links again to Identifier as well, so
both, "SUCCESS" and help links, would use the same colors.
* Health: don't use Markdown code blocks
Every line indented by more than 4 spaces would lose its highlighting otherwise.
* Health: add helper health#help_to_link()
We can add this later if it is proven necessary, but it should not be
because:
1. User can run a subset of checkers via `:CheckHealth plugin1, ...,`
2. Healthcheck is a very rare operation. Optimizing it is not worth the
code/API complexity.
To healthcheck the "foo" plugin:
:CheckHealth foo
To healthcheck the "foo" and "bar" plugins:
:CheckHealth foo bar
To run all auto-discovered healthchecks:
:CheckHealth
- Use execute() instead of redir
- Fixed logic on suboptimal pyenv/virtualenv checks.
- Move system calls from strings to lists. Fixes#5218
- Add highlighting
- Automatically discover health checkers
- Add tests
Helped-by: Shougo Matsushita <Shougo.Matsu@gmail.com>
Helped-by: Tommy Allen <tommy@esdf.io>
Closes#4932