changeset 33098:d3d82d3f6006

runtime(ruby): Update syntax, indent and ftplugin files Commit: https://github.com/vim/vim/commit/da16a1b471aa717f58909cc6531cb6dbbff14d22 Author: Doug Kearns <dougkearns@gmail.com> Date: Fri Sep 1 18:33:33 2023 +0200 runtime(ruby): Update syntax, indent and ftplugin files While making changes to the ruby ftplugin, slightly change the exepath() conditional from patch 9.0.1833 and move it after the :cd invocation. closes: 12981 closes: 12994 Signed-off-by: Christian Brabandt <cb@256bit.org> Co-authored-by: Tim Pope <code@tpope.net> Co-authored-by: Doug Kearns <dougkearns@gmail.com>
author Christian Brabandt <cb@256bit.org>
date Fri, 01 Sep 2023 18:45:05 +0200
parents 586944b27d2a
children 49f317597430
files runtime/ftplugin/eruby.vim runtime/ftplugin/ruby.vim runtime/indent/ruby.vim runtime/syntax/ruby.vim
diffstat 4 files changed, 58 insertions(+), 60 deletions(-) [+]
line wrap: on
line diff
--- a/runtime/ftplugin/eruby.vim
+++ b/runtime/ftplugin/eruby.vim
@@ -3,7 +3,7 @@
 " Maintainer:		Tim Pope <vimNOSPAM@tpope.org>
 " URL:			https://github.com/vim-ruby/vim-ruby
 " Release Coordinator:	Doug Kearns <dougkearns@gmail.com>
-" Last Change:		2020 Jun 28
+" Last Change:		2022 May 15
 
 " Only do this when not done yet for this buffer
 if exists("b:did_ftplugin")
@@ -86,8 +86,12 @@ runtime! ftplugin/ruby.vim ftplugin/ruby
 let b:did_ftplugin = 1
 
 " Combine the new set of values with those previously included.
-if exists("b:undo_ftplugin")
-  let s:undo_ftplugin = b:undo_ftplugin . " | " . s:undo_ftplugin
+if !exists('b:undo_ftplugin')
+  " No-op
+  let b:undo_ftplugin = 'exe'
+endif
+if !empty(s:undo_ftplugin)
+  let b:undo_ftplugin .= '|' . s:undo_ftplugin
 endif
 if exists ("b:browsefilter")
   let s:browsefilter = substitute(b:browsefilter,'\cAll Files (\*\.\*)\t\*\.\*\n','','') . s:browsefilter
@@ -119,7 +123,7 @@ endif
 setlocal commentstring=<%#%s%>
 
 let b:undo_ftplugin = "setl cms< " .
-      \ " | unlet! b:browsefilter b:match_words | " . s:undo_ftplugin
+      \ " | unlet! b:browsefilter b:match_words | " . b:undo_ftplugin
 
 let &cpo = s:save_cpo
 unlet s:save_cpo
--- a/runtime/ftplugin/ruby.vim
+++ b/runtime/ftplugin/ruby.vim
@@ -3,7 +3,7 @@
 " Maintainer:		Tim Pope <vimNOSPAM@tpope.org>
 " URL:			https://github.com/vim-ruby/vim-ruby
 " Release Coordinator:	Doug Kearns <dougkearns@gmail.com>
-" Last Change:		2022 Mar 21
+" Last Change:		2023 Sep 1st
 
 if (exists("b:did_ftplugin"))
   finish
@@ -77,7 +77,11 @@ function! s:query_path(root) abort
   let cwd = fnameescape(getcwd())
   try
     exe cd fnameescape(a:root)
-    let path = split(system(path_check),',')
+    if fnamemodify(exepath('ruby'), ':p:h') ==# getcwd()
+      let path = []
+    else
+      let path = split(system(path_check),',')
+    endif
     exe cd cwd
     return path
   finally
@@ -99,51 +103,41 @@ function! s:build_path(path) abort
   return path
 endfunction
 
