9292if s: path = ~# ' /app/controllers/.*\.rb$'
9393 syn keyword rubyHelper params request response session headers cookies flash
9494 syn keyword rubyMacro protect_from_forgery skip_forgery_protection http_basic_authenticate_with
95- syn match rubyMacro ' \< respond_to\ >\z e[( ] *[:*]'
96- syn match rubyResponse ' \< respond_to\ >\z e[( ] * \ % ([&{]\ | do\>\ )'
95+ syn match rubyMacro ' \v <respond_to>\z e[( ] *[:*]'
96+ syn match rubyResponse ' \v <respond_to>\z e + %([&{]|do> )'
9797 syn keyword rubyResponse render head redirect_to redirect_back respond_with send_data send_file
9898 syn keyword rubyResponse authenticate_or_request_with_http_basic authenticate_with_http_basic http_basic_authenticate_or_request_with request_http_basic_authentication
9999endif
@@ -108,8 +108,8 @@ endif
108108
109109if s: path = ~# ' /app/mailers/.*\.rb$\|/app/models/.*_mailer\.rb$'
110110 syn keyword rubyResponse mail render
111- syn match rubyResponse " \ < headers\> "
112- syn match rubyHelper " \ < headers\[\@ = "
111+ syn match rubyResponse ' \v <headers>[!?:]@! '
112+ syn match rubyHelper ' \v <headers\[ @= '
113113 syn keyword rubyHelper params attachments
114114 syn keyword rubyMacro default
115115 syn keyword rubyMacro register_interceptor register_interceptors register_observer register_observers
@@ -119,7 +119,7 @@ if s:path =~# '/app/\w\+/concerns/.*\.rb$'
119119 syn keyword rubyMacro included class_methods
120120endif
121121
122- if s: path = ~# ' \v/app/%(controllers|helpers|mailers)/.*\.rb$|/app/views/|/test/(controllers|integration|system)/.*_test\.rb$|/spec/(features|requests)/.*_spec\.rb'
122+ if s: path = ~# ' \v/app/%(controllers|helpers|mailers)/.*\.rb$|/app/views/|/test/(controllers|integration|system)/.*_test\.rb$|/spec/(features|requests)/.*_spec\.rb$ '
123123 syn keyword rubyUrlHelper url_for polymorphic_path polymorphic_url edit_polymorphic_path edit_polymorphic_url new_polymorphic_path new_polymorphic_url
124124endif
125125
@@ -136,7 +136,7 @@ if s:path =~# '/db/migrate/.*\.rb$\|/db/schema\.rb$'
136136endif
137137
138138if s: path = ~# ' \.rake$\|/Rakefile[^/]*$'
139- syn match rubyRakeMacro ' ^\s *\z s\ % (task\ | file\ | namespace\ | desc\)\>\% ( \s *= \)\ @ !'
139+ syn match rubyRakeMacro ' \v ^\s *\z s%(task|file|namespace|desc)>%([!?:]| \s *[=]) @!'
140140endif
141141
142142if s: path = ~# ' /config/routes\>.*\.rb$'
@@ -159,9 +159,9 @@ if s:path =~# '/test\%(/\|/.*/\)test_[^\/]*\.rb$\|/test/.*_test\.rb$\|/features/
159159endif
160160
161161if s: path = ~# ' /spec/.*_spec\.rb$'
162- syn match rubyTestHelper ' \< subject\> '
163- syn match rubyTestMacro ' \<\ % (let\ | given\)\> ! \= '
164- syn match rubyTestMacro ' \< subject\> ! \ =\z e\s *\% ([( {&:]\| do\>\ ) '
162+ syn match rubyTestHelper ' \v <subject>[!?:]@! '
163+ syn match rubyTestMacro ' \v < %(let|given)!=[[:keyword:]!?:]@! '
164+ syn match rubyTestMacro ' \v <subject>! =\z e%( \s *[(]| \s +[ {&:]| \s + do\> )'
165165 syn keyword rubyTestMacro before after around background setup teardown
166166 syn keyword rubyTestMacro context describe feature shared_context shared_examples shared_examples_for containedin =rubyKeywordAsMethod
167167 syn keyword rubyTestMacro it example specify scenario include_examples include_context it_should_behave_like it_behaves_like
@@ -180,7 +180,7 @@ endif
180180
181181if s: path = ~# ' \v/test/%(channels|controllers|helpers|integration|mailers|models|system)/.*_test\.rb$'
182182 if s: has_app && ! empty (rails#app ().user_assertions ())
183- exe " syn keyword rubyUserAssertion " . join (rails#app ().user_assertions ())
183+ exe " syn match rubyUserAssertion ' \\ v<%( " . escape ( join (rails#app ().user_assertions (), ' | ' ), ' ? ' ) . " )[[:keyword:]?!:]@!' "
184184 endif
185185 syn keyword rubyTestMacro test setup teardown
186186 syn keyword rubyAssertion assert_difference assert_no_difference
@@ -205,16 +205,16 @@ if s:path =~# '/test/system/.*_test\.rb$' ||
205205 syn keyword rubyAssertion refute_button refute_checked_field refute_content refute_css refute_current_path refute_field refute_link refute_select refute_selector refute_table refute_text refute_title refute_unchecked_field refute_xpath
206206endif
207207
208- if s: path = ~# ' /spec/controllers/.*_spec.rb'
208+ if s: path = ~# ' /spec/controllers/.*_spec\ .rb$ '
209209 syn keyword rubyTestMacro render_views
210210 syn keyword rubyTestHelper assigns
211211endif
212- if s: path = ~# ' /spec/helpers/.*_spec.rb'
212+ if s: path = ~# ' /spec/helpers/.*_spec\ .rb$ '
213213 syn keyword rubyTestAction assign
214- syn match rubyTestHelper ' \< helper\> '
215- syn match rubyTestMacro ' \< helper\> ! \ =\z e\s *\% ([( {&:]\| do\>\ ) '
214+ syn match rubyTestHelper ' \v <helper>[!?:]@! '
215+ syn match rubyTestMacro ' \v <helper>! =\z e%( \s *[(]| \s +[ {&:]| \s + do\> )'
216216endif
217- if s: path = ~# ' /spec/views/.*_spec.rb'
217+ if s: path = ~# ' /spec/views/.*_spec\ .rb$ '
218218 syn keyword rubyTestAction assign render
219219 syn keyword rubyTestHelper rendered
220220endif
@@ -224,8 +224,8 @@ if s:has_app && rails#buffer().type_name('test', 'spec')
224224 syn keyword rubyTestHelper file_fixture
225225endif
226226if s: path = ~# ' \v/test/%(controllers|integration)/.*_test\.rb$|/spec/%(controllers|requests)/.*_spec\.rb$'
227- syn match rubyTestAction ' \.\ @ <!\<\ % (get\ | post\ | put\ | patch\ | delete\ | head\ | process\)\> '
228- syn match rubyTestAction ' \< follow_redirect!'
227+ syn match rubyTestAction ' \v\. @<!< %(get|post|put|patch|delete|head|process)>[?!:]@! '
228+ syn match rubyTestAction ' \v <follow_redirect![[:keyword:]!?:]@ !'
229229 syn keyword rubyTestAction get_via_redirect post_via_redirect
230230 syn keyword rubyTestHelper request response flash session cookies fixture_file_upload
231231endif
@@ -235,7 +235,7 @@ if s:path =~# '/test/system/.*_test\.rb$\|/spec/features/.*_spec\.rb$' ||
235235 syn keyword rubyTestHelper page text
236236 syn keyword rubyTestHelper all field_labeled find find_all find_button find_by_id find_field find_link first
237237 syn keyword rubyTestAction evaluate_script execute_script go_back go_forward open_new_window save_and_open_page save_and_open_screenshot save_page save_screenshot switch_to_frame switch_to_window visit window_opened_by within within_element within_fieldset within_frame within_table within_window
238- syn match rubyTestAction " \ < reset_session!"
238+ syn match rubyTestAction ' \v <reset_session![[:keyword:]!?:]@! '
239239 syn keyword rubyTestAction attach_file check choose click_button click_link click_link_or_button click_on fill_in select uncheck unselect
240240endif
241241
@@ -260,7 +260,7 @@ function! s:highlight(group, ...) abort
260260 call filter (words, ' type(v:val) == type("") && v:val =~# '' ^\h\k*[!?]\=[][{}]\=$'' ' )
261261 if ! empty (words)
262262 exe ' syn match' a: group substitute (
263- \ ' "\<\%(' .join (words, ' \|' ).' \)\%(\k\@<!\|\k\@!: \@!\) "' ,
263+ \ ' "\<\%(' .join (words, ' \|' ).' \)[[:keyword:]!?:] \@!"' ,
264264 \ ' [][{}]' , ' \=get(s:special, submatch(0), submatch(0))' , ' g' )
265265 endif
266266endfunction
0 commit comments