Skip to content

Commit

Permalink
syntax: fix folding of empty import, comment, and declarations
Browse files Browse the repository at this point in the history
Fixes #3576
  • Loading branch information
bhcleek committed Sep 3, 2023
1 parent ec8f05b commit 04b8490
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions syntax/go.vim
Original file line number Diff line number Diff line change
Expand Up @@ -147,21 +147,31 @@ endif
" import
if go#config#FoldEnable('import')
syn region goImport start='import (' end=')' transparent fold contains=goImport,goImportString,goComment
syn match goImport /^import ()/ transparent fold contains=goImport
else
syn region goImport start='import (' end=')' transparent contains=goImport,goImportString,goComment
syn match goImport /^import ()/ transparent contains=goImport
endif

" var, const
if go#config#FoldEnable('varconst')
syn region goVar start='var (' end='^\s*)$' transparent fold
\ contains=ALLBUT,goParen,goBlock,goFunction,goTypeName,goReceiverType,goReceiverVar,goParamName,goParamType,goSimpleParams,goPointerOperator
\ contains=ALLBUT,goParen,goBlock,goFunction,goTypeName,goReceiverType,goReceiverVar,goParamName,goParamType,goSimpleParams,goPointerOperator
syn match goVar /var ()/ transparent fold
\ contains=ALLBUT,goParen,goBlock,goFunction,goTypeName,goReceiverType,goReceiverVar,goParamName,goParamType,goSimpleParams,goPointerOperator
syn region goConst start='const (' end='^\s*)$' transparent fold
\ contains=ALLBUT,goParen,goBlock,goFunction,goTypeName,goReceiverType,goReceiverVar,goParamName,goParamType,goSimpleParams,goPointerOperator
\ contains=ALLBUT,goParen,goBlock,goFunction,goTypeName,goReceiverType,goReceiverVar,goParamName,goParamType,goSimpleParams,goPointerOperator
syn match goConst /const ()/ transparent fold
\ contains=ALLBUT,goParen,goBlock,goFunction,goTypeName,goReceiverType,goReceiverVar,goParamName,goParamType,goSimpleParams,goPointerOperator
else
syn region goVar start='var (' end='^\s*)$' transparent
\ contains=ALLBUT,goParen,goBlock,goFunction,goTypeName,goReceiverType,goReceiverVar,goParamName,goParamType,goSimpleParams,goPointerOperator
\ contains=ALLBUT,goParen,goBlock,goFunction,goTypeName,goReceiverType,goReceiverVar,goParamName,goParamType,goSimpleParams,goPointerOperator
syn match goVar /var ()/ transparent
\ contains=ALLBUT,goParen,goBlock,goFunction,goTypeName,goReceiverType,goReceiverVar,goParamName,goParamType,goSimpleParams,goPointerOperator
syn region goConst start='const (' end='^\s*)$' transparent
\ contains=ALLBUT,goParen,goBlock,goFunction,goTypeName,goReceiverType,goReceiverVar,goParamName,goParamType,goSimpleParams,goPointerOperator
\ contains=ALLBUT,goParen,goBlock,goFunction,goTypeName,goReceiverType,goReceiverVar,goParamName,goParamType,goSimpleParams,goPointerOperator
syn match goConst /const ()/ transparent
\ contains=ALLBUT,goParen,goBlock,goFunction,goTypeName,goReceiverType,goReceiverVar,goParamName,goParamType,goSimpleParams,goPointerOperator
endif

" Single-line var, const, and import.
Expand Down

0 comments on commit 04b8490

Please sign in to comment.