-let s:execute_ruby = 1
-" Security Check, don't execute ruby from the current directory
-if fnamemodify(exepath("ruby"), ":p:h") ==# getcwd()
-  let s:execute_ruby = 0
-endif
-
-function SetRubyPath()
-  if !exists('b:ruby_version') && !exists('g:ruby_path') && isdirectory(expand('%:p:h'))
-    let s:version_file = findfile('.ruby-version', '.;')
-    if !empty(s:version_file) && filereadable(s:version_file) && s:execute_ruby
-      let b:ruby_version = get(readfile(s:version_file, '', 1), '')
-      if !has_key(g:ruby_version_paths, b:ruby_version)
-	let g:ruby_version_paths[b:ruby_version] = s:query_path(fnamemodify(s:version_file, ':p:h'))
-      endif
+if !exists('b:ruby_version') && !exists('g:ruby_path') && isdirectory(expand('%:p:h'))
+  let s:version_file = findfile('.ruby-version', '.;')
+  if !empty(s:version_file) && filereadable(s:version_file)
+    let b:ruby_version = get(readfile(s:version_file, '', 1), '')
+    if !has_key(g:ruby_version_paths, b:ruby_version)
+      let g:ruby_version_paths[b:ruby_version] = s:query_path(fnamemodify(s:version_file, ':p:h'))
     endif
   endif
+endif
 
-  if exists("g:ruby_path")
-    let s:ruby_path = type(g:ruby_path) == type([]) ? join(g:ruby_path, ',') : g:ruby_path
-  elseif has_key(g:ruby_version_paths, get(b:, 'ruby_version', '')) && s:execute_ruby
-    let s:ruby_paths = g:ruby_version_paths[b:ruby_version]
-    let s:ruby_path = s:build_path(s:ruby_paths)
-  else
-    if !exists('g:ruby_default_path')
-      if has("ruby") && has("win32")
-	ruby ::VIM::command( 'let g:ruby_default_path = split("%s",",")' % $:.join(%q{,}) )
-      elseif executable('ruby') && !empty($HOME) && s:execute_ruby
-	let g:ruby_default_path = s:query_path($HOME)
-      else
-	let g:ruby_default_path = map(split($RUBYLIB,':'), 'v:val ==# "." ? "" : v:val')
-      endif
+if exists("g:ruby_path")
+  let s:ruby_path = type(g:ruby_path) == type([]) ? join(g:ruby_path, ',') : g:ruby_path
+elseif has_key(g:ruby_version_paths, get(b:, 'ruby_version', ''))
+  let s:ruby_paths = g:ruby_version_paths[b:ruby_version]
+  let s:ruby_path = s:build_path(s:ruby_paths)
+else
+  if !exists('g:ruby_default_path')
+    if has("ruby") && has("win32")
+      ruby ::VIM::command( 'let g:ruby_default_path = split("%s",",")' % $:.join(%q{,}) )
+    elseif executable('ruby') && !empty($HOME)
+      let g:ruby_default_path = s:query_path($HOME)
+    else
+      let g:ruby_default_path = map(split($RUBYLIB,':'), 'v:val ==# "." ? "" : v:val')
     endif
-    let s:ruby_paths = g:ruby_default_path
-    let s:ruby_path = s:build_path(s:ruby_paths)
   endif
+  let s:ruby_paths = g:ruby_default_path
+  let s:ruby_path = s:build_path(s:ruby_paths)
+endif
 
-  if stridx(&l:path, s:ruby_path) == -1
-    let &l:path = s:ruby_path
-  endif
-  if exists('s:ruby_paths') && stridx(&l:tags, join(map(copy(s:ruby_paths),'v:val."/tags"'),',')) == -1
-    let &l:tags = &tags . ',' . join(map(copy(s:ruby_paths),'v:val."/tags"'),',')
-  endif
-endfunction
-
-call SetRubyPath()
+if stridx(&l:path, s:ruby_path) == -1
+  let &l:path = s:ruby_path
+endif
+if exists('s:ruby_paths') && stridx(&l:tags, join(map(copy(s:ruby_paths),'v:val."/tags"'),',')) == -1
+  let &l:tags = &tags . ',' . join(map(copy(s:ruby_paths),'v:val."/tags"'),',')
+endif
 
 if (has("gui_win32") || has("gui_gtk")) && !exists("b:browsefilter")
   let b:browsefilter = "Ruby Source Files (*.rb)\t*.rb\n" .
