Skip to content

Commit

Permalink
Allow folding any comment (#1428)
Browse files Browse the repository at this point in the history
  • Loading branch information
hexasoftware authored and arp242 committed Sep 8, 2017
1 parent 0be825d commit 9cce36b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
3 changes: 2 additions & 1 deletion doc/vim-go.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1623,8 +1623,9 @@ You can enable specific fold regions by setting an array. Possible values are:
- "import" `import` block.
- "varconst" `var` and `const` blocks.
- "package_comment" The package comment.
- "comment" Any comment that is not the package comment.

By default they're all enabled:
By default all except "comment" are enabled:
>
let g:go_fold_enable = ['block', 'import', 'varconst', 'package_comment']
<
Expand Down
13 changes: 12 additions & 1 deletion syntax/go.vim
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@ let s:fold_block = 1
let s:fold_import = 1
let s:fold_varconst = 1
let s:fold_package_comment = 1
let s:fold_comment = 0

if exists("g:go_fold_enable")
if index(g:go_fold_enable, 'block') == -1
let s:fold_block = 0
Expand All @@ -107,6 +109,9 @@ if exists("g:go_fold_enable")
if index(g:go_fold_enable, 'varconst') == -1
let s:fold_varconst = 0
endif
if index(g:go_fold_enable, 'comment') == -1
let s:fold_comment = 0
endif
if index(g:go_fold_enable, 'package_comment') == -1
let s:fold_package_comment = 0
endif
Expand Down Expand Up @@ -163,8 +168,14 @@ hi def link goPredefinedIdentifiers goBoolean
" Comments; their contents
syn keyword goTodo contained TODO FIXME XXX BUG
syn cluster goCommentGroup contains=goTodo
syn region goComment start="/\*" end="\*/" contains=@goCommentGroup,@Spell

syn region goComment start="//" end="$" contains=goGenerate,@goCommentGroup,@Spell
if s:fold_comment
syn region goComment start="/\*" end="\*/" contains=@goCommentGroup,@Spell fold
syn match goComment "\v(^\s*//.*\n)+" contains=goGenerate,@goCommentGroup,@Spell fold
else
syn region goComment start="/\*" end="\*/" contains=@goCommentGroup,@Spell
endif

hi def link goComment Comment
hi def link goTodo Todo
Expand Down

0 comments on commit 9cce36b

Please sign in to comment.