Skip to content

Commit eec4d89

Browse files
committed
Add new syntax groups for percent literal delimiters
Also adds a new heredoc delimiter group. Fixes #135.
1 parent d3bb65a commit eec4d89

3 files changed

Lines changed: 77 additions & 60 deletions

File tree

ftplugin/ruby.vim

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,8 @@ if exists("loaded_matchit") && !exists("b:match_words")
3232

3333
let b:match_skip =
3434
\ "synIDattr(synID(line('.'),col('.'),0),'name') =~ '" .
35-
\ "\\<ruby\\%(String\\|StringDelimiter\\|Character\\|Escape\\|" .
36-
\ "Regexp\\|RegexpDelimiter\\|" .
37-
\ "Interpolation\\|Comment\\|Documentation\\|" .
35+
\ "\\<ruby\\%(String\\|.\+Delimiter\\|Character\\|.\+Escape\\|" .
36+
\ "Regexp\\|Interpolation\\|Comment\\|Documentation\\|" .
3837
\ "ConditionalModifier\\|RepeatModifier\\|RescueModifier\\|OptionalDo\\|" .
3938
\ "Function\\|BlockArgument\\|KeywordAsMethod\\|ClassVariable\\|" .
4039
\ "InstanceVariable\\|GlobalVariable\\|Symbol\\)\\>'"

indent/ruby.vim

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,20 @@ let s:syng_string =
5656
let s:syng_stringdoc = s:syng_string + ['Documentation']
5757

5858
" Syntax group names that are or delimit strings/symbols/regexes or are comments.
59-
let s:syng_strcom = s:syng_stringdoc +
60-
\ ['Regexp', 'RegexpDelimiter', 'RegexpEscape',
61-
\ 'Symbol', 'StringDelimiter', 'Character', 'Comment']
59+
let s:syng_strcom = s:syng_stringdoc + [
60+
\ 'Character',
61+
\ 'Comment'
62+
\ 'HeredocDelimiter',
63+
\ 'PercentRegexpDelimiter',
64+
\ 'PercentStringDelimiter',
65+
\ 'PercentSymbolDelimiter',
66+
\ 'Regexp',
67+
\ 'RegexpDelimiter',
68+
\ 'RegexpEscape',
69+
\ 'StringDelimiter',
70+
\ 'Symbol',
71+
\ 'SymbolDelimiter',
72+
\ ]
6273

6374
" Expression used to check whether we should skip a match with searchpair().
6475
let s:skip_expr =
@@ -694,7 +705,10 @@ endfunction
694705

695706
" Check if the character at lnum:col is inside a string delimiter
696707
function! s:IsInStringDelimiter(lnum, col) abort
697-
return s:IsInRubyGroup(['StringDelimiter'], a:lnum, a:col)
708+
return s:IsInRubyGroup(
709+
\ ['HeredocDelimiter', 'PercentStringDelimiter', 'StringDelimiter'],
710+
\ a:lnum, a:col
711+
\ )
698712
endfunction
699713

700714
function! s:IsAssignment(str, pos) abort

0 commit comments

Comments
 (0)