Skip to content

Commit 1b32920

Browse files
committed
syntax/go.vim: Add vim-go's highlighting definitions for GoCoverage and other tools
Fixes #13
1 parent 4bd077e commit 1b32920

File tree

1 file changed

+50
-0
lines changed

1 file changed

+50
-0
lines changed

syntax/go.vim

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -755,6 +755,56 @@ hi link goTypeAssertion Special
755755

756756
" }}} Misc
757757

758+
759+
" Vim-Go Compatibility {{{
760+
761+
" NOTE: The code in this section is a collection of verbatim extracts from
762+
" https://github.com/fatih/vim-go/blob/master/syntax/go.vim, included here to
763+
" ensure compatibility with vim-go's code coverage and debugging features. Refer
764+
" to https://github.com/fatih/vim-go/blob/master/LICENSE for details on vim-go's
765+
" source license.
766+
767+
hi def link goSameId Search
768+
hi def link goDiagnosticError SpellBad
769+
hi def link goDiagnosticWarning SpellRare
770+
771+
" TODO(bc): is it appropriate to define text properties in a syntax file?
772+
" The highlight groups need to be defined before the text properties types
773+
" are added, and when users have syntax enabled in their vimrc after
774+
" filetype plugin on, the highlight groups won't be defined when
775+
" ftplugin/go.vim is executed when the first go file is opened.
776+
" See https://github.com/fatih/vim-go/issues/2658.
777+
if has('textprop')
778+
if empty(prop_type_get('goSameId'))
779+
call prop_type_add('goSameId', {'highlight': 'goSameId'})
780+
endif
781+
if empty(prop_type_get('goDiagnosticError'))
782+
call prop_type_add('goDiagnosticError', {'highlight': 'goDiagnosticError'})
783+
endif
784+
if empty(prop_type_get('goDiagnosticWarning'))
785+
call prop_type_add('goDiagnosticWarning', {'highlight': 'goDiagnosticWarning'})
786+
endif
787+
endif
788+
789+
" :GoCoverage commands
790+
hi def link goCoverageNormalText Comment
791+
hi def goCoverageCovered ctermfg=green guifg=#A6E22E
792+
hi def goCoverageUncover ctermfg=red guifg=#F92672
793+
794+
hi def link goDeclsFzfKeyword Keyword
795+
hi def link goDeclsFzfFunction Function
796+
hi def link goDeclsFzfSpecialComment SpecialComment
797+
hi def link goDeclsFzfComment Comment
798+
799+
" :GoDebug commands
800+
if exists('*go#config#HighlightDebug') && go#config#HighlightDebug()
801+
hi def GoDebugBreakpoint term=standout ctermbg=117 ctermfg=0 guibg=#BAD4F5 guifg=Black
802+
hi def GoDebugCurrent term=reverse ctermbg=12 ctermfg=7 guibg=DarkBlue guifg=White
803+
endif
804+
805+
" }}} Vim-Go Compatibility
806+
807+
758808
call s:Cleanup()
759809

760810
if !exists('main_syntax')

0 commit comments

Comments
 (0)