Skip to content

Commit

Permalink
syntax/go.vim: Fixed comments in certain places where expressions are…
Browse files Browse the repository at this point in the history
… expected (e.g. function arguments)
  • Loading branch information
charlespascoe committed Jan 1, 2023
1 parent d581656 commit e8b6098
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
2 changes: 2 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
correctly
- Fixed slice literals whose item type is a function with a return type
- Fixed nested slice literals
- Fixed comments in certain places where expressions are expected (e.g. function
arguments)

## Version 0.2.0 - 2022/12/31

Expand Down
12 changes: 6 additions & 6 deletions syntax/go.vim
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,8 @@ GoDeferCleanup delcom GoFoldStruct

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

syntax match goIdentifier /\K\k*/ contained nextgroup=goDotExpr skipwhite

Expand Down Expand Up @@ -307,8 +307,8 @@ syntax keyword goVarDecl var skipwhite skipnl nextgroup=goVarIdentifier,goVa
" syntax region goVarDeclGroup matchgroup=goVarDeclParens start='(' end=')' contained contains=@goExpr,goComment,goSemicolon,goVarGroupIdentifier
" syntax region goConstDeclGroup matchgroup=goConstDeclParens start='(' end=')' contained contains=@goExpr,goComment,goSemicolon,goVarGroupIdentifier,goIota

syntax region goVarDeclGroup matchgroup=goVarDeclParens start='(' end=')' contained contains=@goExpr,goComment,goSemicolon,goVarIdentifier
syntax region goConstDeclGroup matchgroup=goConstDeclParens start='(' end=')' contained contains=@goExpr,goComment,goSemicolon,goVarIdentifier,goIota
syntax region goVarDeclGroup matchgroup=goVarDeclParens start='(' end=')' contained contains=@goExpr,goSemicolon,goVarIdentifier
syntax region goConstDeclGroup matchgroup=goConstDeclParens start='(' end=')' contained contains=@goExpr,goSemicolon,goVarIdentifier,goIota

" TODO: Is it worth supporting comments in goVarComma??
syntax match goVarIdentifier /\<\K\k*/ contained skipwhite nextgroup=goVarComma,@goType
Expand Down Expand Up @@ -438,7 +438,7 @@ syntax match goSliceOrArrayLiteral /\k\@1<!\[[0-9.]*\]\ze\%(\*\|\K\|\[\|(\)/ con
syntax region goSliceLiteralType start='\S' end='\ze{\|$' contained contains=goSliceLiteralTypeMatch skipwhite skipnl nextgroup=goSliceItems
syntax match goSliceLiteralTypeMatch /\%(\%(interface\|struct\)\s*{\|[^{]\)\+/ contained contains=@goType

syntax region goSliceItems matchgroup=goSliceBraces start='{' end='}' contained contains=goStructLiteralBlock,@goExpr,goComment
syntax region goSliceItems matchgroup=goSliceBraces start='{' end='}' contained contains=goStructLiteralBlock,@goExpr

syntax match goChannel /<-chan/ contained contains=goChannelDir skipwhite nextgroup=@goType
syntax match goChannel /chan\%(<-\)\?/ contained contains=goChannelDir skipwhite nextgroup=@goType
Expand Down Expand Up @@ -578,7 +578,7 @@ syntax region goStructLiteralTypeArgs matchgroup=goTypeParamBrackets start='\['
" goStructLiteralBlock contains itself to 1) prevent weird highlighting while
" typing, and 2) allow slice literals of slices of structs to highlight
" correctly
GoFoldStruct syntax region goStructLiteralBlock matchgroup=goStructBraces start='{' end='}' contained contains=goStructLiteralField,goComma,@goExpr,goComment,goStructLiteralBlock
GoFoldStruct syntax region goStructLiteralBlock matchgroup=goStructBraces start='{' end='}' contained contains=goStructLiteralField,goComma,@goExpr,goStructLiteralBlock

syntax match goStructLiteralField /\<\K\k*\ze:/ contained nextgroup=goStructLiteralColon
syntax match goStructLiteralColon /:/ contained
Expand Down

0 comments on commit e8b6098

Please sign in to comment.