--- a/runtime/indent/ruby.vim
+++ b/runtime/indent/ruby.vim
@@ -4,7 +4,7 @@
 " Previous Maintainer:	Nikolai Weibull <now at bitwi.se>
 " URL:			https://github.com/vim-ruby/vim-ruby
 " Release Coordinator:	Doug Kearns <dougkearns@gmail.com>
-" Last Change:		2022 Mar 22
+" Last Change:		2022 Jun 30
 
 " 0. Initialization {{{1
 " =================
@@ -93,7 +93,7 @@ let s:ruby_indent_keywords =
       \    '\<\%(if\|for\|while\|until\|case\|unless\|begin\):\@!\>'
 
 " Def without an end clause: def method_call(...) = <expression>
-let s:ruby_endless_def = '\<def\s\+\k\+[!?]\=\%((.*)\|\s\)\s*='
+let s:ruby_endless_def = '\<def\s\+\%(\k\+\.\)\=\k\+[!?]\=\%((.*)\|\s\)\s*='
 
 " Regex used for words that, at the start of a line, remove a level of indent.
 let s:ruby_deindent_keywords =
--- a/runtime/syntax/ruby.vim
+++ b/runtime/syntax/ruby.vim
@@ -3,7 +3,7 @@
 " Maintainer:		Doug Kearns <dougkearns@gmail.com>
 " URL:			https://github.com/vim-ruby/vim-ruby
 " Release Coordinator:	Doug Kearns <dougkearns@gmail.com>
-" Last Change:		2021 Nov 03
+" Last Change:		2023 Mar 16
 " ----------------------------------------------------------------------------
 "
 " Previous Maintainer:	Mirko Nasato
@@ -145,9 +145,9 @@ syn cluster rubyStringSpecial	 contains=
 syn cluster rubyStringNotTop	 contains=@rubyStringSpecial,@rubyNestedBrackets,@rubySingleCharEscape
 
 " Regular Expression Metacharacters {{{1
-syn region rubyRegexpComment	  matchgroup=rubyRegexpSpecial	 start="(?#"								    skip="\\\\\|\\)"  end=")"  contained
-syn region rubyRegexpParens	  matchgroup=rubyRegexpSpecial	 start="(\(?:\|?<\=[=!]\|?>\|?<[a-z_]\w*>\|?[imx]*-[imx]*:\=\|\%(?#\)\@!\)" skip="\\\\\|\\)"  end=")"  contained transparent contains=@rubyRegexpSpecial
-syn region rubyRegexpBrackets	  matchgroup=rubyRegexpCharClass start="\[\^\="								    skip="\\\\\|\\\]" end="\]" contained transparent contains=rubyRegexpBrackets,rubyStringEscape,rubyRegexpEscape,rubyRegexpCharClass,rubyRegexpIntersection oneline
+syn region rubyRegexpComment	  matchgroup=rubyRegexpSpecial	 start="(?#"								     skip="\\\\\|\\)"  end=")"	contained
+syn region rubyRegexpParens	  matchgroup=rubyRegexpSpecial	 start="(\%(?:\|?<\=[=!]\|?>\|?<[a-z_]\w*>\|?[imx]*-[imx]*:\=\|\%(?#\)\@!\)" skip="\\\\\|\\)"  end=")"	contained transparent contains=@rubyRegexpSpecial
+syn region rubyRegexpBrackets	  matchgroup=rubyRegexpCharClass start="\[\^\="								     skip="\\\\\|\\\]" end="\]" contained transparent contains=rubyRegexpBrackets,rubyStringEscape,rubyRegexpEscape,rubyRegexpCharClass,rubyRegexpIntersection oneline
 syn match  rubyRegexpCharClass	  "\\[DdHhRSsWw]"	 contained display
 syn match  rubyRegexpCharClass	  "\[:\^\=\%(alnum\|alpha\|ascii\|blank\|cntrl\|digit\|graph\|lower\|print\|punct\|space\|upper\|word\|xdigit\):\]" contained
 syn match  rubyRegexpCharClass	  "\\[pP]{^\=.\{-}}"	 contained display
