Skip to content

Commit 8cf26a5

Browse files
committed
Add # foldable_groups option for comment
Known `=begin xxx` should be valid comment, but seems not detected well when ruby_no_comment_fold is set.
1 parent abfd23f commit 8cf26a5

4 files changed

Lines changed: 40 additions & 1 deletion

File tree

doc/ft-ruby-syntax.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ value is space-separated keywords, known keywords were:
6969
/ Regexp
7070
string String and shell command output (surrounded by ', ", `)
7171
: Symbol
72+
# Multiline comment
7273
<< Here documents
7374

7475
5. Reducing expensive operations *ruby_no_expensive*

etc/examples/generators/syntax/percent_generator.rb

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -567,6 +567,28 @@
567567

568568

569569

570+
# comment {{{
571+
if arg == 'comment'
572+
puts <<-END.gsub(/^ {4}/, '')
573+
# foo
574+
# foo
575+
# bar
576+
577+
baz
578+
579+
580+
581+
=begin foo bar
582+
comment
583+
=end baz
584+
585+
586+
END
587+
end
588+
# }}}
589+
590+
591+
570592
puts "#\svim:foldmethod=syntax"
571593

572594

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Generated by `./etc/examples/generators/syntax/percent_generator.rb comment > etc/examples/syntax/percent/comment.rb`
2+
3+
# foo
4+
# foo
5+
# bar
6+
7+
baz
8+
9+
10+
11+
=begin foo bar
12+
comment
13+
=end baz
14+
15+
16+
# vim:foldmethod=syntax

syntax/ruby.vim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -436,7 +436,7 @@ endif
436436
syn match rubySharpBang "\%^#!.*" display
437437
syn keyword rubyTodo FIXME NOTE TODO OPTIMIZE HACK REVIEW XXX todo contained
438438
syn match rubyComment "#.*" contains=rubySharpBang,rubySpaceError,rubyTodo,@Spell
439-
if !exists("ruby_no_comment_fold")
439+
if !exists("ruby_no_comment_fold") && s:foldable('#')
440440
syn region rubyMultilineComment start="\%(\%(^\s*#.*\n\)\@<!\%(^\s*#.*\n\)\)\%(\(^\s*#.*\n\)\{1,}\)\@=" end="\%(^\s*#.*\n\)\@<=\%(^\s*#.*\n\)\%(^\s*#\)\@!" contains=rubyComment transparent fold keepend
441441
syn region rubyDocumentation start="^=begin\ze\%(\s.*\)\=$" end="^=end\%(\s.*\)\=$" contains=rubySpaceError,rubyTodo,@Spell fold
442442
else

0 commit comments

Comments
 (0)