Skip to content

Commit f171c07

Browse files
committed
Added support for short declaration in select statements, fixed range not highlighting correctly
1 parent 61934ef commit f171c07

File tree

2 files changed

+20
-7
lines changed

2 files changed

+20
-7
lines changed

changelog.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,16 @@
11
# Changelog
22

3+
## Unreleased
4+
5+
### Added
6+
7+
- Added support for short declaration in `select` statements, e.g. `case a :=
8+
<-c:`
9+
10+
### Fixed
11+
12+
- Fixed `range` not highlighting correctly
13+
314
## Version 0.2.1 - 2023/01/01
415

516
### Changed

syntax/go.vim

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -109,15 +109,13 @@ GoDeferCleanup delcom GoFoldStruct
109109

110110
" Two top-level clusters to allow regions to specify what syntax they can
111111
" contain
112-
syntax cluster goExpr contains=@goLiteral,goDotExpr,goFuncLiteral,goCommaExpr,goOperator,goWordStart,goParenBlock,goBracketBlock,goComment
112+
syntax cluster goExpr contains=@goLiteral,goForRange,goDotExpr,goFuncLiteral,goCommaExpr,goOperator,goWordStart,goParenBlock,goBracketBlock,goComment
113113
syntax cluster goStatement contains=@goExpr,@goFlowControl,goReturn,goSemicolon,goBraceBlock,goStatementStart,goConstDecl,goVarDecl,goTypeDecl,goKeywords
114114

115-
syntax match goIdentifier /\K\k*/ contained nextgroup=goDotExpr skipwhite
116-
117115
" 'goWordStart' reduces the number of times each of the 'nextgroups' is checked,
118116
" but also prevents 'goImportedPackages' (a keyword syntax element) from
119117
" overriding matches (e.g. in 'goStructLiteralField').
120-
syntax match goWordStart /\<\ze\K/ contained nextgroup=goStructLiteral,goFuncCall,goBuiltins,goMakeBuiltin,goNewBuiltin,goImportedPackages,goIdentifier
118+
syntax match goWordStart /\<\ze\K/ contained nextgroup=goStructLiteral,goFuncCall,goBuiltins,goMakeBuiltin,goNewBuiltin,goImportedPackages
121119

122120
" 'goDotExpr' matches a dot that is found as a part of an expression, whereas
123121
" 'goDot' is used to highlight a dot in non-expression contexts (e.g. the dot
@@ -636,7 +634,7 @@ call s:HiConfig('goFuncCallParens', ['go_highlight_function_call_parens'])
636634

637635
" Flow Control {{{
638636

639-
syntax cluster goFlowControl contains=goIf,goElse,goFor,goForKeywords,goSwitch,goSelect,goSwitchKeywords
637+
syntax cluster goFlowControl contains=goIf,goElse,goFor,goForRange,goForKeywords,goSwitch,goCase,goSelect,goSwitchKeywords
640638

641639
" 'goStatementStart' is used to avoid searching for 'goLabel' everywhere
642640
syntax match goLabel /\K\k*\ze:/ contained
@@ -645,11 +643,13 @@ syntax keyword goIf if contained skipwhite skipempty nextgroup=
645643
syntax keyword goElse else contained
646644

647645
syntax keyword goFor for contained skipwhite skipempty nextgroup=goShortVarDecl
648-
syntax keyword goForKeywords range break continue contained
646+
syntax keyword goForRange range contained
647+
syntax keyword goForKeywords break continue contained
649648

650649
syntax keyword goSwitch switch contained skipwhite nextgroup=goShortVarDecl
651650
syntax keyword goSelect select contained
652-
syntax keyword goSwitchKeywords case fallthrough default contained
651+
syntax keyword goCase case contained skipwhite nextgroup=goShortVarDecl
652+
syntax keyword goSwitchKeywords fallthrough default contained
653653

654654
syntax match goSwitchTypeCase /^\s\+case\s/ contained skipwhite nextgroup=@goType
655655
syntax region goSwitchTypeBlock matchgroup=goSwitchTypeBraces start='{' end='}' contained contains=goSwitchTypeCase,goSwitchTypeBlockNestedBraces,@goStatement
@@ -661,10 +661,12 @@ hi link goIf Conditional
661661
hi link goElse goIf
662662

663663
hi link goFor Repeat
664+
hi link goForRange goFor
664665
hi link goForKeywords goFor
665666

666667
hi link goSwitch Conditional
667668
hi link goSelect goSwitch
669+
hi link goCase goSwitch
668670
hi link goSwitchKeywords goSwitch
669671

670672
hi link goSwitchTypeBraces goBraces

0 commit comments

Comments
 (0)