@@ -346,7 +346,7 @@ syn cluster rubyDeclaration contains=rub
 syn match rubyControl	     "\%#=1\<\%(break\|in\|next\|redo\|retry\|return\)\>"
 syn match rubyKeyword	     "\%#=1\<\%(super\|yield\)\>"
 syn match rubyBoolean	     "\%#=1\<\%(true\|false\)\>[?!]\@!"
-syn match rubyPseudoVariable "\%#=1\<\(self\|nil\)\>[?!]\@!"
+syn match rubyPseudoVariable "\%#=1\<\%(self\|nil\)\>[?!]\@!"
 syn match rubyPseudoVariable "\%#=1\<__\%(ENCODING\|dir\|FILE\|LINE\|callee\|method\)__\>"
 syn match rubyBeginEnd	     "\%#=1\<\%(BEGIN\|END\)\>"
 
@@ -399,11 +399,6 @@ if !exists("b:ruby_no_expensive") && !ex
 
   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
 
-  if !exists("ruby_minlines")
-    let ruby_minlines = 500
-  endif
-  exe "syn sync minlines=" . ruby_minlines
-
 else
   syn match rubyControl "\<def\>"    nextgroup=rubyMethodDeclaration skipwhite skipnl
   syn match rubyControl "\<class\>"  nextgroup=rubyClassDeclaration  skipwhite skipnl
@@ -412,13 +407,18 @@ else
   syn match rubyKeyword "\<\%(alias\|undef\)\>"
 endif
 
+if !exists("ruby_minlines")
+  let ruby_minlines = 500
+endif
+exe "syn sync minlines=" . ruby_minlines
+
 " Special Methods {{{1
 if !exists("ruby_no_special_methods")
   syn match rubyAccess	  "\<\%(public\|protected\|private\)\>" " use re=2
   syn match rubyAccess	  "\%#=1\<\%(public\|private\)_class_method\>"
   syn match rubyAccess	  "\%#=1\<\%(public\|private\)_constant\>"
   syn match rubyAccess	  "\%#=1\<module_function\>"
-  syn match rubyAttribute "\%#=1\%(\%(^\|;\)\s*\)\@<=attr\>\(\s*[.=]\)\@!" " attr is a common variable name
+  syn match rubyAttribute "\%#=1\%(\%(^\|;\)\s*\)\@<=attr\>\%(\s*[.=]\)\@!" " attr is a common variable name
   syn match rubyAttribute "\%#=1\<attr_\%(accessor\|reader\|writer\)\>"
   syn match rubyControl   "\%#=1\<\%(abort\|at_exit\|exit\|fork\|loop\|trap\)\>"
   syn match rubyEval	  "\%#=1\<eval\>"
@@ -435,8 +435,8 @@ syn match   rubySharpBang    "\%^#!.*" d
 syn keyword rubyTodo	     FIXME NOTE TODO OPTIMIZE HACK REVIEW XXX todo contained
 syn match   rubyEncoding     "[[:alnum:]-_]\+" contained display
 syn match   rubyMagicComment "\c\%<3l#\s*\zs\%(coding\|encoding\):"					contained nextgroup=rubyEncoding skipwhite
-syn match   rubyMagicComment "\c\%<10l#\s*\zs\%(frozen_string_literal\|warn_indent\|warn_past_scope\):" contained nextgroup=rubyBoolean  skipwhite
-syn match   rubyMagicComment "\c\%<10l#\s*\zs\%(shareable_constant_value\):"				contained nextgroup=rubyEncoding  skipwhite
+syn match   rubyMagicComment "\c\%<10l#\s*\zs\%(frozen[-_]string[-_]literal\|warn[-_]indent\|warn[-_]past[-_]scope\):" contained nextgroup=rubyBoolean  skipwhite
+syn match   rubyMagicComment "\c\%<10l#\s*\zs\%(shareable[-_]constant[-_]value\):"				contained nextgroup=rubyEncoding  skipwhite
 syn match   rubyComment	     "#.*" contains=@rubyCommentSpecial,rubySpaceError,@Spell
 
 syn cluster rubyCommentSpecial contains=rubySharpBang,rubyTodo,rubyMagicComment