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

folding improvements #1428

Merged
merged 6 commits into from
Sep 8, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion doc/vim-go.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1622,8 +1622,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 @@ -93,6 +93,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 @@ -103,6 +105,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 @@ -159,8 +164,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