Skip to content

Instantly share code, notes, and snippets.

@shirosaki
Created June 12, 2013 13:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shirosaki/5765418 to your computer and use it in GitHub Desktop.
Save shirosaki/5765418 to your computer and use it in GitHub Desktop.
Fix performance of ruby syntax for new regexp engine
diff --git a/syntax/ruby.vim b/syntax/ruby.vim
index e4bc98f..dac2d1a 100644
--- a/syntax/ruby.vim
+++ b/syntax/ruby.vim
@@ -117,10 +117,7 @@ syn match rubyPredefinedVariable "$_\>" display
syn match rubyPredefinedVariable "$-[0FIKadilpvw]\>" display
syn match rubyPredefinedVariable "$\%(deferr\|defout\|stderr\|stdin\|stdout\)\>" display
syn match rubyPredefinedVariable "$\%(DEBUG\|FILENAME\|KCODE\|LOADED_FEATURES\|LOAD_PATH\|PROGRAM_NAME\|SAFE\|VERBOSE\)\>" display
-syn match rubyPredefinedConstant "\%(\%(\.\@<!\.\)\@<!\|::\)\_s*\zs\%(MatchingData\|ARGF\|ARGV\|ENV\)\>\%(\s*(\)\@!"
-syn match rubyPredefinedConstant "\%(\%(\.\@<!\.\)\@<!\|::\)\_s*\zs\%(DATA\|FALSE\|NIL\)\>\%(\s*(\)\@!"
-syn match rubyPredefinedConstant "\%(\%(\.\@<!\.\)\@<!\|::\)\_s*\zs\%(STDERR\|STDIN\|STDOUT\|TOPLEVEL_BINDING\|TRUE\)\>\%(\s*(\)\@!"
-syn match rubyPredefinedConstant "\%(\%(\.\@<!\.\)\@<!\|::\)\_s*\zs\%(RUBY_\%(VERSION\|RELEASE_DATE\|PLATFORM\|PATCHLEVEL\|REVISION\|DESCRIPTION\|COPYRIGHT\|ENGINE\)\)\>\%(\s*(\)\@!"
+syn match rubyPredefinedConstant "\%([^.]\.\_s*\)\@<!\%(MatchingData\|ARG\(F\|V\)\|ENV\|DATA\|FALSE\|NIL\|STD\(ERR\|IN\|OUT\)\|TOPLEVEL_BINDING\|TRUE\|RUBY_\%(VERSION\|RELEASE_DATE\|PLATFORM\|PATCHLEVEL\|REVISION\|DESCRIPTION\|COPYRIGHT\|ENGINE\)\)\>\%(\s*(\)\@!"
" Normal Regular Expression
syn region rubyRegexp matchgroup=rubyRegexpDelimiter start="\%(\%(^\|\<\%(and\|or\|while\|until\|unless\|if\|elsif\|when\|not\|then\|else\)\|[;\~=!|&(,[<>?:*+-]\)\s*\)\@<=/" end="/[iomxneus]*" skip="\\\\\|\\/" contains=@rubyRegexpSpecial fold
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment