mirror of
				https://github.com/neovim/neovim.git
				synced 2025-10-26 12:27:24 +00:00 
			
		
		
		
	feat(runtime): new checkhealth filetype (#16708)
This commit is contained in:
		![41898282+github-actions[bot]@users.noreply.github.com](/assets/img/avatar_default.png) github-actions[bot]
					github-actions[bot]
				
			
				
					committed by
					
						 GitHub
						GitHub
					
				
			
			
				
	
			
			
			 GitHub
						GitHub
					
				
			
						parent
						
							ec101b9fd9
						
					
				
				
					commit
					09306f07c4
				
			| @@ -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 the specified healthchecks. | ||||||
| " Runs all discovered healthchecks if a:plugin_names is empty. | " Runs all discovered healthchecks if a:plugin_names is empty. | ||||||
| function! health#check(plugin_names) abort | function! health#check(plugin_names) abort | ||||||
| @@ -29,13 +5,9 @@ function! health#check(plugin_names) abort | |||||||
|         \ ? s:discover_healthchecks() |         \ ? s:discover_healthchecks() | ||||||
|         \ : s:get_healthcheck(a:plugin_names) |         \ : s:get_healthcheck(a:plugin_names) | ||||||
|  |  | ||||||
|   tabnew |   " create scratch-buffer | ||||||
|   setlocal wrap breakindent linebreak |   execute 'tab sbuffer' nvim_create_buf(v:true, v:true) | ||||||
|   setlocal filetype=markdown |   setfiletype checkhealth | ||||||
|   setlocal conceallevel=2 concealcursor=nc |  | ||||||
|   setlocal keywordprg=:help |  | ||||||
|   let &l:iskeyword='!-~,^*,^|,^",192-255' |  | ||||||
|   call s:enhance_syntax() |  | ||||||
|  |  | ||||||
|   if empty(healthchecks) |   if empty(healthchecks) | ||||||
|     call setline(1, 'ERROR: No healthchecks found.') |     call setline(1, 'ERROR: No healthchecks found.') | ||||||
| @@ -70,8 +42,6 @@ function! health#check(plugin_names) abort | |||||||
|  |  | ||||||
|   " needed for plasticboy/vim-markdown, because it uses fdm=expr |   " needed for plasticboy/vim-markdown, because it uses fdm=expr | ||||||
|   normal! zR |   normal! zR | ||||||
|   setlocal nomodified |  | ||||||
|   setlocal bufhidden=hide |  | ||||||
|   redraw|echo '' |   redraw|echo '' | ||||||
| endfunction | endfunction | ||||||
|  |  | ||||||
|   | |||||||
							
								
								
									
										20
									
								
								runtime/ftplugin/checkhealth.vim
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										20
									
								
								runtime/ftplugin/checkhealth.vim
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,20 @@ | |||||||
|  | " Vim filetype plugin | ||||||
|  | " Language:     Neovim checkhealth buffer | ||||||
|  | " Last Change:  2021 Dec 15 | ||||||
|  |  | ||||||
|  | if exists("b:did_ftplugin") | ||||||
|  |   finish | ||||||
|  | endif | ||||||
|  |  | ||||||
|  | runtime! ftplugin/markdown.vim ftplugin/markdown_*.vim ftplugin/markdown/*.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<" | ||||||
|  | else | ||||||
|  |   let b:undo_ftplugin = "setl wrap< bri< lbr< cole< cocu< kp< isk<" | ||||||
|  | endif | ||||||
							
								
								
									
										28
									
								
								runtime/syntax/checkhealth.vim
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										28
									
								
								runtime/syntax/checkhealth.vim
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,28 @@ | |||||||
|  | " Vim syntax file | ||||||
|  | " Language:     Neovim checkhealth buffer | ||||||
|  | " Last Change:  2021 Dec 15 | ||||||
|  |  | ||||||
|  | if exists("b:current_syntax") | ||||||
|  |   finish | ||||||
|  | endif | ||||||
|  |  | ||||||
|  | runtime! syntax/markdown.vim | ||||||
|  | unlet! b:current_syntax | ||||||
|  |  | ||||||
|  | syn case match | ||||||
|  |  | ||||||
|  | " We do not care about markdown syntax errors | ||||||
|  | syn clear markdownError | ||||||
|  |  | ||||||
|  | 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 | ||||||
|  |  | ||||||
|  | hi def link healthError Error | ||||||
|  | hi def link healthWarning WarningMsg | ||||||
|  | hi def healthSuccess guibg=#5fff00 guifg=#080808 ctermbg=82 ctermfg=232 | ||||||
|  | hi def link healthHelp Identifier | ||||||
|  |  | ||||||
|  | let b:current_syntax = "checkhealth" | ||||||
| @@ -156,7 +156,7 @@ describe('health.vim', function() | |||||||
|         test_plug.submodule_failed: require("test_plug.submodule_failed.health").check() |         test_plug.submodule_failed: require("test_plug.submodule_failed.health").check() | ||||||
|         ======================================================================== |         ======================================================================== | ||||||
|           - ERROR: Failed to run healthcheck for "test_plug.submodule_failed" plugin. Exception: |           - ERROR: Failed to run healthcheck for "test_plug.submodule_failed" plugin. Exception: | ||||||
|             function health#check, line 24]]) |             function health#check, line 20]]) | ||||||
|       eq(expected, received) |       eq(expected, received) | ||||||
|     end) |     end) | ||||||
|  |  | ||||||
| @@ -167,7 +167,7 @@ describe('health.vim', function() | |||||||
|         broken: health#broken#check |         broken: health#broken#check | ||||||
|         ======================================================================== |         ======================================================================== | ||||||
|           - ERROR: Failed to run healthcheck for "broken" plugin. Exception: |           - ERROR: Failed to run healthcheck for "broken" plugin. Exception: | ||||||
|             function health#check[24]..health#broken#check, line 1 |             function health#check[20]..health#broken#check, line 1 | ||||||
|             caused an error |             caused an error | ||||||
|         ]]) |         ]]) | ||||||
|     end) |     end) | ||||||
| @@ -186,7 +186,7 @@ describe('health.vim', function() | |||||||
|         test_plug.submodule_failed: require("test_plug.submodule_failed.health").check() |         test_plug.submodule_failed: require("test_plug.submodule_failed.health").check() | ||||||
|         ======================================================================== |         ======================================================================== | ||||||
|           - ERROR: Failed to run healthcheck for "test_plug.submodule_failed" plugin. Exception: |           - ERROR: Failed to run healthcheck for "test_plug.submodule_failed" plugin. Exception: | ||||||
|             function health#check, line 24]]) |             function health#check, line 20]]) | ||||||
|       eq(expected, received) |       eq(expected, received) | ||||||
|     end) |     end) | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user