annotate runtime/syntax/go.vim @ 33634:7c43330262d4 v9.0.2058

patch 9.0.2058: tests: avoid error when no swap files exist Commit: https://github.com/vim/vim/commit/a36acb7ac444a789440dc30e0f04d5427069face Author: zeertzjq <zeertzjq@outlook.com> Date: Sat Oct 21 11:50:26 2023 +0200 patch 9.0.2058: tests: avoid error when no swap files exist Problem: tests: avoid error when no swap files exist Solution: use unlet! so that no error message is reported in case the variable does not exists When s:GetSwapFileList() does not find any swapfiles, it will return an empty list []. This means, that the variable 'name' will not be declared, cause the following unlet command to fail and causing a 1 sec delay on running the tests. So let's instead use the :unlet! command which simply skips reporting an error when the variable given as parameter does not exists. closes: #13396 Signed-off-by: Christian Brabandt <cb@256bit.org> Co-authored-by: zeertzjq <zeertzjq@outlook.com>
author Christian Brabandt <cb@256bit.org>
date Sat, 21 Oct 2023 12:00:04 +0200
parents a5bd10de6c37
children 176821d2ea8a
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
25161
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
1 " Copyright 2009 The Go Authors. All rights reserved.
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
2 " Use of this source code is governed by a BSD-style
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
3 " license that can be found in the LICENSE file.
6153
1e8ebf870720 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
4 "
25161
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
5 " go.vim: Vim syntax file for Go.
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
6 " Language: Go
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
7 " Maintainer: Billie Cleek <bhcleek@gmail.com>
32957
a5bd10de6c37 runtime(go): Update Go syntax file with 1.21 builtins (#12876)
Christian Brabandt <cb@256bit.org>
parents: 32004
diff changeset
8 " Latest Revision: 2023-08-21
25161
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
9 " License: BSD-style. See LICENSE file in source repository.
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
10 " Repository: https://github.com/fatih/vim-go
6153
1e8ebf870720 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
11
1e8ebf870720 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
12 " Quit when a (custom) syntax file was already loaded
25161
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
13 if exists("b:current_syntax")
6153
1e8ebf870720 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
14 finish
1e8ebf870720 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
15 endif
1e8ebf870720 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
16
25161
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
17 let s:keepcpo = &cpo
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
18 set cpo&vim
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
19
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
20 function! s:FoldEnable(...) abort
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
21 if a:0 > 0
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
22 return index(s:FoldEnable(), a:1) > -1
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
23 endif
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
24 return get(g:, 'go_fold_enable', ['block', 'import', 'varconst', 'package_comment'])
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
25 endfunction
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
26
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
27 function! s:HighlightArrayWhitespaceError() abort
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
28 return get(g:, 'go_highlight_array_whitespace_error', 0)
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
29 endfunction
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
30
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
31 function! s:HighlightChanWhitespaceError() abort
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
32 return get(g:, 'go_highlight_chan_whitespace_error', 0)
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
33 endfunction
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
34
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
35 function! s:HighlightExtraTypes() abort
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
36 return get(g:, 'go_highlight_extra_types', 0)
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
37 endfunction
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
38
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
39 function! s:HighlightSpaceTabError() abort
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
40 return get(g:, 'go_highlight_space_tab_error', 0)
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
41 endfunction
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
42
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
43 function! s:HighlightTrailingWhitespaceError() abort
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
44 return get(g:, 'go_highlight_trailing_whitespace_error', 0)
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
45 endfunction
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
46
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
47 function! s:HighlightOperators() abort
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
48 return get(g:, 'go_highlight_operators', 0)
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
49 endfunction
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
50
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
51 function! s:HighlightFunctions() abort
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
52 return get(g:, 'go_highlight_functions', 0)
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
53 endfunction
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
54
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
55 function! s:HighlightFunctionParameters() abort
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
56 return get(g:, 'go_highlight_function_parameters', 0)
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
57 endfunction
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
58
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
59 function! s:HighlightFunctionCalls() abort
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
60 return get(g:, 'go_highlight_function_calls', 0)
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
61 endfunction
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
62
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
63 function! s:HighlightFields() abort
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
64 return get(g:, 'go_highlight_fields', 0)
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
65 endfunction
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
66
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
67 function! s:HighlightTypes() abort
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
68 return get(g:, 'go_highlight_types', 0)
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
69 endfunction
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
70
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
71 function! s:HighlightBuildConstraints() abort
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
72 return get(g:, 'go_highlight_build_constraints', 0)
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
73 endfunction
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
74
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
75 function! s:HighlightStringSpellcheck() abort
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
76 return get(g:, 'go_highlight_string_spellcheck', 1)
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
77 endfunction
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
78
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
79 function! s:HighlightFormatStrings() abort
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
80 return get(g:, 'go_highlight_format_strings', 1)
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
81 endfunction
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
82
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
83 function! s:HighlightGenerateTags() abort
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
84 return get(g:, 'go_highlight_generate_tags', 0)
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
85 endfunction
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
86
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
87 function! s:HighlightVariableAssignments() abort
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
88 return get(g:, 'go_highlight_variable_assignments', 0)
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
89 endfunction
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
90
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
91 function! s:HighlightVariableDeclarations() abort
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
92 return get(g:, 'go_highlight_variable_declarations', 0)
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
93 endfunction
6153
1e8ebf870720 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
94
1e8ebf870720 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
95 syn case match
1e8ebf870720 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
96
25161
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
97 syn keyword goPackage package
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
98 syn keyword goImport import contained
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
99 syn keyword goVar var contained
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
100 syn keyword goConst const contained
6153
1e8ebf870720 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
101
25161
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
102 hi def link goPackage Statement
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
103 hi def link goImport Statement
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
104 hi def link goVar Keyword
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
105 hi def link goConst Keyword
6153
1e8ebf870720 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
106 hi def link goDeclaration Keyword
1e8ebf870720 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
107
1e8ebf870720 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
108 " Keywords within functions
1e8ebf870720 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
109 syn keyword goStatement defer go goto return break continue fallthrough
1e8ebf870720 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
110 syn keyword goConditional if else switch select
1e8ebf870720 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
111 syn keyword goLabel case default
1e8ebf870720 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
112 syn keyword goRepeat for range
1e8ebf870720 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
113
1e8ebf870720 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
114 hi def link goStatement Statement
1e8ebf870720 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
115 hi def link goConditional Conditional
1e8ebf870720 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
116 hi def link goLabel Label
1e8ebf870720 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
117 hi def link goRepeat Repeat
1e8ebf870720 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
118
1e8ebf870720 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
119 " Predefined types
31139
20cf2080f1ee Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 25836
diff changeset
120 syn keyword goType chan map bool string error any comparable
6153
1e8ebf870720 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
121 syn keyword goSignedInts int int8 int16 int32 int64 rune
1e8ebf870720 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
122 syn keyword goUnsignedInts byte uint uint8 uint16 uint32 uint64 uintptr
1e8ebf870720 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
123 syn keyword goFloats float32 float64
1e8ebf870720 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
124 syn keyword goComplexes complex64 complex128
1e8ebf870720 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
125
1e8ebf870720 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
126 hi def link goType Type
1e8ebf870720 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
127 hi def link goSignedInts Type
1e8ebf870720 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
128 hi def link goUnsignedInts Type
1e8ebf870720 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
129 hi def link goFloats Type
1e8ebf870720 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
130 hi def link goComplexes Type
1e8ebf870720 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
131
25161
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
132 " Predefined functions and values
32957
a5bd10de6c37 runtime(go): Update Go syntax file with 1.21 builtins (#12876)
Christian Brabandt <cb@256bit.org>
parents: 32004
diff changeset
133 syn keyword goBuiltins append cap clear close complex copy delete imag len
a5bd10de6c37 runtime(go): Update Go syntax file with 1.21 builtins (#12876)
Christian Brabandt <cb@256bit.org>
parents: 32004
diff changeset
134 syn keyword goBuiltins make max min new panic print println real recover
25161
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
135 syn keyword goBoolean true false
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
136 syn keyword goPredefinedIdentifiers nil iota
6153
1e8ebf870720 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
137
25161
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
138 hi def link goBuiltins Identifier
32004
a9b5ffbc0428 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 31139
diff changeset
139 hi def link goPredefinedIdentifiers Constant
a9b5ffbc0428 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 31139
diff changeset
140 " Boolean links to Constant by default by vim: goBoolean and goPredefinedIdentifiers
a9b5ffbc0428 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 31139
diff changeset
141 " will be highlighted the same, but having the separate groups allows users to
a9b5ffbc0428 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 31139
diff changeset
142 " have separate highlighting for them if they desire.
25161
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
143 hi def link goBoolean Boolean
6153
1e8ebf870720 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
144
1e8ebf870720 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
145 " Comments; their contents
1e8ebf870720 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
146 syn keyword goTodo contained TODO FIXME XXX BUG
1e8ebf870720 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
147 syn cluster goCommentGroup contains=goTodo
25161
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
148
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
149 syn region goComment start="//" end="$" contains=goGenerate,@goCommentGroup,@Spell
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
150 if s:FoldEnable('comment')
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
151 syn region goComment start="/\*" end="\*/" contains=@goCommentGroup,@Spell fold
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
152 syn match goComment "\v(^\s*//.*\n)+" contains=goGenerate,@goCommentGroup,@Spell fold
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
153 else
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
154 syn region goComment start="/\*" end="\*/" contains=@goCommentGroup,@Spell
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
155 endif
6153
1e8ebf870720 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
156
1e8ebf870720 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
157 hi def link goComment Comment
1e8ebf870720 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
158 hi def link goTodo Todo
1e8ebf870720 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
159
25161
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
160 if s:HighlightGenerateTags()
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
161 syn match goGenerateVariables contained /\%(\$GOARCH\|\$GOOS\|\$GOFILE\|\$GOLINE\|\$GOPACKAGE\|\$DOLLAR\)\>/
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
162 syn region goGenerate start="^\s*//go:generate" end="$" contains=goGenerateVariables
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
163 hi def link goGenerate PreProc
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
164 hi def link goGenerateVariables Special
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
165 endif
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
166
6153
1e8ebf870720 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
167 " Go escapes
1e8ebf870720 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
168 syn match goEscapeOctal display contained "\\[0-7]\{3}"
1e8ebf870720 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
169 syn match goEscapeC display contained +\\[abfnrtv\\'"]+
1e8ebf870720 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
170 syn match goEscapeX display contained "\\x\x\{2}"
1e8ebf870720 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
171 syn match goEscapeU display contained "\\u\x\{4}"
1e8ebf870720 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
172 syn match goEscapeBigU display contained "\\U\x\{8}"
1e8ebf870720 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
173 syn match goEscapeError display contained +\\[^0-7xuUabfnrtv\\'"]+
1e8ebf870720 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
174
1e8ebf870720 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
175 hi def link goEscapeOctal goSpecialString
1e8ebf870720 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
176 hi def link goEscapeC goSpecialString
1e8ebf870720 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
177 hi def link goEscapeX goSpecialString
1e8ebf870720 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
178 hi def link goEscapeU goSpecialString
1e8ebf870720 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
179 hi def link goEscapeBigU goSpecialString
1e8ebf870720 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
180 hi def link goSpecialString Special
1e8ebf870720 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
181 hi def link goEscapeError Error
1e8ebf870720 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
182
1e8ebf870720 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
183 " Strings and their contents
1e8ebf870720 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
184 syn cluster goStringGroup contains=goEscapeOctal,goEscapeC,goEscapeX,goEscapeU,goEscapeBigU,goEscapeError
25161
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
185 if s:HighlightStringSpellcheck()
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
186 syn region goString start=+"+ skip=+\\\\\|\\"+ end=+"+ contains=@goStringGroup,@Spell
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
187 syn region goRawString start=+`+ end=+`+ contains=@Spell
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
188 else
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
189 syn region goString start=+"+ skip=+\\\\\|\\"+ end=+"+ contains=@goStringGroup
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
190 syn region goRawString start=+`+ end=+`+
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
191 endif
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
192
31139
20cf2080f1ee Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 25836
diff changeset
193 syn match goImportString /^\%(\s\+\|import \)\(\h\w* \)\?\zs"[^"]\+"$/ contained containedin=goImport
20cf2080f1ee Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 25836
diff changeset
194
25161
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
195 if s:HighlightFormatStrings()
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
196 " [n] notation is valid for specifying explicit argument indexes
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
197 " 1. Match a literal % not preceded by a %.
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
198 " 2. Match any number of -, #, 0, space, or +
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
199 " 3. Match * or [n]* or any number or nothing before a .
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
200 " 4. Match * or [n]* or any number or nothing after a .
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
201 " 5. Match [n] or nothing before a verb
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
202 " 6. Match a formatting verb
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
203 syn match goFormatSpecifier /\
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
204 \%([^%]\%(%%\)*\)\
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
205 \@<=%[-#0 +]*\
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
206 \%(\%(\%(\[\d\+\]\)\=\*\)\|\d\+\)\=\
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
207 \%(\.\%(\%(\%(\[\d\+\]\)\=\*\)\|\d\+\)\=\)\=\
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
208 \%(\[\d\+\]\)\=[vTtbcdoqxXUeEfFgGspw]/ contained containedin=goString,goRawString
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
209 hi def link goFormatSpecifier goSpecialString
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
210 endif
6153
1e8ebf870720 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
211
31139
20cf2080f1ee Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 25836
diff changeset
212 hi def link goImportString String
6153
1e8ebf870720 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
213 hi def link goString String
1e8ebf870720 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
214 hi def link goRawString String
1e8ebf870720 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
215
1e8ebf870720 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
216 " Characters; their contents
1e8ebf870720 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
217 syn cluster goCharacterGroup contains=goEscapeOctal,goEscapeC,goEscapeX,goEscapeU,goEscapeBigU
1e8ebf870720 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
218 syn region goCharacter start=+'+ skip=+\\\\\|\\'+ end=+'+ contains=@goCharacterGroup
1e8ebf870720 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
219
1e8ebf870720 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
220 hi def link goCharacter Character
1e8ebf870720 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
221
1e8ebf870720 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
222 " Regions
1e8ebf870720 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
223 syn region goParen start='(' end=')' transparent
25161
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
224 if s:FoldEnable('block')
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
225 syn region goBlock start="{" end="}" transparent fold
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
226 else
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
227 syn region goBlock start="{" end="}" transparent
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
228 endif
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
229
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
230 " import
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
231 if s:FoldEnable('import')
31139
20cf2080f1ee Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 25836
diff changeset
232 syn region goImport start='import (' end=')' transparent fold contains=goImport,goImportString,goComment
25161
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
233 else
31139
20cf2080f1ee Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 25836
diff changeset
234 syn region goImport start='import (' end=')' transparent contains=goImport,goImportString,goComment
25161
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
235 endif
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
236
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
237 " var, const
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
238 if s:FoldEnable('varconst')
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
239 syn region goVar start='var (' end='^\s*)$' transparent fold
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
240 \ contains=ALLBUT,goParen,goBlock,goFunction,goTypeName,goReceiverType,goReceiverVar,goParamName,goParamType,goSimpleParams,goPointerOperator
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
241 syn region goConst start='const (' end='^\s*)$' transparent fold
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
242 \ contains=ALLBUT,goParen,goBlock,goFunction,goTypeName,goReceiverType,goReceiverVar,goParamName,goParamType,goSimpleParams,goPointerOperator
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
243 else
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
244 syn region goVar start='var (' end='^\s*)$' transparent
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
245 \ contains=ALLBUT,goParen,goBlock,goFunction,goTypeName,goReceiverType,goReceiverVar,goParamName,goParamType,goSimpleParams,goPointerOperator
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
246 syn region goConst start='const (' end='^\s*)$' transparent
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
247 \ contains=ALLBUT,goParen,goBlock,goFunction,goTypeName,goReceiverType,goReceiverVar,goParamName,goParamType,goSimpleParams,goPointerOperator
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
248 endif
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
249
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
250 " Single-line var, const, and import.
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
251 syn match goSingleDecl /\%(import\|var\|const\) [^(]\@=/ contains=goImport,goVar,goConst
6153
1e8ebf870720 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
252
1e8ebf870720 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
253 " Integers
31139
20cf2080f1ee Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 25836
diff changeset
254 syn match goDecimalInt "\<-\=\%(0\|\%(\d\|\d_\d\)\+\)\>"
20cf2080f1ee Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 25836
diff changeset
255 syn match goHexadecimalInt "\<-\=0[xX]_\?\%(\x\|\x_\x\)\+\>"
20cf2080f1ee Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 25836
diff changeset
256 syn match goOctalInt "\<-\=0[oO]\?_\?\%(\o\|\o_\o\)\+\>"
20cf2080f1ee Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 25836
diff changeset
257 syn match goBinaryInt "\<-\=0[bB]_\?\%([01]\|[01]_[01]\)\+\>"
6153
1e8ebf870720 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
258
1e8ebf870720 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
259 hi def link goDecimalInt Integer
25161
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
260 hi def link goDecimalError Error
6153
1e8ebf870720 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
261 hi def link goHexadecimalInt Integer
25161
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
262 hi def link goHexadecimalError Error
6153
1e8ebf870720 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
263 hi def link goOctalInt Integer
25161
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
264 hi def link goOctalError Error
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
265 hi def link goBinaryInt Integer
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
266 hi def link goBinaryError Error
6153
1e8ebf870720 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
267 hi def link Integer Number
1e8ebf870720 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
268
1e8ebf870720 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
269 " Floating point
31139
20cf2080f1ee Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 25836
diff changeset
270 "float_lit = decimal_float_lit | hex_float_lit .
20cf2080f1ee Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 25836
diff changeset
271 "
20cf2080f1ee Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 25836
diff changeset
272 "decimal_float_lit = decimal_digits "." [ decimal_digits ] [ decimal_exponent ] |
20cf2080f1ee Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 25836
diff changeset
273 " decimal_digits decimal_exponent |
20cf2080f1ee Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 25836
diff changeset
274 " "." decimal_digits [ decimal_exponent ] .
20cf2080f1ee Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 25836
diff changeset
275 "decimal_exponent = ( "e" | "E" ) [ "+" | "-" ] decimal_digits .
20cf2080f1ee Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 25836
diff changeset
276 "
20cf2080f1ee Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 25836
diff changeset
277 "hex_float_lit = "0" ( "x" | "X" ) hex_mantissa hex_exponent .
20cf2080f1ee Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 25836
diff changeset
278 "hex_mantissa = [ "_" ] hex_digits "." [ hex_digits ] |
20cf2080f1ee Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 25836
diff changeset
279 " [ "_" ] hex_digits |
20cf2080f1ee Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 25836
diff changeset
280 " "." hex_digits .
20cf2080f1ee Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 25836
diff changeset
281 "hex_exponent = ( "p" | "P" ) [ "+" | "-" ] decimal_digits .
20cf2080f1ee Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 25836
diff changeset
282 " decimal floats with a decimal point
20cf2080f1ee Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 25836
diff changeset
283 syn match goFloat "\<-\=\%(0\|\%(\d\|\d_\d\)\+\)\.\%(\%(\%(\d\|\d_\d\)\+\)\=\%([Ee][-+]\=\%(\d\|\d_\d\)\+\)\=\>\)\="
20cf2080f1ee Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 25836
diff changeset
284 syn match goFloat "\s\zs-\=\.\%(\d\|\d_\d\)\+\%(\%([Ee][-+]\=\%(\d\|\d_\d\)\+\)\>\)\="
20cf2080f1ee Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 25836
diff changeset
285 " decimal floats without a decimal point
20cf2080f1ee Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 25836
diff changeset
286 syn match goFloat "\<-\=\%(0\|\%(\d\|\d_\d\)\+\)[Ee][-+]\=\%(\d\|\d_\d\)\+\>"
20cf2080f1ee Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 25836
diff changeset
287 " hexadecimal floats with a decimal point
20cf2080f1ee Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 25836
diff changeset
288 syn match goHexadecimalFloat "\<-\=0[xX]\%(_\x\|\x\)\+\.\%(\%(\x\|\x_\x\)\+\)\=\%([Pp][-+]\=\%(\d\|\d_\d\)\+\)\=\>"
20cf2080f1ee Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 25836
diff changeset
289 syn match goHexadecimalFloat "\<-\=0[xX]\.\%(\x\|\x_\x\)\+\%([Pp][-+]\=\%(\d\|\d_\d\)\+\)\=\>"
20cf2080f1ee Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 25836
diff changeset
290 " hexadecimal floats without a decimal point
20cf2080f1ee Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 25836
diff changeset
291 syn match goHexadecimalFloat "\<-\=0[xX]\%(_\x\|\x\)\+[Pp][-+]\=\%(\d\|\d_\d\)\+\>"
6153
1e8ebf870720 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
292
1e8ebf870720 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
293 hi def link goFloat Float
31139
20cf2080f1ee Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 25836
diff changeset
294 hi def link goHexadecimalFloat Float
6153
1e8ebf870720 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
295
1e8ebf870720 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
296 " Imaginary literals
31139
20cf2080f1ee Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 25836
diff changeset
297 syn match goImaginaryDecimal "\<-\=\%(0\|\%(\d\|\d_\d\)\+\)i\>"
20cf2080f1ee Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 25836
diff changeset
298 syn match goImaginaryHexadecimal "\<-\=0[xX]_\?\%(\x\|\x_\x\)\+i\>"
20cf2080f1ee Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 25836
diff changeset
299 syn match goImaginaryOctal "\<-\=0[oO]\?_\?\%(\o\|\o_\o\)\+i\>"
20cf2080f1ee Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 25836
diff changeset
300 syn match goImaginaryBinary "\<-\=0[bB]_\?\%([01]\|[01]_[01]\)\+i\>"
6153
1e8ebf870720 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
301
31139
20cf2080f1ee Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 25836
diff changeset
302 " imaginary decimal floats with a decimal point
20cf2080f1ee Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 25836
diff changeset
303 syn match goImaginaryFloat "\<-\=\%(0\|\%(\d\|\d_\d\)\+\)\.\%(\%(\%(\d\|\d_\d\)\+\)\=\%([Ee][-+]\=\%(\d\|\d_\d\)\+\)\=\)\=i\>"
20cf2080f1ee Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 25836
diff changeset
304 syn match goImaginaryFloat "\s\zs-\=\.\%(\d\|\d_\d\)\+\%([Ee][-+]\=\%(\d\|\d_\d\)\+\)\=i\>"
20cf2080f1ee Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 25836
diff changeset
305 " imaginary decimal floats without a decimal point
20cf2080f1ee Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 25836
diff changeset
306 syn match goImaginaryFloat "\<-\=\%(0\|\%(\d\|\d_\d\)\+\)[Ee][-+]\=\%(\d\|\d_\d\)\+i\>"
20cf2080f1ee Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 25836
diff changeset
307 " imaginary hexadecimal floats with a decimal point
20cf2080f1ee Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 25836
diff changeset
308 syn match goImaginaryHexadecimalFloat "\<-\=0[xX]\%(_\x\|\x\)\+\.\%(\%(\x\|\x_\x\)\+\)\=\%([Pp][-+]\=\%(\d\|\d_\d\)\+\)\=i\>"
20cf2080f1ee Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 25836
diff changeset
309 syn match goImaginaryHexadecimalFloat "\<-\=0[xX]\.\%(\x\|\x_\x\)\+\%([Pp][-+]\=\%(\d\|\d_\d\)\+\)\=i\>"
20cf2080f1ee Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 25836
diff changeset
310 " imaginary hexadecimal floats without a decimal point
20cf2080f1ee Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 25836
diff changeset
311 syn match goImaginaryHexadecimalFloat "\<-\=0[xX]\%(_\x\|\x\)\+[Pp][-+]\=\%(\d\|\d_\d\)\+i\>"
20cf2080f1ee Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 25836
diff changeset
312
20cf2080f1ee Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 25836
diff changeset
313 hi def link goImaginaryDecimal Number
20cf2080f1ee Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 25836
diff changeset
314 hi def link goImaginaryHexadecimal Number
20cf2080f1ee Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 25836
diff changeset
315 hi def link goImaginaryOctal Number
20cf2080f1ee Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 25836
diff changeset
316 hi def link goImaginaryBinary Number
20cf2080f1ee Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 25836
diff changeset
317 hi def link goImaginaryFloat Float
20cf2080f1ee Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 25836
diff changeset
318 hi def link goImaginaryHexadecimalFloat Float
6153
1e8ebf870720 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
319
1e8ebf870720 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
320 " Spaces after "[]"
25161
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
321 if s:HighlightArrayWhitespaceError()
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
322 syn match goSpaceError display "\%(\[\]\)\@<=\s\+"
6153
1e8ebf870720 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
323 endif
1e8ebf870720 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
324
1e8ebf870720 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
325 " Spacing errors around the 'chan' keyword
25161
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
326 if s:HighlightChanWhitespaceError()
6153
1e8ebf870720 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
327 " receive-only annotation on chan type
25161
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
328 "
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
329 " \(\<chan\>\)\@<!<- (only pick arrow when it doesn't come after a chan)
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
330 " this prevents picking up 'chan<- chan<-' but not '<- chan'
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
331 syn match goSpaceError display "\%(\%(\<chan\>\)\@<!<-\)\@<=\s\+\%(\<chan\>\)\@="
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
332
6153
1e8ebf870720 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
333 " send-only annotation on chan type
25161
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
334 "
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
335 " \(<-\)\@<!\<chan\> (only pick chan when it doesn't come after an arrow)
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
336 " this prevents picking up '<-chan <-chan' but not 'chan <-'
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
337 syn match goSpaceError display "\%(\%(<-\)\@<!\<chan\>\)\@<=\s\+\%(<-\)\@="
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
338
6153
1e8ebf870720 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
339 " value-ignoring receives in a few contexts
25161
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
340 syn match goSpaceError display "\%(\%(^\|[={(,;]\)\s*<-\)\@<=\s\+"
6153
1e8ebf870720 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
341 endif
1e8ebf870720 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
342
1e8ebf870720 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
343 " Extra types commonly seen
25161
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
344 if s:HighlightExtraTypes()
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
345 syn match goExtraType /\<bytes\.\%(Buffer\)\>/
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
346 syn match goExtraType /\<context\.\%(Context\)\>/
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
347 syn match goExtraType /\<io\.\%(Reader\|ReadSeeker\|ReadWriter\|ReadCloser\|ReadWriteCloser\|Writer\|WriteCloser\|Seeker\)\>/
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
348 syn match goExtraType /\<reflect\.\%(Kind\|Type\|Value\)\>/
6153
1e8ebf870720 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
349 syn match goExtraType /\<unsafe\.Pointer\>/
1e8ebf870720 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
350 endif
1e8ebf870720 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
351
1e8ebf870720 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
352 " Space-tab error
25161
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
353 if s:HighlightSpaceTabError()
6153
1e8ebf870720 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
354 syn match goSpaceError display " \+\t"me=e-1
1e8ebf870720 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
355 endif
1e8ebf870720 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
356
1e8ebf870720 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
357 " Trailing white space error
25161
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
358 if s:HighlightTrailingWhitespaceError()
6153
1e8ebf870720 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
359 syn match goSpaceError display excludenl "\s\+$"
1e8ebf870720 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
360 endif
1e8ebf870720 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
361
1e8ebf870720 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
362 hi def link goExtraType Type
1e8ebf870720 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
363 hi def link goSpaceError Error
1e8ebf870720 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
364
25161
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
365
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
366
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
367 " included from: https://github.com/athom/more-colorful.vim/blob/master/after/syntax/go.vim
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
368 "
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
369 " Comments; their contents
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
370 syn keyword goTodo contained NOTE
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
371 hi def link goTodo Todo
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
372
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
373 syn match goVarArgs /\.\.\./
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
374
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
375 " Operators;
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
376 if s:HighlightOperators()
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
377 " match single-char operators: - + % < > ! & | ^ * =
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
378 " and corresponding two-char operators: -= += %= <= >= != &= |= ^= *= ==
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
379 syn match goOperator /[-+%<>!&|^*=]=\?/
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
380 " match / and /=
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
381 syn match goOperator /\/\%(=\|\ze[^/*]\)/
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
382 " match two-char operators: << >> &^
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
383 " and corresponding three-char operators: <<= >>= &^=
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
384 syn match goOperator /\%(<<\|>>\|&^\)=\?/
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
385 " match remaining two-char operators: := && || <- ++ --
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
386 syn match goOperator /:=\|||\|<-\|++\|--/
31139
20cf2080f1ee Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 25836
diff changeset
387 " match ~
20cf2080f1ee Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 25836
diff changeset
388 syn match goOperator /\~/
25161
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
389 " match ...
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
390
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
391 hi def link goPointerOperator goOperator
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
392 hi def link goVarArgs goOperator
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
393 endif
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
394 hi def link goOperator Operator
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
395
31139
20cf2080f1ee Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 25836
diff changeset
396 " -> type constraint opening bracket
20cf2080f1ee Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 25836
diff changeset
397 " |-> start non-counting group
20cf2080f1ee Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 25836
diff changeset
398 " || -> any word character
20cf2080f1ee Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 25836
diff changeset
399 " || | -> at least one, as many as possible
20cf2080f1ee Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 25836
diff changeset
400 " || | | -> start non-counting group
20cf2080f1ee Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 25836
diff changeset
401 " || | | | -> match ~
20cf2080f1ee Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 25836
diff changeset
402 " || | | | | -> at most once
20cf2080f1ee Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 25836
diff changeset
403 " || | | | | | -> allow a slice type
20cf2080f1ee Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 25836
diff changeset
404 " || | | | | | | -> any word character
20cf2080f1ee Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 25836
diff changeset
405 " || | | | | | | | -> start a non-counting group
20cf2080f1ee Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 25836
diff changeset
406 " || | | | | | | | | -> that matches word characters and |
20cf2080f1ee Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 25836
diff changeset
407 " || | | | | | | | | | -> close the non-counting group
20cf2080f1ee Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 25836
diff changeset
408 " || | | | | | | | | | | -> close the non-counting group
20cf2080f1ee Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 25836
diff changeset
409 " || | | | | | | | | | | |-> any number of matches
20cf2080f1ee Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 25836
diff changeset
410 " || | | | | | | | | | | || -> start a non-counting group
20cf2080f1ee Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 25836
diff changeset
411 " || | | | | | | | | | | || | -> a comma and whitespace
20cf2080f1ee Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 25836
diff changeset
412 " || | | | | | | | | | | || | | -> at most once
20cf2080f1ee Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 25836
diff changeset
413 " || | | | | | | | | | | || | | | -> close the non-counting group
20cf2080f1ee Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 25836
diff changeset
414 " || | | | | | | | | | | || | | | | -> at least one of those non-counting groups, as many as possible
20cf2080f1ee Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 25836
diff changeset
415 " || | | | | | -------- | | | | || | | | | | -> type constraint closing bracket
20cf2080f1ee Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 25836
diff changeset
416 " || | | | | || | | | | | || | | | | | |
20cf2080f1ee Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 25836
diff changeset
417 syn match goTypeParams /\[\%(\w\+\s\+\%(\~\?\%(\[]\)\?\w\%(\w\||\)\)*\%(,\s*\)\?\)\+\]/ nextgroup=goSimpleParams,goDeclType contained
20cf2080f1ee Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 25836
diff changeset
418
25161
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
419 " Functions;
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
420 if s:HighlightFunctions() || s:HighlightFunctionParameters()
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
421 syn match goDeclaration /\<func\>/ nextgroup=goReceiver,goFunction,goSimpleParams skipwhite skipnl
31139
20cf2080f1ee Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 25836
diff changeset
422 syn match goReceiverDecl /(\s*\zs\%(\%(\w\+\s\+\)\?\*\?\w\+\%(\[\%(\%(\[\]\)\?\w\+\%(,\s*\)\?\)\+\]\)\?\)\ze\s*)/ contained contains=goReceiverVar,goReceiverType,goPointerOperator
25161
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
423 syn match goReceiverVar /\w\+\ze\s\+\%(\w\|\*\)/ nextgroup=goPointerOperator,goReceiverType skipwhite skipnl contained
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
424 syn match goPointerOperator /\*/ nextgroup=goReceiverType contained skipwhite skipnl
31139
20cf2080f1ee Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 25836
diff changeset
425 syn match goFunction /\w\+/ nextgroup=goSimpleParams,goTypeParams contained skipwhite skipnl
20cf2080f1ee Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 25836
diff changeset
426 syn match goReceiverType /\w\+\%(\[\%(\%(\[\]\)\?\w\+\%(,\s*\)\?\)\+\]\)\?\ze\s*)/ contained
25161
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
427 if s:HighlightFunctionParameters()
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
428 syn match goSimpleParams /(\%(\w\|\_s\|[*\.\[\],\{\}<>-]\)*)/ contained contains=goParamName,goType nextgroup=goFunctionReturn skipwhite skipnl
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
429 syn match goFunctionReturn /(\%(\w\|\_s\|[*\.\[\],\{\}<>-]\)*)/ contained contains=goParamName,goType skipwhite skipnl
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
430 syn match goParamName /\w\+\%(\s*,\s*\w\+\)*\ze\s\+\%(\w\|\.\|\*\|\[\)/ contained nextgroup=goParamType skipwhite skipnl
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
431 syn match goParamType /\%([^,)]\|\_s\)\+,\?/ contained nextgroup=goParamName skipwhite skipnl
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
432 \ contains=goVarArgs,goType,goSignedInts,goUnsignedInts,goFloats,goComplexes,goDeclType,goBlock
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
433 hi def link goReceiverVar goParamName
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
434 hi def link goParamName Identifier
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
435 endif
31139
20cf2080f1ee Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 25836
diff changeset
436 syn match goReceiver /(\s*\%(\w\+\s\+\)\?\*\?\s*\w\+\%(\[\%(\%(\[\]\)\?\w\+\%(,\s*\)\?\)\+\]\)\?\s*)\ze\s*\w/ contained nextgroup=goFunction contains=goReceiverDecl skipwhite skipnl
25161
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
437 else
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
438 syn keyword goDeclaration func
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
439 endif
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
440 hi def link goFunction Function
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
441
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
442 " Function calls;
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
443 if s:HighlightFunctionCalls()
31139
20cf2080f1ee Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 25836
diff changeset
444 syn match goFunctionCall /\w\+\ze\%(\[\%(\%(\[]\)\?\w\+\(,\s*\)\?\)\+\]\)\?(/ contains=goBuiltins,goDeclaration
25161
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
445 endif
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
446 hi def link goFunctionCall Type
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
447
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
448 " Fields;
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
449 if s:HighlightFields()
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
450 " 1. Match a sequence of word characters coming after a '.'
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
451 " 2. Require the following but dont match it: ( \@= see :h E59)
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
452 " - The symbols: / - + * % OR
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
453 " - The symbols: [] {} <> ) OR
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
454 " - The symbols: \n \r space OR
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
455 " - The symbols: , : .
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
456 " 3. Have the start of highlight (hs) be the start of matched
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
457 " pattern (s) offsetted one to the right (+1) (see :h E401)
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
458 syn match goField /\.\w\+\
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
459 \%(\%([\/\-\+*%]\)\|\
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
460 \%([\[\]{}<\>\)]\)\|\
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
461 \%([\!=\^|&]\)\|\
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
462 \%([\n\r\ ]\)\|\
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
463 \%([,\:.]\)\)\@=/hs=s+1
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
464 endif
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
465 hi def link goField Identifier
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
466
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
467 " Structs & Interfaces;
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
468 if s:HighlightTypes()
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
469 syn match goTypeConstructor /\<\w\+{\@=/
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
470 syn match goTypeDecl /\<type\>/ nextgroup=goTypeName skipwhite skipnl
31139
20cf2080f1ee Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 25836
diff changeset
471 syn match goTypeName /\w\+/ contained nextgroup=goDeclType,goTypeParams skipwhite skipnl
25161
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
472 syn match goDeclType /\<\%(interface\|struct\)\>/ skipwhite skipnl
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
473 hi def link goReceiverType Type
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
474 else
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
475 syn keyword goDeclType struct interface
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
476 syn keyword goDeclaration type
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
477 endif
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
478 hi def link goTypeConstructor Type
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
479 hi def link goTypeName Type
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
480 hi def link goTypeDecl Keyword
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
481 hi def link goDeclType Keyword
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
482
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
483 " Variable Assignments
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
484 if s:HighlightVariableAssignments()
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
485 syn match goVarAssign /\v[_.[:alnum:]]+(,\s*[_.[:alnum:]]+)*\ze(\s*([-^+|^\/%&]|\*|\<\<|\>\>|\&\^)?\=[^=])/
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
486 hi def link goVarAssign Special
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
487 endif
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
488
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
489 " Variable Declarations
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
490 if s:HighlightVariableDeclarations()
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
491 syn match goVarDefs /\v\w+(,\s*\w+)*\ze(\s*:\=)/
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
492 hi def link goVarDefs Special
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
493 endif
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
494
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
495 " Build Constraints
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
496 if s:HighlightBuildConstraints()
25836
65de67669df3 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 25161
diff changeset
497 syn match goBuildKeyword display contained "+build\|go:build"
25161
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
498 " Highlight the known values of GOOS, GOARCH, and other +build options.
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
499 syn keyword goBuildDirectives contained
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
500 \ android darwin dragonfly freebsd linux nacl netbsd openbsd plan9
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
501 \ solaris windows 386 amd64 amd64p32 arm armbe arm64 arm64be ppc64
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
502 \ ppc64le mips mipsle mips64 mips64le mips64p32 mips64p32le ppc
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
503 \ s390 s390x sparc sparc64 cgo ignore race
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
504
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
505 " Other words in the build directive are build tags not listed above, so
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
506 " avoid highlighting them as comments by using a matchgroup just for the
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
507 " start of the comment.
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
508 " The rs=s+2 option lets the \s*+build portion be part of the inner region
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
509 " instead of the matchgroup so it will be highlighted as a goBuildKeyword.
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
510 syn region goBuildComment matchgroup=goBuildCommentStart
31139
20cf2080f1ee Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 25836
diff changeset
511 \ start="//\(\s*+build\s\|go:build\)"rs=s+2 end="$"
25161
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
512 \ contains=goBuildKeyword,goBuildDirectives
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
513 hi def link goBuildCommentStart Comment
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
514 hi def link goBuildDirectives Type
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
515 hi def link goBuildKeyword PreProc
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
516 endif
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
517
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
518 if s:HighlightBuildConstraints() || s:FoldEnable('package_comment')
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
519 " One or more line comments that are followed immediately by a "package"
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
520 " declaration are treated like package documentation, so these must be
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
521 " matched as comments to avoid looking like working build constraints.
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
522 " The he, me, and re options let the "package" itself be highlighted by
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
523 " the usual rules.
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
524 exe 'syn region goPackageComment start=/\v(\/\/.*\n)+\s*package/'
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
525 \ . ' end=/\v\n\s*package/he=e-7,me=e-7,re=e-7'
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
526 \ . ' contains=@goCommentGroup,@Spell'
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
527 \ . (s:FoldEnable('package_comment') ? ' fold' : '')
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
528 exe 'syn region goPackageComment start=/\v^\s*\/\*.*\n(.*\n)*\s*\*\/\npackage/'
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
529 \ . ' end=/\v\*\/\n\s*package/he=e-7,me=e-7,re=e-7'
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
530 \ . ' contains=@goCommentGroup,@Spell'
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
531 \ . (s:FoldEnable('package_comment') ? ' fold' : '')
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
532 hi def link goPackageComment Comment
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
533 endif
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
534
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
535 " :GoCoverage commands
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
536 hi def link goCoverageNormalText Comment
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
537
6153
1e8ebf870720 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
538 " Search backwards for a global declaration to start processing the syntax.
1e8ebf870720 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
539 "syn sync match goSync grouphere NONE /^\(const\|var\|type\|func\)\>/
1e8ebf870720 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
540
1e8ebf870720 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
541 " There's a bug in the implementation of grouphere. For now, use the
1e8ebf870720 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
542 " following as a more expensive/less precise workaround.
1e8ebf870720 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
543 syn sync minlines=500
1e8ebf870720 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
544
25161
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
545 let b:current_syntax = "go"
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
546
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
547 let &cpo = s:keepcpo
84c7dc0fdcd2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 6153
diff changeset
548 unlet s:keepcpo
6153
1e8ebf870720 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
549
1e8ebf870720 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
550 " vim: sw=2 sts=2 et