aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJustin M. Keyes <justinkz@gmail.com>2016-09-04 22:57:19 -0400
committerJustin M. Keyes <justinkz@gmail.com>2016-09-05 19:22:01 -0400
commit3c24704ac85e8f8e337d9a4a887ffccf744501b9 (patch)
tree0ca5411bbb12c3438c466e698702b6aa5dca62ea
parent31257b450b6d9cb434a69f158c8c3cdb5924307c (diff)
downloadrneovim-3c24704ac85e8f8e337d9a4a887ffccf744501b9.tar.gz
rneovim-3c24704ac85e8f8e337d9a4a887ffccf744501b9.tar.bz2
rneovim-3c24704ac85e8f8e337d9a4a887ffccf744501b9.zip
health.vim: Show results incrementally.
Also: - improve precision of "No healthcheck found" - fix SUGGESTIONS syntax group definition - fix indentation of SUGGESTIONS
-rw-r--r--runtime/autoload/health.vim49
-rw-r--r--test/functional/plugin/health_spec.lua20
2 files changed, 38 insertions, 31 deletions
diff --git a/runtime/autoload/health.vim b/runtime/autoload/health.vim
index 6ba9405e0a..4ef09c2f2f 100644
--- a/runtime/autoload/health.vim
+++ b/runtime/autoload/health.vim
@@ -11,47 +11,50 @@ function! s:enhance_syntax() abort
syntax keyword healthSuccess SUCCESS
highlight link healthSuccess Function
- syntax keyword healthSuggestion SUGGESTION
+ syntax keyword healthSuggestion SUGGESTIONS
highlight link healthSuggestion String
endfunction
" Runs the specified healthchecks.
" Runs all discovered healthchecks if a:plugin_names is empty.
function! health#check(plugin_names) abort
- let report = ''
-
let healthchecks = empty(a:plugin_names)
\ ? s:discover_health_checks()
\ : s:to_fn_names(a:plugin_names)
if empty(healthchecks)
- let report = "ERROR: No healthchecks found."
+ call setline(1, 'ERROR: No healthchecks found.')
else
+ tabnew
+ setlocal filetype=markdown bufhidden=wipe
+ call s:enhance_syntax()
+
+ redraw|echo 'Running healthchecks...'
for c in healthchecks
- let report .= printf("\n%s\n%s", c, repeat('=',80))
+ let output = ''
+ call append('$', split(printf("\n%s\n%s", c, repeat('=',80)), "\n"))
try
- let report .= execute('call '.c.'()')
- catch /^Vim\%((\a\+)\)\=:E117/
- let report .= execute(
- \ 'call health#report_error(''No healthcheck found for "'
- \ .s:to_plugin_name(c)
- \ .'" plugin.'')')
+ let output = "\n\n".execute('call '.c.'()')
catch
- let report .= execute(
- \ 'call health#report_error(''Failed to run healthcheck for "'
- \ .s:to_plugin_name(c)
- \ .'" plugin. Exception:''."\n".v:exception)')
+ if v:exception =~# '^Vim\%((\a\+)\)\=:E117.*\V'.c
+ let output = execute(
+ \ 'call health#report_error(''No healthcheck found for "'
+ \ .s:to_plugin_name(c)
+ \ .'" plugin.'')')
+ else
+ let output = execute(
+ \ 'call health#report_error(''Failed to run healthcheck for "'
+ \ .s:to_plugin_name(c)
+ \ .'" plugin. Exception:''."\n".v:exception)')
+ endif
endtry
- let report .= "\n"
+ call append('$', split(output, "\n") + [''])
+ redraw
endfor
endif
- tabnew
- setlocal bufhidden=wipe
- set filetype=markdown
- call s:enhance_syntax()
- call setline(1, split(report, "\n"))
setlocal nomodified
+ redraw|echo ''
endfunction
" Starts a new report.
@@ -86,10 +89,10 @@ function! s:format_report_message(status, msg, ...) abort " {{{
" Report each suggestion
if len(suggestions) > 0
- let output .= "\n - SUGGESTIONS:"
+ let output .= "\n - SUGGESTIONS:"
endif
for suggestion in suggestions
- let output .= "\n - " . s:indent_after_line1(suggestion, 10)
+ let output .= "\n - " . s:indent_after_line1(suggestion, 10)
endfor
return output
diff --git a/test/functional/plugin/health_spec.lua b/test/functional/plugin/health_spec.lua
index a9665cd751..4bcaab009f 100644
--- a/test/functional/plugin/health_spec.lua
+++ b/test/functional/plugin/health_spec.lua
@@ -34,9 +34,9 @@ describe('health.vim', function()
## Baz
- WARNING: Zim
- - SUGGESTIONS:
- - suggestion 1
- - suggestion 2]]),
+ - SUGGESTIONS:
+ - suggestion 1
+ - suggestion 2]]),
result)
end)
@@ -45,9 +45,9 @@ describe('health.vim', function()
it("concatenates multiple reports", function()
helpers.execute("CheckHealth success1 success2")
helpers.expect([[
+
health#success1#check
================================================================================
-
## report 1
- SUCCESS: everything is fine
@@ -56,26 +56,30 @@ describe('health.vim', function()
health#success2#check
================================================================================
-
## another 1
- - SUCCESS: ok]])
+ - SUCCESS: ok
+ ]])
end)
it("gracefully handles broken healthcheck", function()
helpers.execute("CheckHealth broken")
helpers.expect([[
+
health#broken#check
================================================================================
- ERROR: Failed to run healthcheck for "broken" plugin. Exception:
- caused an error]])
+ caused an error
+ ]])
end)
it("gracefully handles invalid healthcheck", function()
helpers.execute("CheckHealth non_existent_healthcheck")
helpers.expect([[
+
health#non_existent_healthcheck#check
================================================================================
- - ERROR: No healthcheck found for "non_existent_healthcheck" plugin.]])
+ - ERROR: No healthcheck found for "non_existent_healthcheck" plugin.
+ ]])
end)
end)
end)