codekingpro/portable-devtools
114k
1" Copyright 2009 The Go Authors. All rights reserved.2" Use of this source code is governed by a BSD-style3" license that can be found in the LICENSE file.4"5" go.vim: Vim syntax file for Go.6" Language: Go7" Maintainer: Billie Cleek <bhcleek@gmail.com>8" Latest Revision: 2024-04-139" 2024-03-17: - fix goPackageComment highlight (by Vim Project)10" License: BSD-style. See LICENSE file in source repository.11" Repository: https://github.com/fatih/vim-go12 13" Quit when a (custom) syntax file was already loaded14if exists("b:current_syntax")15 finish16endif17 18let s:keepcpo = &cpo19set cpo&vim20 21function! s:FoldEnable(...) abort22 if a:0 > 023 return index(s:FoldEnable(), a:1) > -124 endif25 return get(g:, 'go_fold_enable', ['block', 'import', 'varconst', 'package_comment'])26endfunction27 28function! s:HighlightArrayWhitespaceError() abort29 return get(g:, 'go_highlight_array_whitespace_error', 0)30endfunction31 32function! s:HighlightChanWhitespaceError() abort33 return get(g:, 'go_highlight_chan_whitespace_error', 0)34endfunction35 36function! s:HighlightExtraTypes() abort37 return get(g:, 'go_highlight_extra_types', 0)38endfunction39 40function! s:HighlightSpaceTabError() abort41 return get(g:, 'go_highlight_space_tab_error', 0)42endfunction43 44function! s:HighlightTrailingWhitespaceError() abort45 return get(g:, 'go_highlight_trailing_whitespace_error', 0)46endfunction47 48function! s:HighlightOperators() abort49 return get(g:, 'go_highlight_operators', 0)50endfunction51 52function! s:HighlightFunctions() abort53 return get(g:, 'go_highlight_functions', 0)54endfunction55 56function! s:HighlightFunctionParameters() abort57 return get(g:, 'go_highlight_function_parameters', 0)58endfunction59 60function! s:HighlightFunctionCalls() abort61 return get(g:, 'go_highlight_function_calls', 0)62endfunction63 64function! s:HighlightFields() abort65 return get(g:, 'go_highlight_fields', 0)66endfunction67 68function! s:HighlightTypes() abort69 return get(g:, 'go_highlight_types', 0)70endfunction71 72function! s:HighlightBuildConstraints() abort73 return get(g:, 'go_highlight_build_constraints', 0)74endfunction75 76function! s:HighlightStringSpellcheck() abort77 return get(g:, 'go_highlight_string_spellcheck', 1)78endfunction79 80function! s:HighlightFormatStrings() abort81 return get(g:, 'go_highlight_format_strings', 1)82endfunction83 84function! s:HighlightGenerateTags() abort85 return get(g:, 'go_highlight_generate_tags', 0)86endfunction87 88function! s:HighlightVariableAssignments() abort89 return get(g:, 'go_highlight_variable_assignments', 0)90endfunction91 92function! s:HighlightVariableDeclarations() abort93 return get(g:, 'go_highlight_variable_declarations', 0)94endfunction95 96syn case match97 98syn keyword goPackage package99syn keyword goImport import contained100syn keyword goVar var contained101syn keyword goConst const contained102 103hi def link goPackage Statement104hi def link goImport Statement105hi def link goVar Keyword106hi def link goConst Keyword107hi def link goDeclaration Keyword108 109" Keywords within functions110syn keyword goStatement defer go goto return break continue fallthrough111syn keyword goConditional if else switch select112syn keyword goLabel case default113syn keyword goRepeat for range114 115hi def link goStatement Statement116hi def link goConditional Conditional117hi def link goLabel Label118hi def link goRepeat Repeat119 120" Predefined types121syn keyword goType chan map bool string error any comparable122syn keyword goSignedInts int int8 int16 int32 int64 rune123syn keyword goUnsignedInts byte uint uint8 uint16 uint32 uint64 uintptr124syn keyword goFloats float32 float64125syn keyword goComplexes complex64 complex128126 127hi def link goType Type128hi def link goSignedInts Type129hi def link goUnsignedInts Type130hi def link goFloats Type131hi def link goComplexes Type132 133" Predefined functions and values134syn keyword goBuiltins append cap clear close complex copy delete imag len135syn keyword goBuiltins make max min new panic print println real recover136syn keyword goBoolean true false137syn keyword goPredefinedIdentifiers nil iota138 139hi def link goBuiltins Identifier140hi def link goPredefinedIdentifiers Constant141" Boolean links to Constant by default by vim: goBoolean and goPredefinedIdentifiers142" will be highlighted the same, but having the separate groups allows users to143" have separate highlighting for them if they desire.144hi def link goBoolean Boolean145 146" Comments; their contents147syn keyword goTodo contained TODO FIXME XXX BUG148syn cluster goCommentGroup contains=goTodo149 150syn region goComment start="//" end="$" contains=goGenerate,@goCommentGroup,@Spell151if s:FoldEnable('comment')152 syn region goComment start="/\*" end="\*/" contains=@goCommentGroup,@Spell fold153 syn match goComment "\v(^\s*//.*\n)+" contains=goGenerate,@goCommentGroup,@Spell fold154else155 syn region goComment start="/\*" end="\*/" contains=@goCommentGroup,@Spell156endif157 158hi def link goComment Comment159hi def link goTodo Todo160 161if s:HighlightGenerateTags()162 syn match goGenerateVariables contained /\%(\$GOARCH\|\$GOOS\|\$GOFILE\|\$GOLINE\|\$GOPACKAGE\|\$DOLLAR\)\>/163 syn region goGenerate start="^\s*//go:generate" end="$" contains=goGenerateVariables164 hi def link goGenerate PreProc165 hi def link goGenerateVariables Special166endif167 168" Go escapes169syn match goEscapeOctal display contained "\\[0-7]\{3}"170syn match goEscapeC display contained +\\[abfnrtv\\'"]+171syn match goEscapeX display contained "\\x\x\{2}"172syn match goEscapeU display contained "\\u\x\{4}"173syn match goEscapeBigU display contained "\\U\x\{8}"174syn match goEscapeError display contained +\\[^0-7xuUabfnrtv\\'"]+175 176hi def link goEscapeOctal goSpecialString177hi def link goEscapeC goSpecialString178hi def link goEscapeX goSpecialString179hi def link goEscapeU goSpecialString180hi def link goEscapeBigU goSpecialString181hi def link goSpecialString Special182hi def link goEscapeError Error183 184" Strings and their contents185syn cluster goStringGroup contains=goEscapeOctal,goEscapeC,goEscapeX,goEscapeU,goEscapeBigU,goEscapeError186if s:HighlightStringSpellcheck()187 syn region goString start=+"+ skip=+\\\\\|\\"+ end=+"+ contains=@goStringGroup,@Spell188 syn region goRawString start=+`+ end=+`+ contains=@Spell189else190 syn region goString start=+"+ skip=+\\\\\|\\"+ end=+"+ contains=@goStringGroup191 syn region goRawString start=+`+ end=+`+192endif193 194syn match goImportString /^\%(\s\+\|import \)\(\h\w* \)\?\zs"[^"]\+"/ contained containedin=goImport195 196if s:HighlightFormatStrings()197 " [n] notation is valid for specifying explicit argument indexes198 " 1. Match a literal % not preceded by a %.199 " 2. Match any number of -, #, 0, space, or +200 " 3. Match * or [n]* or any number or nothing before a .201 " 4. Match * or [n]* or any number or nothing after a .202 " 5. Match [n] or nothing before a verb203 " 6. Match a formatting verb204 syn match goFormatSpecifier /\205 \%([^%]\%(%%\)*\)\206 \@<=%[-#0 +]*\207 \%(\%(\%(\[\d\+\]\)\=\*\)\|\d\+\)\=\208 \%(\.\%(\%(\%(\[\d\+\]\)\=\*\)\|\d\+\)\=\)\=\209 \%(\[\d\+\]\)\=[vTtbcdoqxXUeEfFgGspw]/ contained containedin=goString,goRawString210 hi def link goFormatSpecifier goSpecialString211endif212 213hi def link goImportString String214hi def link goString String215hi def link goRawString String216 217" Characters; their contents218syn cluster goCharacterGroup contains=goEscapeOctal,goEscapeC,goEscapeX,goEscapeU,goEscapeBigU219syn region goCharacter start=+'+ skip=+\\\\\|\\'+ end=+'+ contains=@goCharacterGroup220 221hi def link goCharacter Character222 223" Regions224syn region goParen start='(' end=')' transparent225if s:FoldEnable('block')226 syn region goBlock start="{" end="}" transparent fold227else228 syn region goBlock start="{" end="}" transparent229endif230 231" import232if s:FoldEnable('import')233 syn region goImport start='import (' end=')' transparent fold contains=goImport,goImportString,goComment234 syn match goImport /^import ()/ transparent fold contains=goImport235else236 syn region goImport start='import (' end=')' transparent contains=goImport,goImportString,goComment237 syn match goImport /^import ()/ transparent contains=goImport238endif239 240" var, const241if s:FoldEnable('varconst')242 syn region goVar start='var (' end='^\s*)$' transparent fold243 \ contains=ALLBUT,goParen,goBlock,goFunction,goTypeName,goReceiverType,goReceiverVar,goParamName,goParamType,goSimpleParams,goPointerOperator244 syn match goVar /var ()/ transparent fold245 \ contains=goVar246 syn region goConst start='const (' end='^\s*)$' transparent fold247 \ contains=ALLBUT,goParen,goBlock,goFunction,goTypeName,goReceiverType,goReceiverVar,goParamName,goParamType,goSimpleParams,goPointerOperator248 syn match goConst /const ()/ transparent fold249 \ contains=goConst250else251 syn region goVar start='var (' end='^\s*)$' transparent252 \ contains=ALLBUT,goParen,goBlock,goFunction,goTypeName,goReceiverType,goReceiverVar,goParamName,goParamType,goSimpleParams,goPointerOperator253 syn match goVar /var ()/ transparent254 \ contains=goVar255 syn region goConst start='const (' end='^\s*)$' transparent256 \ contains=ALLBUT,goParen,goBlock,goFunction,goTypeName,goReceiverType,goReceiverVar,goParamName,goParamType,goSimpleParams,goPointerOperator257 syn match goConst /const ()/ transparent258 \ contains=goConst259endif260 261" Single-line var, const, and import.262syn match goSingleDecl /\%(import\|var\|const\) [^(]\@=/ contains=goImport,goVar,goConst263 264" Integers265syn match goDecimalInt "\<-\=\%(0\|\%(\d\|\d_\d\)\+\)\>"266syn match goHexadecimalInt "\<-\=0[xX]_\?\%(\x\|\x_\x\)\+\>"267syn match goOctalInt "\<-\=0[oO]\?_\?\%(\o\|\o_\o\)\+\>"268syn match goBinaryInt "\<-\=0[bB]_\?\%([01]\|[01]_[01]\)\+\>"269 270hi def link goDecimalInt Integer271hi def link goDecimalError Error272hi def link goHexadecimalInt Integer273hi def link goHexadecimalError Error274hi def link goOctalInt Integer275hi def link goOctalError Error276hi def link goBinaryInt Integer277hi def link goBinaryError Error278hi def link Integer Number279 280" Floating point281"float_lit = decimal_float_lit | hex_float_lit .282"283"decimal_float_lit = decimal_digits "." [ decimal_digits ] [ decimal_exponent ] |284" decimal_digits decimal_exponent |285" "." decimal_digits [ decimal_exponent ] .286"decimal_exponent = ( "e" | "E" ) [ "+" | "-" ] decimal_digits .287"288"hex_float_lit = "0" ( "x" | "X" ) hex_mantissa hex_exponent .289"hex_mantissa = [ "_" ] hex_digits "." [ hex_digits ] |290" [ "_" ] hex_digits |291" "." hex_digits .292"hex_exponent = ( "p" | "P" ) [ "+" | "-" ] decimal_digits .293" decimal floats with a decimal point294syn match goFloat "\<-\=\%(0\|\%(\d\|\d_\d\)\+\)\.\%(\%(\%(\d\|\d_\d\)\+\)\=\%([Ee][-+]\=\%(\d\|\d_\d\)\+\)\=\>\)\="295syn match goFloat "\s\zs-\=\.\%(\d\|\d_\d\)\+\%(\%([Ee][-+]\=\%(\d\|\d_\d\)\+\)\>\)\="296" decimal floats without a decimal point297syn match goFloat "\<-\=\%(0\|\%(\d\|\d_\d\)\+\)[Ee][-+]\=\%(\d\|\d_\d\)\+\>"298" hexadecimal floats with a decimal point299syn match goHexadecimalFloat "\<-\=0[xX]\%(_\x\|\x\)\+\.\%(\%(\x\|\x_\x\)\+\)\=\%([Pp][-+]\=\%(\d\|\d_\d\)\+\)\=\>"300syn match goHexadecimalFloat "\<-\=0[xX]\.\%(\x\|\x_\x\)\+\%([Pp][-+]\=\%(\d\|\d_\d\)\+\)\=\>"301" hexadecimal floats without a decimal point302syn match goHexadecimalFloat "\<-\=0[xX]\%(_\x\|\x\)\+[Pp][-+]\=\%(\d\|\d_\d\)\+\>"303 304hi def link goFloat Float305hi def link goHexadecimalFloat Float306 307" Imaginary literals308syn match goImaginaryDecimal "\<-\=\%(0\|\%(\d\|\d_\d\)\+\)i\>"309syn match goImaginaryHexadecimal "\<-\=0[xX]_\?\%(\x\|\x_\x\)\+i\>"310syn match goImaginaryOctal "\<-\=0[oO]\?_\?\%(\o\|\o_\o\)\+i\>"311syn match goImaginaryBinary "\<-\=0[bB]_\?\%([01]\|[01]_[01]\)\+i\>"312 313" imaginary decimal floats with a decimal point314syn match goImaginaryFloat "\<-\=\%(0\|\%(\d\|\d_\d\)\+\)\.\%(\%(\%(\d\|\d_\d\)\+\)\=\%([Ee][-+]\=\%(\d\|\d_\d\)\+\)\=\)\=i\>"315syn match goImaginaryFloat "\s\zs-\=\.\%(\d\|\d_\d\)\+\%([Ee][-+]\=\%(\d\|\d_\d\)\+\)\=i\>"316" imaginary decimal floats without a decimal point317syn match goImaginaryFloat "\<-\=\%(0\|\%(\d\|\d_\d\)\+\)[Ee][-+]\=\%(\d\|\d_\d\)\+i\>"318" imaginary hexadecimal floats with a decimal point319syn match goImaginaryHexadecimalFloat "\<-\=0[xX]\%(_\x\|\x\)\+\.\%(\%(\x\|\x_\x\)\+\)\=\%([Pp][-+]\=\%(\d\|\d_\d\)\+\)\=i\>"320syn match goImaginaryHexadecimalFloat "\<-\=0[xX]\.\%(\x\|\x_\x\)\+\%([Pp][-+]\=\%(\d\|\d_\d\)\+\)\=i\>"321" imaginary hexadecimal floats without a decimal point322syn match goImaginaryHexadecimalFloat "\<-\=0[xX]\%(_\x\|\x\)\+[Pp][-+]\=\%(\d\|\d_\d\)\+i\>"323 324hi def link goImaginaryDecimal Number325hi def link goImaginaryHexadecimal Number326hi def link goImaginaryOctal Number327hi def link goImaginaryBinary Number328hi def link goImaginaryFloat Float329hi def link goImaginaryHexadecimalFloat Float330 331" Spaces after "[]"332if s:HighlightArrayWhitespaceError()333 syn match goSpaceError display "\%(\[\]\)\@<=\s\+"334endif335 336" Spacing errors around the 'chan' keyword337if s:HighlightChanWhitespaceError()338 " receive-only annotation on chan type339 "340 " \(\<chan\>\)\@<!<- (only pick arrow when it doesn't come after a chan)341 " this prevents picking up 'chan<- chan<-' but not '<- chan'342 syn match goSpaceError display "\%(\%(\<chan\>\)\@<!<-\)\@<=\s\+\%(\<chan\>\)\@="343 344 " send-only annotation on chan type345 "346 " \(<-\)\@<!\<chan\> (only pick chan when it doesn't come after an arrow)347 " this prevents picking up '<-chan <-chan' but not 'chan <-'348 syn match goSpaceError display "\%(\%(<-\)\@<!\<chan\>\)\@<=\s\+\%(<-\)\@="349 350 " value-ignoring receives in a few contexts351 syn match goSpaceError display "\%(\%(^\|[={(,;]\)\s*<-\)\@<=\s\+"352endif353 354" Extra types commonly seen355if s:HighlightExtraTypes()356 syn match goExtraType /\<bytes\.\%(Buffer\)\>/357 syn match goExtraType /\<context\.\%(Context\)\>/358 syn match goExtraType /\<io\.\%(Reader\|ReadSeeker\|ReadWriter\|ReadCloser\|ReadWriteCloser\|Writer\|WriteCloser\|Seeker\)\>/359 syn match goExtraType /\<reflect\.\%(Kind\|Type\|Value\)\>/360 syn match goExtraType /\<unsafe\.Pointer\>/361endif362 363" Space-tab error364if s:HighlightSpaceTabError()365 syn match goSpaceError display " \+\t"me=e-1366endif367 368" Trailing white space error369if s:HighlightTrailingWhitespaceError()370 syn match goSpaceError display excludenl "\s\+$"371endif372 373hi def link goExtraType Type374hi def link goSpaceError Error375 376 377 378" included from: https://github.com/athom/more-colorful.vim/blob/master/after/syntax/go.vim379"380" Comments; their contents381syn keyword goTodo contained NOTE382hi def link goTodo Todo383 384syn match goVarArgs /\.\.\./385 386" Operators;387if s:HighlightOperators()388 " match single-char operators: - + % < > ! & | ^ * =389 " and corresponding two-char operators: -= += %= <= >= != &= |= ^= *= ==390 syn match goOperator /[-+%<>!&|^*=]=\?/391 " match / and /=392 syn match goOperator /\/\%(=\|\ze[^/*]\)/393 " match two-char operators: << >> &^394 " and corresponding three-char operators: <<= >>= &^=395 syn match goOperator /\%(<<\|>>\|&^\)=\?/396 " match remaining two-char operators: := && || <- ++ --397 syn match goOperator /:=\|||\|<-\|++\|--/398 " match ~399 syn match goOperator /\~/400 " match ...401 402 hi def link goPointerOperator goOperator403 hi def link goVarArgs goOperator404endif405hi def link goOperator Operator406 407" -> type constraint opening bracket408" |-> start non-counting group409" || -> any word character410" || | -> at least one, as many as possible411" || | | -> start non-counting group412" || | | | -> match ~413" || | | | | -> at most once414" || | | | | | -> allow a slice type415" || | | | | | | -> any word character416" || | | | | | | | -> start a non-counting group417" || | | | | | | | | -> that matches word characters and |418" || | | | | | | | | | -> close the non-counting group419" || | | | | | | | | | | -> close the non-counting group420" || | | | | | | | | | | |-> any number of matches421" || | | | | | | | | | | || -> start a non-counting group422" || | | | | | | | | | | || | -> a comma and whitespace423" || | | | | | | | | | | || | | -> at most once424" || | | | | | | | | | | || | | | -> close the non-counting group425" || | | | | | | | | | | || | | | | -> at least one of those non-counting groups, as many as possible426" || | | | | | -------- | | | | || | | | | | -> type constraint closing bracket427" || | | | | || | | | | | || | | | | | |428syn match goTypeParams /\[\%(\w\+\s\+\%(\~\?\%(\[]\)\?\w\%(\w\||\)\)*\%(,\s*\)\?\)\+\]/ nextgroup=goSimpleParams,goDeclType contained429 430" Functions;431if s:HighlightFunctions() || s:HighlightFunctionParameters()432 syn match goDeclaration /\<func\>/ nextgroup=goReceiver,goFunction,goSimpleParams skipwhite skipnl433 syn match goReceiverDecl /(\s*\zs\%(\%(\w\+\s\+\)\?\*\?\w\+\%(\[\%(\%(\[\]\)\?\w\+\%(,\s*\)\?\)\+\]\)\?\)\ze\s*)/ contained contains=goReceiverVar,goReceiverType,goPointerOperator434 syn match goReceiverVar /\w\+\ze\s\+\%(\w\|\*\)/ nextgroup=goPointerOperator,goReceiverType skipwhite skipnl contained435 syn match goPointerOperator /\*/ nextgroup=goReceiverType contained skipwhite skipnl436 syn match goFunction /\w\+/ nextgroup=goSimpleParams,goTypeParams contained skipwhite skipnl437 syn match goReceiverType /\w\+\%(\[\%(\%(\[\]\)\?\w\+\%(,\s*\)\?\)\+\]\)\?\ze\s*)/ contained438 if s:HighlightFunctionParameters()439 syn match goSimpleParams /(\%(\w\|\_s\|[*\.\[\],\{\}<>-]\)*)/ contained contains=goParamName,goType nextgroup=goFunctionReturn skipwhite skipnl440 syn match goFunctionReturn /(\%(\w\|\_s\|[*\.\[\],\{\}<>-]\)*)/ contained contains=goParamName,goType skipwhite skipnl441 syn match goParamName /\w\+\%(\s*,\s*\w\+\)*\ze\s\+\%(\w\|\.\|\*\|\[\)/ contained nextgroup=goParamType skipwhite skipnl442 syn match goParamType /\%([^,)]\|\_s\)\+,\?/ contained nextgroup=goParamName skipwhite skipnl443 \ contains=goVarArgs,goType,goSignedInts,goUnsignedInts,goFloats,goComplexes,goDeclType,goBlock444 hi def link goReceiverVar goParamName445 hi def link goParamName Identifier446 endif447 syn match goReceiver /(\s*\%(\w\+\s\+\)\?\*\?\s*\w\+\%(\[\%(\%(\[\]\)\?\w\+\%(,\s*\)\?\)\+\]\)\?\s*)\ze\s*\w/ contained nextgroup=goFunction contains=goReceiverDecl skipwhite skipnl448else449 syn keyword goDeclaration func450endif451hi def link goFunction Function452 453" Function calls;454if s:HighlightFunctionCalls()455 syn match goFunctionCall /\w\+\ze\%(\[\%(\%(\[]\)\?\w\+\(,\s*\)\?\)\+\]\)\?(/ contains=goBuiltins,goDeclaration456endif457hi def link goFunctionCall Type458 459" Fields;460if s:HighlightFields()461 " 1. Match a sequence of word characters coming after a '.'462 " 2. Require the following but dont match it: ( \@= see :h E59)463 " - The symbols: / - + * % OR464 " - The symbols: [] {} <> ) OR465 " - The symbols: \n \r space OR466 " - The symbols: , : .467 " 3. Have the start of highlight (hs) be the start of matched468 " pattern (s) offsetted one to the right (+1) (see :h E401)469 syn match goField /\.\w\+\470 \%(\%([\/\-\+*%]\)\|\471 \%([\[\]{}<\>\)]\)\|\472 \%([\!=\^|&]\)\|\473 \%([\n\r\ ]\)\|\474 \%([,\:.]\)\)\@=/hs=s+1475endif476hi def link goField Identifier477 478" Structs & Interfaces;479if s:HighlightTypes()480 syn match goTypeConstructor /\<\w\+{\@=/481 syn match goTypeDecl /\<type\>/ nextgroup=goTypeName skipwhite skipnl482 syn match goTypeName /\w\+/ contained nextgroup=goDeclType,goTypeParams skipwhite skipnl483 syn match goDeclType /\<\%(interface\|struct\)\>/ skipwhite skipnl484 hi def link goReceiverType Type485else486 syn keyword goDeclType struct interface487 syn keyword goDeclaration type488endif489hi def link goTypeConstructor Type490hi def link goTypeName Type491hi def link goTypeDecl Keyword492hi def link goDeclType Keyword493 494" Variable Assignments495if s:HighlightVariableAssignments()496 syn match goVarAssign /\v[_.[:alnum:]]+(,\s*[_.[:alnum:]]+)*\ze(\s*([-^+|^\/%&]|\*|\<\<|\>\>|\&\^)?\=[^=])/497 hi def link goVarAssign Special498endif499 500" Variable Declarations501if s:HighlightVariableDeclarations()502 syn match goVarDefs /\v\w+(,\s*\w+)*\ze(\s*:\=)/503 hi def link goVarDefs Special504endif505 506" Build Constraints507if s:HighlightBuildConstraints()508 syn match goBuildKeyword display contained "+build\|go:build"509 " Highlight the known values of GOOS, GOARCH, and other +build options.510 syn keyword goBuildDirectives contained511 \ android darwin dragonfly freebsd linux nacl netbsd openbsd plan9512 \ solaris windows 386 amd64 amd64p32 arm armbe arm64 arm64be ppc64513 \ ppc64le mips mipsle mips64 mips64le mips64p32 mips64p32le ppc514 \ s390 s390x sparc sparc64 cgo ignore race515 516 " Other words in the build directive are build tags not listed above, so517 " avoid highlighting them as comments by using a matchgroup just for the518 " start of the comment.519 " The rs=s+2 option lets the \s*+build portion be part of the inner region520 " instead of the matchgroup so it will be highlighted as a goBuildKeyword.521 syn region goBuildComment matchgroup=goBuildCommentStart522 \ start="//\(\s*+build\s\|go:build\)"rs=s+2 end="$"523 \ contains=goBuildKeyword,goBuildDirectives524 hi def link goBuildCommentStart Comment525 hi def link goBuildDirectives Type526 hi def link goBuildKeyword PreProc527endif528 529if s:HighlightBuildConstraints() || s:FoldEnable('package_comment')530 " One or more line comments that are followed immediately by a "package"531 " declaration are treated like package documentation, so these must be532 " matched as comments to avoid looking like working build constraints.533 " The he, me, and re options let the "package" itself be highlighted by534 " the usual rules.535 exe 'syn region goPackageComment start=/\v(\/\/.*\n)+\s*package\s/'536 \ . ' end=/\v\n\s*package\s/he=e-8,me=e-8,re=e-8'537 \ . ' contains=@goCommentGroup,@Spell'538 \ . (s:FoldEnable('package_comment') ? ' fold' : '')539 exe 'syn region goPackageComment start=/\v^\s*\/\*.*\n(.*\n)*\s*\*\/\npackage\s/'540 \ . ' end=/\v\*\/\n\s*package\s/he=e-8,me=e-8,re=e-8'541 \ . ' contains=@goCommentGroup,@Spell'542 \ . (s:FoldEnable('package_comment') ? ' fold' : '')543 hi def link goPackageComment Comment544endif545 546" :GoCoverage commands547hi def link goCoverageNormalText Comment548 549" Search backwards for a global declaration to start processing the syntax.550"syn sync match goSync grouphere NONE /^\(const\|var\|type\|func\)\>/551 552" There's a bug in the implementation of grouphere. For now, use the553" following as a more expensive/less precise workaround.554syn sync minlines=500555 556let b:current_syntax = "go"557 558let &cpo = s:keepcpo559unlet s:keepcpo560 561" vim: sw=2 sts=2 et562 