mirror of
https://github.com/neovim/neovim.git
synced 2026-05-04 21:15:09 +00:00
health.vim: fix highlighting
`:syntax keyword` is affected by 'iskeyword'. When we aligned 'iskeyword' to that of filetype=help, colon (:) is now included. Simplest way to deal with this is to include colon (:) in the `:syntax keyword` directive. Also: - change "SUGGESTIONS" mouthful to "ADVICE" - change "SUCCESS" to "OK"
This commit is contained in:
@@ -1,15 +1,15 @@
|
||||
function! s:enhance_syntax() abort
|
||||
syntax case match
|
||||
|
||||
syntax keyword healthError ERROR
|
||||
syntax keyword healthError ERROR[:]
|
||||
\ containedin=markdownCodeBlock,mkdListItemLine
|
||||
highlight link healthError Error
|
||||
|
||||
syntax keyword healthWarning WARNING
|
||||
syntax keyword healthWarning WARNING[:]
|
||||
\ containedin=markdownCodeBlock,mkdListItemLine
|
||||
highlight link healthWarning WarningMsg
|
||||
|
||||
syntax keyword healthSuccess SUCCESS
|
||||
syntax keyword healthSuccess OK[:]
|
||||
\ containedin=markdownCodeBlock,mkdListItemLine
|
||||
highlight healthSuccess guibg=#5fff00 guifg=#080808 ctermbg=82 ctermfg=232
|
||||
|
||||
@@ -102,13 +102,13 @@ function! s:format_report_message(status, msg, ...) abort " {{{
|
||||
if a:0 > 0
|
||||
let suggestions = type(a:1) == type("") ? [a:1] : a:1
|
||||
if type(suggestions) != type([])
|
||||
echoerr "Expected String or List"
|
||||
throw "Expected String or List"
|
||||
endif
|
||||
endif
|
||||
|
||||
" Report each suggestion
|
||||
if len(suggestions) > 0
|
||||
let output .= "\n - SUGGESTIONS:"
|
||||
let output .= "\n - ADVICE:"
|
||||
endif
|
||||
for suggestion in suggestions
|
||||
let output .= "\n - " . s:indent_after_line1(suggestion, 10)
|
||||
@@ -124,7 +124,7 @@ endfunction " }}}
|
||||
|
||||
" Reports a successful healthcheck.
|
||||
function! health#report_ok(msg) abort " {{{
|
||||
echo s:format_report_message('SUCCESS', a:msg)
|
||||
echo s:format_report_message('OK', a:msg)
|
||||
endfunction " }}}
|
||||
|
||||
" Reports a health warning.
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
local helpers = require('test.functional.helpers')(after_each)
|
||||
local Screen = require('test.functional.ui.screen')
|
||||
local plugin_helpers = require('test.functional.plugin.helpers')
|
||||
|
||||
local command = helpers.command
|
||||
@@ -30,13 +31,13 @@ describe('health.vim', function()
|
||||
|
||||
|
||||
## Check Bar
|
||||
- SUCCESS: Bar status
|
||||
- SUCCESS: Other Bar status
|
||||
- OK: Bar status
|
||||
- OK: Other Bar status
|
||||
- WARNING: Zub
|
||||
|
||||
## Baz
|
||||
- WARNING: Zim
|
||||
- SUGGESTIONS:
|
||||
- ADVICE:
|
||||
- suggestion 1
|
||||
- suggestion 2]]),
|
||||
result)
|
||||
@@ -51,15 +52,15 @@ describe('health.vim', function()
|
||||
health#success1#check
|
||||
========================================================================
|
||||
## report 1
|
||||
- SUCCESS: everything is fine
|
||||
- OK: everything is fine
|
||||
|
||||
## report 2
|
||||
- SUCCESS: nothing to see here
|
||||
- OK: nothing to see here
|
||||
|
||||
health#success2#check
|
||||
========================================================================
|
||||
## another 1
|
||||
- SUCCESS: ok
|
||||
- OK: ok
|
||||
]])
|
||||
end)
|
||||
|
||||
@@ -75,6 +76,36 @@ describe('health.vim', function()
|
||||
]])
|
||||
end)
|
||||
|
||||
it("highlights OK, ERROR", function()
|
||||
local screen = Screen.new(72, 10)
|
||||
screen:attach()
|
||||
screen:set_default_attr_ids({
|
||||
Ok = { foreground = Screen.colors.Grey3, background = 6291200 },
|
||||
Error = { foreground = Screen.colors.Grey100, background = Screen.colors.Red },
|
||||
})
|
||||
screen:set_default_attr_ignore({
|
||||
Heading = { bold=true, foreground=Screen.colors.Magenta },
|
||||
Heading2 = { foreground = Screen.colors.SlateBlue },
|
||||
Bar = { foreground=Screen.colors.Purple },
|
||||
Bullet = { bold=true, foreground=Screen.colors.Brown },
|
||||
})
|
||||
command("CheckHealth foo success1")
|
||||
command("1tabclose")
|
||||
command("set laststatus=0")
|
||||
screen:expect([[
|
||||
^ |
|
||||
health#foo#check |
|
||||
========================================================================|
|
||||
- {Error:ERROR:} No healthcheck found for "foo" plugin. |
|
||||
|
|
||||
health#success1#check |
|
||||
========================================================================|
|
||||
## report 1 |
|
||||
- {Ok:OK:} everything is fine |
|
||||
|
|
||||
]])
|
||||
end)
|
||||
|
||||
it("gracefully handles invalid healthcheck", function()
|
||||
command("CheckHealth non_existent_healthcheck")
|
||||
helpers.expect([[
|
||||
|
||||
Reference in New Issue
Block a user