@@ -47,22 +47,21 @@ set cpo&vim
4747" 1. Variables {{{1
4848" ============
4949
50- " Regex of syntax group names that are or delimit strings/symbols or are comments.
51- let s: syng_strcom = ' \<ruby\%(Regexp\|RegexpDelimiter\|RegexpEscape' .
52- \ ' \|Symbol\|String\|StringDelimiter\|StringEscape\|ASCIICode' .
53- \ ' \|Interpolation\|InterpolationDelimiter\|NoInterpolation\|Comment\|Documentation\)\>'
54-
55- " Regex of syntax group names that are strings.
50+ " Syntax group names that are strings.
5651let s: syng_string =
57- \ ' \<ruby\%(String\|Interpolation\|InterpolationDelimiter\|NoInterpolation\|StringEscape\)\>'
52+ \ [' String' , ' Interpolation' , ' InterpolationDelimiter' , ' NoInterpolation' , ' StringEscape' ]
53+
54+ " Syntax group names that are strings or documentation.
55+ let s: syng_stringdoc = s: syng_string + [' Documentation' ]
5856
59- " Regex of syntax group names that are strings or documentation.
60- let s: syng_stringdoc =
61- \ ' \<ruby\%(String\|Interpolation\|InterpolationDelimiter\|NoInterpolation\|StringEscape\|Documentation\)\>'
57+ " Syntax group names that are or delimit strings/symbols/regexes or are comments.
58+ let s: syng_strcom = s: syng_stringdoc +
59+ \ [' Regexp' , ' RegexpDelimiter' , ' RegexpEscape' ,
60+ \ ' Symbol' , ' StringDelimiter' , ' ASCIICode' , ' Comment' ]
6261
6362" Expression used to check whether we should skip a match with searchpair().
6463let s: skip_expr =
65- \ " synIDattr( synID(line('.' ),col('.' ),1),'name') =~ ' " . s: syng_strcom . " ' "
64+ \ ' index(map( ' . string ( s: syng_strcom ). ' ,"hlID( '' ruby '' .v:val)"), synID(line("." ),col("." ),1)) >= 0 '
6665
6766" Regex used for words that, at the start of a line, add a level of indent.
6867let s: ruby_indent_keywords =
@@ -650,24 +649,29 @@ endfunction
650649" 4. Auxiliary Functions {{{1
651650" ======================
652651
652+ function ! s: IsInRubyGroup (groups, lnum, col ) abort
653+ let ids = map (copy (a: groups ), ' hlID("ruby".v:val)' )
654+ return index (ids, synID (a: lnum , a: col , 1 )) >= 0
655+ endfunction
656+
653657" Check if the character at lnum:col is inside a string, comment, or is ascii.
654658function ! s: IsInStringOrComment (lnum, col ) abort
655- return synIDattr ( synID ( a: lnum , a: col, 1 ), ' name ' ) = ~ s: syng_strcom
659+ return s: IsInRubyGroup ( s: syng_strcom , a: lnum , a: col)
656660endfunction
657661
658662" Check if the character at lnum:col is inside a string.
659663function ! s: IsInString (lnum, col ) abort
660- return synIDattr ( synID ( a: lnum , a: col, 1 ), ' name ' ) = ~ s: syng_string
664+ return s: IsInRubyGroup ( s: syng_string , a: lnum , a: col)
661665endfunction
662666
663667" Check if the character at lnum:col is inside a string or documentation.
664668function ! s: IsInStringOrDocumentation (lnum, col ) abort
665- return synIDattr ( synID ( a: lnum , a: col, 1 ), ' name ' ) = ~ s: syng_stringdoc
669+ return s: IsInRubyGroup ( s: syng_stringdoc , a: lnum , a: col)
666670endfunction
667671
668672" Check if the character at lnum:col is inside a string delimiter
669673function ! s: IsInStringDelimiter (lnum, col ) abort
670- return synIDattr ( synID ( a: lnum , a: col, 1 ), ' name ' ) == ' rubyStringDelimiter '
674+ return s: IsInRubyGroup ([ ' StringDelimiter ' ], a: lnum , a: col)
671675endfunction
672676
673677function ! s: IsAssignment (str, pos) abort
0 commit comments