arp242/gopher.vim

syntax: split fold-block

arp242 opened this issue · 0 comments

Right now putting fold-block in gopher_highlight will fold any { .. } block. There is no way to fold only functions, or only structs.

It would be useful to split this out to fold-func, fold-struct (which also includes interfaces), and fold-block (which would be if and for).

Most basic patch to test feasibility:

diff --git i/syntax/go.vim w/syntax/go.vim
index 606d0d6..2d6cac6 100644
--- i/syntax/go.vim
+++ w/syntax/go.vim
@@ -16,7 +16,7 @@ syn keyword     goPackage         package
 syn keyword     goImport          import    contained
 syn keyword     goVar             var       contained
 syn keyword     goConst           const     contained
-syn keyword     goDeclaration     func type struct interface
+syn keyword     goDeclaration     func type struct interface contained

 " Keywords within functions.
 syn keyword     goStatement       defer go goto return break continue fallthrough
@@ -141,11 +141,12 @@ syn region      goCharacter       start=/'/ end=/'/ contains=@goCharacterGroup

 " Regions
 syn region      goParen           start='(' end=')' transparent
-if s:has_setting('fold-block')
-  syn region    goBlock           start="{" end="}" transparent fold
-else
-  syn region    goBlock           start="{" end="}" transparent
-endif
+" if s:has_setting('fold-block')
+"   syn region    goBlock           start="{" end="}" transparent fold
+" else
+"   syn region    goBlock           start="{" end="}" transparent
+" endif
+syn region    goBlock       start=/^func / end="}" transparent fold contains=goDeclaration

 " import
 if s:has_setting('fold-import')

Original report: fatih/vim-go#2551