diff options
author | Justin M. Keyes <justinkz@gmail.com> | 2022-11-11 21:33:31 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-11-11 18:33:31 -0800 |
commit | 4d2373f5f6570fcc851b818198f45fbda391fd6a (patch) | |
tree | 07dfe76d60f55eaa7dfe18c4bdbd61fcee709f17 /runtime | |
parent | 2425fe2dc5e5985779912319433ddf914a20dd6a (diff) | |
download | rneovim-4d2373f5f6570fcc851b818198f45fbda391fd6a.tar.gz rneovim-4d2373f5f6570fcc851b818198f45fbda391fd6a.tar.bz2 rneovim-4d2373f5f6570fcc851b818198f45fbda391fd6a.zip |
feat(checkhealth): use "help" syntax, avoid tabpage #20879
- 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.
Diffstat (limited to 'runtime')
-rw-r--r-- | runtime/autoload/health.vim | 26 | ||||
-rw-r--r-- | runtime/ftplugin/checkhealth.vim | 12 | ||||
-rw-r--r-- | runtime/lua/nvim/health.lua | 8 | ||||
-rw-r--r-- | runtime/syntax/checkhealth.vim | 21 |
4 files changed, 31 insertions, 36 deletions
diff --git a/runtime/autoload/health.vim b/runtime/autoload/health.vim index a693868381..5fd4627b11 100644 --- a/runtime/autoload/health.vim +++ b/runtime/autoload/health.vim @@ -5,8 +5,13 @@ function! health#check(plugin_names) abort \ ? s:discover_healthchecks() \ : s:get_healthcheck(a:plugin_names) - " create scratch-buffer - execute 'tab sbuffer' nvim_create_buf(v:true, v:true) + " Create buffer and open in a tab, unless this is the default buffer when Nvim starts. + let emptybuf = (bufnr('$') == 1 && empty(getline(1)) && 1 == line('$')) + execute (emptybuf ? 'buffer' : 'tab sbuffer') nvim_create_buf(v:true, v:true) + if bufexists('health://') + bwipe health:// + endif + file health:// setfiletype checkhealth if empty(healthchecks) @@ -38,7 +43,7 @@ function! health#check(plugin_names) abort \ name, v:throwpoint, v:exception)) endif endtry - let header = [name. ': ' . func, repeat('=', 72)] + let header = [repeat('=', 78), name .. ': ' .. func, ''] " remove empty line after header from report_start let s:output = s:output[0] == '' ? s:output[1:] : s:output let s:output = header + s:output + [''] @@ -47,8 +52,7 @@ function! health#check(plugin_names) abort endfor endif - " needed for plasticboy/vim-markdown, because it uses fdm=expr - normal! zR + " Clear the 'Running healthchecks...' message. redraw|echo '' endfunction @@ -58,7 +62,7 @@ endfunction " Starts a new report. function! health#report_start(name) abort - call s:collect_output("\n## " . a:name) + call s:collect_output(printf("\n%s ~", a:name)) endfunction " Indents lines *except* line 1 of a string if it contains newlines. @@ -81,7 +85,7 @@ endfunction " Format a message for a specific report item. " a:1: Optional advice (string or list) function! s:format_report_message(status, msg, ...) abort " {{{ - let output = ' - ' . a:status . ': ' . s:indent_after_line1(a:msg, 4) + let output = '- ' .. a:status .. (empty(a:status) ? '' : ' ') .. s:indent_after_line1(a:msg, 2) " Optional parameters if a:0 > 0 @@ -92,9 +96,9 @@ function! s:format_report_message(status, msg, ...) abort " {{{ " Report each suggestion if !empty(advice) - let output .= "\n - ADVICE:" + let output .= "\n - ADVICE:" for suggestion in advice - let output .= "\n - " . s:indent_after_line1(suggestion, 10) + let output .= "\n - " . s:indent_after_line1(suggestion, 6) endfor endif endif @@ -102,9 +106,9 @@ function! s:format_report_message(status, msg, ...) abort " {{{ return s:help_to_link(output) endfunction " }}} -" Use {msg} to report information in the current section +" Reports a message as a listitem in the current section. function! health#report_info(msg) abort " {{{ - call s:collect_output(s:format_report_message('INFO', a:msg)) + call s:collect_output(s:format_report_message('', a:msg)) endfunction " }}} " Reports a successful healthcheck. diff --git a/runtime/ftplugin/checkhealth.vim b/runtime/ftplugin/checkhealth.vim index 3d8e9ace1a..62a1970b4a 100644 --- a/runtime/ftplugin/checkhealth.vim +++ b/runtime/ftplugin/checkhealth.vim @@ -1,20 +1,18 @@ " Vim filetype plugin -" Language: Neovim checkhealth buffer -" Last Change: 2021 Dec 15 +" Language: Nvim :checkhealth buffer +" Last Change: 2022 Nov 10 if exists("b:did_ftplugin") finish endif -runtime! ftplugin/markdown.vim ftplugin/markdown_*.vim ftplugin/markdown/*.vim +runtime! ftplugin/help.vim setlocal wrap breakindent linebreak -setlocal conceallevel=2 concealcursor=nc -setlocal keywordprg=:help let &l:iskeyword='!-~,^*,^|,^",192-255' if exists("b:undo_ftplugin") - let b:undo_ftplugin .= "|setl wrap< bri< lbr< cole< cocu< kp< isk<" + let b:undo_ftplugin .= "|setl wrap< bri< lbr< kp< isk<" else - let b:undo_ftplugin = "setl wrap< bri< lbr< cole< cocu< kp< isk<" + let b:undo_ftplugin = "setl wrap< bri< lbr< kp< isk<" endif diff --git a/runtime/lua/nvim/health.lua b/runtime/lua/nvim/health.lua index 413eae0bf9..0dd32ddc0b 100644 --- a/runtime/lua/nvim/health.lua +++ b/runtime/lua/nvim/health.lua @@ -359,14 +359,12 @@ local function check_terminal() \ ..'\%(conemu\|vtpcon\|win32con\)'))) call health#report_error('command failed: '.cmd."\n".out) else - call health#report_info('key_backspace (kbs) terminfo entry: ' - \ .(empty(kbs_entry) ? '? (not found)' : kbs_entry)) - call health#report_info('key_dc (kdch1) terminfo entry: ' - \ .(empty(kbs_entry) ? '? (not found)' : kdch1_entry)) + call health#report_info(printf('key_backspace (kbs) terminfo entry: `%s`', (empty(kbs_entry) ? '? (not found)' : kbs_entry))) + call health#report_info(printf('key_dc (kdch1) terminfo entry: `%s`', (empty(kbs_entry) ? '? (not found)' : kdch1_entry))) endif for env_var in ['XTERM_VERSION', 'VTE_VERSION', 'TERM_PROGRAM', 'COLORTERM', 'SSH_TTY'] if exists('$'.env_var) - call health#report_info(printf("$%s='%s'", env_var, eval('$'.env_var))) + call health#report_info(printf('$%s="%s"', env_var, eval('$'.env_var))) endif endfor endf diff --git a/runtime/syntax/checkhealth.vim b/runtime/syntax/checkhealth.vim index 37f1822740..4b0ce75a54 100644 --- a/runtime/syntax/checkhealth.vim +++ b/runtime/syntax/checkhealth.vim @@ -1,26 +1,21 @@ " Vim syntax file -" Language: Neovim checkhealth buffer -" Last Change: 2021 Dec 15 +" Language: Nvim :checkhealth buffer +" Last Change: 2022 Nov 10 if exists("b:current_syntax") finish endif -runtime! syntax/markdown.vim +runtime! syntax/help.vim unlet! b:current_syntax syn case match -" We do not care about markdown syntax errors -if hlexists('markdownError') - syn clear markdownError -endif - -syn keyword healthError ERROR[:] containedin=markdownCodeBlock,mkdListItemLine -syn keyword healthWarning WARNING[:] containedin=markdownCodeBlock,mkdListItemLine -syn keyword healthSuccess OK[:] containedin=markdownCodeBlock,mkdListItemLine -syn match healthHelp "|.\{-}|" containedin=markdownCodeBlock,mkdListItemLine contains=healthBar -syn match healthBar "|" contained conceal +syn keyword healthError ERROR[:] +syn keyword healthWarning WARNING[:] +syn keyword healthSuccess OK[:] +syn match helpSectionDelim "^======*\n.*$" +syn match healthHeadingChar "=" conceal cchar=─ contained containedin=helpSectionDelim hi def link healthError Error hi def link healthWarning WarningMsg |