Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

syntax: split fold-block #24

Open
arp242 opened this issue Oct 28, 2019 · 0 comments
Open

syntax: split fold-block #24

arp242 opened this issue Oct 28, 2019 · 0 comments
Labels
enhancement New feature or request

Comments

@arp242
Copy link
Owner

arp242 commented Oct 28, 2019

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

@arp242 arp242 added the enhancement New feature or request label Oct 28, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant