aboutsummaryrefslogtreecommitdiff
path: root/runtime/autoload/health.vim
diff options
context:
space:
mode:
Diffstat (limited to 'runtime/autoload/health.vim')
-rw-r--r--runtime/autoload/health.vim47
1 files changed, 12 insertions, 35 deletions
diff --git a/runtime/autoload/health.vim b/runtime/autoload/health.vim
index 73c1459f86..1292e4344e 100644
--- a/runtime/autoload/health.vim
+++ b/runtime/autoload/health.vim
@@ -1,27 +1,3 @@
-function! s:enhance_syntax() abort
- syntax case match
-
- syntax keyword healthError ERROR[:]
- \ containedin=markdownCodeBlock,mkdListItemLine
- highlight default link healthError Error
-
- syntax keyword healthWarning WARNING[:]
- \ containedin=markdownCodeBlock,mkdListItemLine
- highlight default link healthWarning WarningMsg
-
- syntax keyword healthSuccess OK[:]
- \ containedin=markdownCodeBlock,mkdListItemLine
- highlight default healthSuccess guibg=#5fff00 guifg=#080808 ctermbg=82 ctermfg=232
-
- syntax match healthHelp "|.\{-}|" contains=healthBar
- \ containedin=markdownCodeBlock,mkdListItemLine
- syntax match healthBar "|" contained conceal
- highlight default link healthHelp Identifier
-
- " We do not care about markdown syntax errors in :checkhealth output.
- highlight! link markdownError Normal
-endfunction
-
" Runs the specified healthchecks.
" Runs all discovered healthchecks if a:plugin_names is empty.
function! health#check(plugin_names) abort
@@ -29,13 +5,9 @@ function! health#check(plugin_names) abort
\ ? s:discover_healthchecks()
\ : s:get_healthcheck(a:plugin_names)
- tabnew
- setlocal wrap breakindent linebreak
- setlocal filetype=markdown
- setlocal conceallevel=2 concealcursor=nc
- setlocal keywordprg=:help
- let &l:iskeyword='!-~,^*,^|,^",192-255'
- call s:enhance_syntax()
+ " create scratch-buffer
+ execute 'tab sbuffer' nvim_create_buf(v:true, v:true)
+ setfiletype checkhealth
if empty(healthchecks)
call setline(1, 'ERROR: No healthchecks found.')
@@ -49,10 +21,17 @@ function! health#check(plugin_names) abort
throw 'healthcheck_not_found'
endif
eval type == 'v' ? call(func, []) : luaeval(func)
+ " in the event the healthcheck doesn't return anything
+ " (the plugin author should avoid this possibility)
+ if len(s:output) == 0
+ throw 'healthcheck_no_return_value'
+ endif
catch
let s:output = [] " Clear the output
if v:exception =~# 'healthcheck_not_found'
call health#report_error('No healthcheck found for "'.name.'" plugin.')
+ elseif v:exception =~# 'healthcheck_no_return_value'
+ call health#report_error('The healthcheck report for "'.name.'" plugin is empty.')
else
call health#report_error(printf(
\ "Failed to run healthcheck for \"%s\" plugin. Exception:\n%s\n%s",
@@ -70,8 +49,6 @@ function! health#check(plugin_names) abort
" needed for plasticboy/vim-markdown, because it uses fdm=expr
normal! zR
- setlocal nomodified
- setlocal bufhidden=hide
redraw|echo ''
endfunction
@@ -157,7 +134,7 @@ endfunction " }}}
" From a path return a list [{name}, {func}, {type}] representing a healthcheck
function! s:filepath_to_healthcheck(path) abort
- if a:path =~# 'vim$'
+ if a:path =~# 'vim$'
let name = matchstr(a:path, '\zs[^\/]*\ze\.vim$')
let func = 'health#'.name.'#check'
let type = 'v'
@@ -211,7 +188,7 @@ function! s:get_healthcheck_list(plugin_names) abort
\ + nvim_get_runtime_file('lua/**/'.p.'/health/init.lua', v:true)
\ + nvim_get_runtime_file('lua/**/'.p.'/health.lua', v:true)
if len(paths) == 0
- let healthchecks += [[p, '', '']] " healthchek not found
+ let healthchecks += [[p, '', '']] " healthcheck not found
else
let healthchecks += map(uniq(sort(paths)),
\'<SID>filepath_to_healthcheck(v:val)')