From f0c824485506e36ed407308d360192b7aa9f5fa9 Mon Sep 17 00:00:00 2001 From: Fatih Arslan Date: Mon, 31 Mar 2014 01:00:34 +0300 Subject: [PATCH] syntax: improve highlighting, thanks to @ififi, closes #19 --- syntax/go.vim | 68 +++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 66 insertions(+), 2 deletions(-) diff --git a/syntax/go.vim b/syntax/go.vim index 531370267c..dd48cf9293 100644 --- a/syntax/go.vim +++ b/syntax/go.vim @@ -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 @@ -83,8 +103,6 @@ hi def link goComplexes Type " elsewhere. Order matters here. syn match goDeclaration /\/ -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 @@ -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\)\>/