New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Neovim Universal Healthcare #4932
Conversation
I think you need to add tests to your TODO, check test/functional/plugin/shada_spec.lua (I point at this file because it contains tests for autoload, syntax, ftplugin and plugin files at once). |
If I understand, a command like |
@Hettomei The command would remain to be |
(I find the mental image of people mistaking I think |
“Checkers” is fine, but such things were always used for troubleshooting, and I would say that moving everything to |
The original reason for using |
Health checking is very common in the "devops" culture, cf. AWS. Command is named "Troubleshooting" is far too long, too many syllables, and difficult to type e.g. in IRC or Reddit. It's also less generic: I was hoping "healthcheck" is what the checkers can be called. |
agree with @justinmk. |
What does everyone think about something like this? This is a little more involved than the original proposal, but I don't think it would be very difficult to use. It would take away a lot of the hassle that I see in the current python health checker, worrying about indentation, line wraps, etc. ""
" Inside of autoload/health/nvim.vim
""
function! health#nvim#check() abort
" Start diagnosing a certain item
call health#diagnose('Python 3 configuration')
call health#symptom_check('General Python Environment')
call health#add_note('Python 3 is in the path', 'success')
" Say a symptom check
call health#symptom_check('Virtual Environment')
" Add notes about the system
call health#add_note('Virtual env not configured.', 'warning')
nvim_pkg_suggestions = [
\ 'Attempt to install the Neovim pacakage with `pip3 install neovim`',
\ 'Consult the Neovim Python FAQ page at <website stuff>'
\ ]
call health#add_note('Neovim package not installed', 'warning', nvim_pkg_suggestions)
endfunction
|
@tjdevries Looks like a nice API. If the names can be made more obvious, it will further help plugin authors.
function! health#nvim#check() abort
call health#report_start('General Python Environment')
call health#report_ok('Python 3 is in the path')
call health#report_start('Virtual Environment')
call health#report_warn('Virtual env not configured.')
nvim_pkg_suggestions = [
\ 'Attempt to install the Neovim pacakage with `pip3 install neovim`',
\ 'Consult the Neovim Python FAQ page at <website stuff>'
\ ]
call health#report_warn('Neovim package not installed', nvim_pkg_suggestions)
endfunction |
@justinmk That seems to be straight forward enough for me. I like it and it seems to be pretty easy to adopt. One thing I'm still considering is the levels. Would |
|
I will think about it some more. |
You're talking about But seriously, I think |
264a5ad
to
d0db84e
Compare
Examples of some output that I've gotten from the new setup:
|
endif | ||
|
||
if resolve(python_bin) !~# '^'.venv_root.'/' | ||
call health#report_warn('Your virtualenv is not set up optimatlly.', [ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
optimally
is spelled wrong here.
Responding to your commit:
I used it as a way to move the messages below what I thought were the prime diagnostic information, such as version numbers and paths. Things that could be a dead give away to a problem. I think how your examples look now is fine, but the |
Sure, color coding would be pretty cool! I think maybe that will be one of the features to add in future work, for nicer formatting. Adding it to the description above. |
https://github.com/Shougo/unite.vim has a way of doing it. @Shougo how does unite check for unite sources implemented by third-party plugins? Can you link to the relevant code?
|
|
||
let l:report .= capture('call ' . l:checker[0] . '()') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be put in a try
block to catch unforeseen exceptions or will capture()
grab the exception output?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See #4697 (comment)
capture('foo')
will capture the exception and display it to the user- can be wrapped in
try
if you need to handle the exception in some way
- can be wrapped in
capture('silent! foo')
will capture the exception output, without showing it to the user
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! Then, it would only make sense to use try
if we want a checker to have an exit code (I can't think of a reason where we would). Otherwise, I think capture('silent! foo')
would be the best way to go.
This. unite.vim just search from |
function! s:download(url) abort | ||
let content = '' | ||
if executable('curl') | ||
let content = system('curl -sL "'.a:url.'"') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think using list is better like this system(['curl', '-sL', a:url])
.
I moved it to the new location of the documentation. Now the tags point to the correct place.
7f75ae3
to
c2538f8
Compare
Health.vim aims to solve this problem in two ways for both core and plugin | ||
maintainers. | ||
|
||
The way this is done is to provide an interface for that users will know to |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove extraneous "for"
Let's not get tied up in the help doc, I'll tweak before merge. Is this functionally complete? |
@justinmk Yes. I think so. The tests that I wrote are working as expected. It seems to find any correctly structured helper that is in the If there are any particular concerns, I will try and address those as well, but it seems functional to me. |
Realized that I messed something up when I was trying to add something... I'll try and add it in a different PR later. Just moved the original call back to the function. Also fixed a systemlist problem
The old way would always enable all the checkers when you would run :CheckHealth, which is bad if people wanted to eliminate some checkers. So I made the interface consistent.
Fixed most of the suggestions that were given.
dcba0a2
to
ff45d75
Compare
@justinmk Are you looking for anything else in particular currently? Should I change this to [RFC]? |
@tjdevries Working on merging this (#5205). I can't find where we discussed the concept of "disabling" a checker. What is the use-case for that? |
@justinmk I guess there were two main use cases:
It's primarily because we add all the checker by default, I figured we should have a way to turn them off if someone desires. |
Addressed this in #5205 by letting
|
Context
This is in response to #4478. It can be thought of as an extension of #4885.
We will be attempting to create an interface that anyone can hook into to display messages about the health of their plugin, script, feature, etc.
Outline
The general outline (subject to change) is as follows:
nvim/runtime/autoload/health.vim
: Sets up the health checker interface. Provides:g:health_checkers
: The health checkers dictionary that contains all the available checkers to run. The value of the key determines whether it should be run or not (v:true
andv:false
)health#check()
: Some report function that can be called. This will run all the enabled doctors, and compile the results into a nice report (which may initially be printing to a nvim buffer). This can be called by:CheckHealth<bang>
health#report_start(name)
: A function to begin a specific area of a report.health#report_info(msg)
: A function to report general info from the checkerhealth#report_warn(msg, [suggestions])
: A function to report warnings, with optional list of suggestions.health#report_error(msg, [suggestions])
: A function to report errors, with optional list of suggestions.nvim/runtime/autoload/health/nvim.vim
: This is where the current health.vim file goes. All standard Neovim gotchas / checks will go in this file. It could be split out later quite easily.$PLUGIN/autoload/health/$PLUGIN.vim
and have a functionhealth#{plugin_name}#check(bang)
that runs the desired health checks.autoload/health/{plug}/python.vim
,autoload/health/{plugin}/environment.vim
, etc. to allow for further customiation.They would also need to register their plugin withhealth#add_checker({checker_name})
$PLUGIN/autoload/health/**.vim
will automatically be added and enabled as ahealth_checker
.Future work
Certain To Do's
test/functional/plugin/shada_spec.lua
Open Questions
health#report_error
is called, or leave that up to the plugin maintainer?