Skip to content

Commit

Permalink
syntax: improve highlighting, thanks to @ififi, closes #19
Browse files Browse the repository at this point in the history
  • Loading branch information
fatih committed Mar 30, 2014
1 parent 2a18ecc commit f0c8244
Showing 1 changed file with 66 additions and 2 deletions.
68 changes: 66 additions & 2 deletions syntax/go.vim
Original file line number Diff line number Diff line change
Expand Up @@ -32,19 +32,39 @@ endif
if !exists("go_highlight_array_whitespace_error")
let go_highlight_array_whitespace_error = 1
endif

if !exists("go_highlight_chan_whitespace_error")
let go_highlight_chan_whitespace_error = 1
endif

if !exists("go_highlight_extra_types")
let go_highlight_extra_types = 1
endif

if !exists("go_highlight_space_tab_error")
let go_highlight_space_tab_error = 1
endif

if !exists("go_highlight_trailing_whitespace_error")
let go_highlight_trailing_whitespace_error = 1
endif

if !exists("go_highlight_operators")
let go_highlight_operators = 1
endif

if !exists("go_highlight_functions")
let go_highlight_functions = 1
endif

if !exists("go_highlight_methods")
let go_highlight_methods = 1
endif

if !exists("go_highlight_structs")
let go_highlight_structs = 1
endif

syn case match

syn keyword goDirective package import
Expand Down Expand Up @@ -83,8 +103,6 @@ hi def link goComplexes Type
" elsewhere. Order matters here.
syn match goDeclaration /\<func\>/

syn match goFunction "\%(\%(func\s\)\s*\)\@<=\h\%(\w\|\.\)*"
hi def link goFunction Function

" Predefined functions and values
syn keyword goBuiltins append cap close complex copy delete imag len
Expand Down Expand Up @@ -199,6 +217,52 @@ endif
hi def link goExtraType Type
hi def link goSpaceError Error



" included from: https://github.com/athom/more-colorful.vim/blob/master/after/syntax/go.vim
"
" Comments; their contents
syn keyword goTodo contained NOTE
hi def link goTodo Todo


" Operators;
if go_highlight_operators != 0
syn match goOperator /:=/
syn match goOperator />=/
syn match goOperator /<=/
syn match goOperator /==/
syn match goOperator /\s>\s/
syn match goOperator /\s<\s/
syn match goOperator /\s+\s/
syn match goOperator /\s-\s/
syn match goOperator /\s\*\s/
syn match goOperator /\s\/\s/
syn match goOperator /\s%\s/
endif
hi def link goOperator Operator

" Functions;
if go_highlight_functions != 0
syn match goFunction /\(func\s\+\)\@<=\w\+\((\)\@=/
syn match goFunction /\()\s\+\)\@<=\w\+\((\)\@=/
endif
hi def link goFunction Function

" Methods;
if go_highlight_methods != 0
syn match goMethod /\(\.\)\@<=\w\+\((\)\@=/
endif
hi def link goMethod Type

" Structs;
if go_highlight_structs != 0
syn match goStruct /\(.\)\@<=\w\+\({\)\@=/
syn match goStructDef /\(type\s\+\)\@<=\w\+\(\s\+struct\s\+{\)\@=/
endif
hi def link goStruct Function
hi def link goStructDef Function

" Search backwards for a global declaration to start processing the syntax.
"syn sync match goSync grouphere NONE /^\(const\|var\|type\|func\)\>/

Expand Down

0 comments on commit f0c8244

Please sign in to comment.