aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarco Hinz <mh.codebro@gmail.com>2016-11-04 11:03:05 +0100
committerJustin M. Keyes <justinkz@gmail.com>2016-11-04 11:03:05 +0100
commit32d9c19e294f38a6adae6e055fc606fc3fd33f2f (patch)
treedd113fda6697b40469ea9c56b816de71383b1dc3
parent01f1028496bd1a402ad1b11c311291ec96335b70 (diff)
downloadrneovim-32d9c19e294f38a6adae6e055fc606fc3fd33f2f.tar.gz
rneovim-32d9c19e294f38a6adae6e055fc606fc3fd33f2f.tar.bz2
rneovim-32d9c19e294f38a6adae6e055fc606fc3fd33f2f.zip
Health: introduce help links (#5557)
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()
-rw-r--r--runtime/autoload/health.vim18
-rw-r--r--runtime/autoload/health/provider.vim2
2 files changed, 17 insertions, 3 deletions
diff --git a/runtime/autoload/health.vim b/runtime/autoload/health.vim
index cbfd7c76a1..346b6e386e 100644
--- a/runtime/autoload/health.vim
+++ b/runtime/autoload/health.vim
@@ -9,13 +9,20 @@ function! s:enhance_syntax() abort
highlight link healthInfo ModeMsg
syntax keyword healthSuccess SUCCESS
- highlight link healthSuccess Function
+ highlight link healthSuccess ModeMsg
syntax keyword healthSuggestion SUGGESTIONS
highlight link healthSuggestion String
+ syntax match healthHelp "|.\{-}|" contains=healthBar
+ syntax match healthBar "|" contained conceal
+ highlight link healthHelp Identifier
+
" We do not care about markdown syntax errors in :CheckHealth output.
highlight! link markdownError Normal
+
+ " We don't need code blocks.
+ syntax clear markdownCodeBlock
endfunction
" Runs the specified healthchecks.
@@ -28,6 +35,8 @@ function! health#check(plugin_names) abort
tabnew
setlocal wrap breakindent
setlocal filetype=markdown bufhidden=wipe
+ setlocal conceallevel=2 concealcursor=nc
+ setlocal keywordprg=:help
call s:enhance_syntax()
if empty(healthchecks)
@@ -78,6 +87,11 @@ function! s:indent_after_line1(s, columns) abort
return join(lines, "\n")
endfunction
+" Changes ':help clipboard' to '|clipoard|'. Also removes surrounding quotes.
+function! s:help_to_link(s) abort
+ return substitute(a:s, '\v[''"]?:h%[elp] ([^''"]+)[''"]?', '|\1|', 'g')
+endfunction
+
" Format a message for a specific report item
function! s:format_report_message(status, msg, ...) abort " {{{
let output = ' - ' . a:status . ': ' . s:indent_after_line1(a:msg, 4)
@@ -99,7 +113,7 @@ function! s:format_report_message(status, msg, ...) abort " {{{
let output .= "\n - " . s:indent_after_line1(suggestion, 10)
endfor
- return output
+ return s:help_to_link(output)
endfunction " }}}
" Use {msg} to report information in the current section
diff --git a/runtime/autoload/health/provider.vim b/runtime/autoload/health/provider.vim
index 3c40e48b2e..b3af3d50bc 100644
--- a/runtime/autoload/health/provider.vim
+++ b/runtime/autoload/health/provider.vim
@@ -53,7 +53,7 @@ function! s:check_clipboard() abort
if empty(clipboard_tool)
call health#report_warn(
\ "No clipboard tool found. Using the system clipboard won't work.",
- \ ['See ":help clipboard"'])
+ \ ['See |clipboard|.'])
else
call health#report_ok('Clipboard tool found: '. clipboard_tool)
endif