comparison vendor/vim-syntax/ruby.vim @ 726:78469331407e

Update syntaxes
author nanaya <me@nanaya.net>
date Mon, 19 Aug 2024 17:04:13 +0900
parents 6cdd7d26260d
children
comparison
equal deleted inserted replaced
725:0a896ffe3029 726:78469331407e
1 " Vim syntax file 1 " Vim syntax file
2 " Language: Ruby 2 " Language: Ruby
3 " Maintainer: Doug Kearns <dougkearns@gmail.com> 3 " Maintainer: Doug Kearns <dougkearns@gmail.com>
4 " URL: https://github.com/vim-ruby/vim-ruby 4 " URL: https://github.com/vim-ruby/vim-ruby
5 " Release Coordinator: Doug Kearns <dougkearns@gmail.com> 5 " Release Coordinator: Doug Kearns <dougkearns@gmail.com>
6 " Last Change: 2021 Nov 03 6 " Last Change: 2023 Mar 16
7 " ---------------------------------------------------------------------------- 7 " ----------------------------------------------------------------------------
8 " 8 "
9 " Previous Maintainer: Mirko Nasato 9 " Previous Maintainer: Mirko Nasato
10 " Thanks to perl.vim authors, and to Reimer Behrends. :-) (MN) 10 " Thanks to perl.vim authors, and to Reimer Behrends. :-) (MN)
11 " ---------------------------------------------------------------------------- 11 " ----------------------------------------------------------------------------
143 syn cluster rubyNestedBrackets contains=rubyNested.\+ 143 syn cluster rubyNestedBrackets contains=rubyNested.\+
144 syn cluster rubyStringSpecial contains=rubyInterpolation,rubyStringEscape 144 syn cluster rubyStringSpecial contains=rubyInterpolation,rubyStringEscape
145 syn cluster rubyStringNotTop contains=@rubyStringSpecial,@rubyNestedBrackets,@rubySingleCharEscape 145 syn cluster rubyStringNotTop contains=@rubyStringSpecial,@rubyNestedBrackets,@rubySingleCharEscape
146 146
147 " Regular Expression Metacharacters {{{1 147 " Regular Expression Metacharacters {{{1
148 syn region rubyRegexpComment matchgroup=rubyRegexpSpecial start="(?#" skip="\\\\\|\\)" end=")" contained 148 syn region rubyRegexpComment matchgroup=rubyRegexpSpecial start="(?#" skip="\\\\\|\\)" end=")" contained
149 syn region rubyRegexpParens matchgroup=rubyRegexpSpecial start="(\(?:\|?<\=[=!]\|?>\|?<[a-z_]\w*>\|?[imx]*-[imx]*:\=\|\%(?#\)\@!\)" skip="\\\\\|\\)" end=")" contained transparent contains=@rubyRegexpSpecial 149 syn region rubyRegexpParens matchgroup=rubyRegexpSpecial start="(\%(?:\|?<\=[=!]\|?>\|?<[a-z_]\w*>\|?[imx]*-[imx]*:\=\|\%(?#\)\@!\)" skip="\\\\\|\\)" end=")" contained transparent contains=@rubyRegexpSpecial
150 syn region rubyRegexpBrackets matchgroup=rubyRegexpCharClass start="\[\^\=" skip="\\\\\|\\\]" end="\]" contained transparent contains=rubyRegexpBrackets,rubyStringEscape,rubyRegexpEscape,rubyRegexpCharClass,rubyRegexpIntersection oneline 150 syn region rubyRegexpBrackets matchgroup=rubyRegexpCharClass start="\[\^\=" skip="\\\\\|\\\]" end="\]" contained transparent contains=rubyRegexpBrackets,rubyStringEscape,rubyRegexpEscape,rubyRegexpCharClass,rubyRegexpIntersection oneline
151 syn match rubyRegexpCharClass "\\[DdHhRSsWw]" contained display 151 syn match rubyRegexpCharClass "\\[DdHhRSsWw]" contained display
152 syn match rubyRegexpCharClass "\[:\^\=\%(alnum\|alpha\|ascii\|blank\|cntrl\|digit\|graph\|lower\|print\|punct\|space\|upper\|word\|xdigit\):\]" contained 152 syn match rubyRegexpCharClass "\[:\^\=\%(alnum\|alpha\|ascii\|blank\|cntrl\|digit\|graph\|lower\|print\|punct\|space\|upper\|word\|xdigit\):\]" contained
153 syn match rubyRegexpCharClass "\\[pP]{^\=.\{-}}" contained display 153 syn match rubyRegexpCharClass "\\[pP]{^\=.\{-}}" contained display
154 syn match rubyRegexpEscape "\\[].*?+^$|\\/(){}[]" contained " see commit e477f10 154 syn match rubyRegexpEscape "\\[].*?+^$|\\/(){}[]" contained " see commit e477f10
155 syn match rubyRegexpQuantifier "[*?+][?+]\=" contained display 155 syn match rubyRegexpQuantifier "[*?+][?+]\=" contained display
344 " Keywords {{{1 344 " Keywords {{{1
345 " TODO: reorganise 345 " TODO: reorganise
346 syn match rubyControl "\%#=1\<\%(break\|in\|next\|redo\|retry\|return\)\>" 346 syn match rubyControl "\%#=1\<\%(break\|in\|next\|redo\|retry\|return\)\>"
347 syn match rubyKeyword "\%#=1\<\%(super\|yield\)\>" 347 syn match rubyKeyword "\%#=1\<\%(super\|yield\)\>"
348 syn match rubyBoolean "\%#=1\<\%(true\|false\)\>[?!]\@!" 348 syn match rubyBoolean "\%#=1\<\%(true\|false\)\>[?!]\@!"
349 syn match rubyPseudoVariable "\%#=1\<\(self\|nil\)\>[?!]\@!" 349 syn match rubyPseudoVariable "\%#=1\<\%(self\|nil\)\>[?!]\@!"
350 syn match rubyPseudoVariable "\%#=1\<__\%(ENCODING\|dir\|FILE\|LINE\|callee\|method\)__\>" 350 syn match rubyPseudoVariable "\%#=1\<__\%(ENCODING\|dir\|FILE\|LINE\|callee\|method\)__\>"
351 syn match rubyBeginEnd "\%#=1\<\%(BEGIN\|END\)\>" 351 syn match rubyBeginEnd "\%#=1\<\%(BEGIN\|END\)\>"
352 352
353 " Expensive Mode {{{1 353 " Expensive Mode {{{1
354 " Match 'end' with the appropriate opening keyword for syntax based folding 354 " Match 'end' with the appropriate opening keyword for syntax based folding
397 " statements with optional 'do' 397 " statements with optional 'do'
398 syn region rubyOptionalDoLine matchgroup=rubyRepeat start="\<for\>" start="\%(\%(^\|\.\.\.\=\|[{:,;([<>~\*/%&^|+=-]\|\%(\<\%(\h\|[^\x00-\x7F]\)\%(\w\|[^\x00-\x7F]\)*\)\@<![!?]\)\s*\)\@<=\<\%(until\|while\)\>" matchgroup=rubyOptionalDo end="\<do\>" end="\ze\%(;\|$\)" oneline contains=ALLBUT,@rubyNotTop 398 syn region rubyOptionalDoLine matchgroup=rubyRepeat start="\<for\>" start="\%(\%(^\|\.\.\.\=\|[{:,;([<>~\*/%&^|+=-]\|\%(\<\%(\h\|[^\x00-\x7F]\)\%(\w\|[^\x00-\x7F]\)*\)\@<![!?]\)\s*\)\@<=\<\%(until\|while\)\>" matchgroup=rubyOptionalDo end="\<do\>" end="\ze\%(;\|$\)" oneline contains=ALLBUT,@rubyNotTop
399 399
400 SynFold 'for' syn region rubyRepeatExpression start="\<for\>" start="\%(\%(^\|\.\.\.\=\|[{:,;([<>~\*/%&^|+=-]\|\%(\<\%(\h\|[^\x00-\x7F]\)\%(\w\|[^\x00-\x7F]\)*\)\@<![!?]\)\s*\)\@<=\<\%(until\|while\)\>" matchgroup=rubyRepeat skip="\<end:" end="\<end\>" contains=ALLBUT,@rubyNotTop nextgroup=rubyOptionalDoLine 400 SynFold 'for' syn region rubyRepeatExpression start="\<for\>" start="\%(\%(^\|\.\.\.\=\|[{:,;([<>~\*/%&^|+=-]\|\%(\<\%(\h\|[^\x00-\x7F]\)\%(\w\|[^\x00-\x7F]\)*\)\@<![!?]\)\s*\)\@<=\<\%(until\|while\)\>" matchgroup=rubyRepeat skip="\<end:" end="\<end\>" contains=ALLBUT,@rubyNotTop nextgroup=rubyOptionalDoLine
401 401
402 if !exists("ruby_minlines")
403 let ruby_minlines = 500
404 endif
405 exe "syn sync minlines=" . ruby_minlines
406
407 else 402 else
408 syn match rubyControl "\<def\>" nextgroup=rubyMethodDeclaration skipwhite skipnl 403 syn match rubyControl "\<def\>" nextgroup=rubyMethodDeclaration skipwhite skipnl
409 syn match rubyControl "\<class\>" nextgroup=rubyClassDeclaration skipwhite skipnl 404 syn match rubyControl "\<class\>" nextgroup=rubyClassDeclaration skipwhite skipnl
410 syn match rubyControl "\<module\>" nextgroup=rubyModuleDeclaration skipwhite skipnl 405 syn match rubyControl "\<module\>" nextgroup=rubyModuleDeclaration skipwhite skipnl
411 syn match rubyControl "\<\%(case\|begin\|do\|for\|if\|unless\|while\|until\|else\|elsif\|rescue\|ensure\|then\|when\|end\)\>" 406 syn match rubyControl "\<\%(case\|begin\|do\|for\|if\|unless\|while\|until\|else\|elsif\|rescue\|ensure\|then\|when\|end\)\>"
412 syn match rubyKeyword "\<\%(alias\|undef\)\>" 407 syn match rubyKeyword "\<\%(alias\|undef\)\>"
413 endif 408 endif
414 409
410 if !exists("ruby_minlines")
411 let ruby_minlines = 500
412 endif
413 exe "syn sync minlines=" . ruby_minlines
414
415 " Special Methods {{{1 415 " Special Methods {{{1
416 if !exists("ruby_no_special_methods") 416 if !exists("ruby_no_special_methods")
417 syn match rubyAccess "\<\%(public\|protected\|private\)\>" " use re=2 417 syn match rubyAccess "\<\%(public\|protected\|private\)\>" " use re=2
418 syn match rubyAccess "\%#=1\<\%(public\|private\)_class_method\>" 418 syn match rubyAccess "\%#=1\<\%(public\|private\)_class_method\>"
419 syn match rubyAccess "\%#=1\<\%(public\|private\)_constant\>" 419 syn match rubyAccess "\%#=1\<\%(public\|private\)_constant\>"
420 syn match rubyAccess "\%#=1\<module_function\>" 420 syn match rubyAccess "\%#=1\<module_function\>"
421 syn match rubyAttribute "\%#=1\%(\%(^\|;\)\s*\)\@<=attr\>\(\s*[.=]\)\@!" " attr is a common variable name 421 syn match rubyAttribute "\%#=1\%(\%(^\|;\)\s*\)\@<=attr\>\%(\s*[.=]\)\@!" " attr is a common variable name
422 syn match rubyAttribute "\%#=1\<attr_\%(accessor\|reader\|writer\)\>" 422 syn match rubyAttribute "\%#=1\<attr_\%(accessor\|reader\|writer\)\>"
423 syn match rubyControl "\%#=1\<\%(abort\|at_exit\|exit\|fork\|loop\|trap\)\>" 423 syn match rubyControl "\%#=1\<\%(abort\|at_exit\|exit\|fork\|loop\|trap\)\>"
424 syn match rubyEval "\%#=1\<eval\>" 424 syn match rubyEval "\%#=1\<eval\>"
425 syn match rubyEval "\%#=1\<\%(class\|instance\|module\)_eval\>" 425 syn match rubyEval "\%#=1\<\%(class\|instance\|module\)_eval\>"
426 syn match rubyException "\%#=1\<\%(raise\|fail\|catch\|throw\)\>" 426 syn match rubyException "\%#=1\<\%(raise\|fail\|catch\|throw\)\>"
433 " Comments and Documentation {{{1 433 " Comments and Documentation {{{1
434 syn match rubySharpBang "\%^#!.*" display 434 syn match rubySharpBang "\%^#!.*" display
435 syn keyword rubyTodo FIXME NOTE TODO OPTIMIZE HACK REVIEW XXX todo contained 435 syn keyword rubyTodo FIXME NOTE TODO OPTIMIZE HACK REVIEW XXX todo contained
436 syn match rubyEncoding "[[:alnum:]-_]\+" contained display 436 syn match rubyEncoding "[[:alnum:]-_]\+" contained display
437 syn match rubyMagicComment "\c\%<3l#\s*\zs\%(coding\|encoding\):" contained nextgroup=rubyEncoding skipwhite 437 syn match rubyMagicComment "\c\%<3l#\s*\zs\%(coding\|encoding\):" contained nextgroup=rubyEncoding skipwhite
438 syn match rubyMagicComment "\c\%<10l#\s*\zs\%(frozen_string_literal\|warn_indent\|warn_past_scope\):" contained nextgroup=rubyBoolean skipwhite 438 syn match rubyMagicComment "\c\%<10l#\s*\zs\%(frozen[-_]string[-_]literal\|warn[-_]indent\|warn[-_]past[-_]scope\):" contained nextgroup=rubyBoolean skipwhite
439 syn match rubyMagicComment "\c\%<10l#\s*\zs\%(shareable_constant_value\):" contained nextgroup=rubyEncoding skipwhite 439 syn match rubyMagicComment "\c\%<10l#\s*\zs\%(shareable[-_]constant[-_]value\):" contained nextgroup=rubyEncoding skipwhite
440 syn match rubyComment "#.*" contains=@rubyCommentSpecial,rubySpaceError,@Spell 440 syn match rubyComment "#.*" contains=@rubyCommentSpecial,rubySpaceError,@Spell
441 441
442 syn cluster rubyCommentSpecial contains=rubySharpBang,rubyTodo,rubyMagicComment 442 syn cluster rubyCommentSpecial contains=rubySharpBang,rubyTodo,rubyMagicComment
443 syn cluster rubyCommentNotTop contains=@rubyCommentSpecial,rubyEncoding 443 syn cluster rubyCommentNotTop contains=@rubyCommentSpecial,rubyEncoding
444 444