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
Changes from 4 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
16 changes: 15 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 = 1

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,6 +164,7 @@ 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

Expand Down Expand Up @@ -240,6 +246,13 @@ else
\ contains=ALLBUT,goParen,goBlock,goFunction,goTypeName,goReceiverType,goReceiverVar
endif

if s:fold_comment
" changed this to comments instead of declaration_comment
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this comment can be removed?

syn region goComment start="/\*" end="\*/" contains=@goCommentGroup,@Spell fold
syn match goComment "\v(^\s*//.*\n)+" contains=goGenerate,@goCommentGroup,@Spell fold
endif
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good and works well in my testing, but could you move this next to the regular goComment lines on line 168? I think that makes more sense and would make it easier to maintain later on.

Would also be nice if you could remove the extra blank lines you added :-)



" Single-line var, const, and import.
syn match goSingleDecl /\(import\|var\|const\) [^(]\@=/ contains=goImport,goVar,goConst

Expand Down Expand Up @@ -452,4 +465,5 @@ syn sync minlines=500

let b:current_syntax = "go"

" vim: sw=2 ts=2 et
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we want to keep the modeline; you you add this back please?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, sry I guess I removed modeline within my tests down there and didn't realize, I was also trying to create a FoldText() function so in the cases we fold the declarations the text would contain the subject (func/type/const/var),

I made the suggested changes