comparison runtime/ftplugin/ruby.vim @ 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 828bcb1a37e7
children 01c803103fa9
comparison
equal deleted inserted replaced
33097:586944b27d2a 33098:d3d82d3f6006
1 " Vim filetype plugin 1 " Vim filetype plugin
2 " Language: Ruby 2 " Language: Ruby
3 " Maintainer: Tim Pope <vimNOSPAM@tpope.org> 3 " Maintainer: Tim Pope <vimNOSPAM@tpope.org>
4 " URL: https://github.com/vim-ruby/vim-ruby 4 " URL: https://github.com/vim-ruby/vim-ruby
5 " Release Coordinator: Doug Kearns <dougkearns@gmail.com> 5 " Release Coordinator: Doug Kearns <dougkearns@gmail.com>
6 " Last Change: 2022 Mar 21 6 " Last Change: 2023 Sep 1st
7 7
8 if (exists("b:did_ftplugin")) 8 if (exists("b:did_ftplugin"))
9 finish 9 finish
10 endif 10 endif
11 let b:did_ftplugin = 1 11 let b:did_ftplugin = 1
75 75
76 let cd = haslocaldir() ? 'lcd' : 'cd' 76 let cd = haslocaldir() ? 'lcd' : 'cd'
77 let cwd = fnameescape(getcwd()) 77 let cwd = fnameescape(getcwd())
78 try 78 try
79 exe cd fnameescape(a:root) 79 exe cd fnameescape(a:root)
80 let path = split(system(path_check),',') 80 if fnamemodify(exepath('ruby'), ':p:h') ==# getcwd()
81 let path = []
82 else
83 let path = split(system(path_check),',')
84 endif
81 exe cd cwd 85 exe cd cwd
82 return path 86 return path
83 finally 87 finally
84 exe cd cwd 88 exe cd cwd
85 endtry 89 endtry
97 let path = substitute(&g:path, '[^,]\zs$', ',', '') . path 101 let path = substitute(&g:path, '[^,]\zs$', ',', '') . path
98 endif 102 endif
99 return path 103 return path
100 endfunction 104 endfunction
101 105
102 let s:execute_ruby = 1 106 if !exists('b:ruby_version') && !exists('g:ruby_path') && isdirectory(expand('%:p:h'))
103 " Security Check, don't execute ruby from the current directory 107 let s:version_file = findfile('.ruby-version', '.;')
104 if fnamemodify(exepath("ruby"), ":p:h") ==# getcwd() 108 if !empty(s:version_file) && filereadable(s:version_file)
105 let s:execute_ruby = 0 109 let b:ruby_version = get(readfile(s:version_file, '', 1), '')
106 endif 110 if !has_key(g:ruby_version_paths, b:ruby_version)
107 111 let g:ruby_version_paths[b:ruby_version] = s:query_path(fnamemodify(s:version_file, ':p:h'))
108 function SetRubyPath() 112 endif
109 if !exists('b:ruby_version') && !exists('g:ruby_path') && isdirectory(expand('%:p:h')) 113 endif
110 let s:version_file = findfile('.ruby-version', '.;') 114 endif
111 if !empty(s:version_file) && filereadable(s:version_file) && s:execute_ruby 115
112 let b:ruby_version = get(readfile(s:version_file, '', 1), '') 116 if exists("g:ruby_path")
113 if !has_key(g:ruby_version_paths, b:ruby_version) 117 let s:ruby_path = type(g:ruby_path) == type([]) ? join(g:ruby_path, ',') : g:ruby_path
114 let g:ruby_version_paths[b:ruby_version] = s:query_path(fnamemodify(s:version_file, ':p:h')) 118 elseif has_key(g:ruby_version_paths, get(b:, 'ruby_version', ''))
115 endif 119 let s:ruby_paths = g:ruby_version_paths[b:ruby_version]
116 endif 120 let s:ruby_path = s:build_path(s:ruby_paths)
117 endif 121 else
118 122 if !exists('g:ruby_default_path')
119 if exists("g:ruby_path") 123 if has("ruby") && has("win32")
120 let s:ruby_path = type(g:ruby_path) == type([]) ? join(g:ruby_path, ',') : g:ruby_path 124 ruby ::VIM::command( 'let g:ruby_default_path = split("%s",",")' % $:.join(%q{,}) )
121 elseif has_key(g:ruby_version_paths, get(b:, 'ruby_version', '')) && s:execute_ruby 125 elseif executable('ruby') && !empty($HOME)
122 let s:ruby_paths = g:ruby_version_paths[b:ruby_version] 126 let g:ruby_default_path = s:query_path($HOME)
123 let s:ruby_path = s:build_path(s:ruby_paths) 127 else
124 else 128 let g:ruby_default_path = map(split($RUBYLIB,':'), 'v:val ==# "." ? "" : v:val')
125 if !exists('g:ruby_default_path') 129 endif
126 if has("ruby") && has("win32") 130 endif
127 ruby ::VIM::command( 'let g:ruby_default_path = split("%s",",")' % $:.join(%q{,}) ) 131 let s:ruby_paths = g:ruby_default_path
128 elseif executable('ruby') && !empty($HOME) && s:execute_ruby 132 let s:ruby_path = s:build_path(s:ruby_paths)
129 let g:ruby_default_path = s:query_path($HOME) 133 endif
130 else 134
131 let g:ruby_default_path = map(split($RUBYLIB,':'), 'v:val ==# "." ? "" : v:val') 135 if stridx(&l:path, s:ruby_path) == -1
132 endif 136 let &l:path = s:ruby_path
133 endif 137 endif
134 let s:ruby_paths = g:ruby_default_path 138 if exists('s:ruby_paths') && stridx(&l:tags, join(map(copy(s:ruby_paths),'v:val."/tags"'),',')) == -1
135 let s:ruby_path = s:build_path(s:ruby_paths) 139 let &l:tags = &tags . ',' . join(map(copy(s:ruby_paths),'v:val."/tags"'),',')
136 endif 140 endif
137
138 if stridx(&l:path, s:ruby_path) == -1
139 let &l:path = s:ruby_path
140 endif
141 if exists('s:ruby_paths') && stridx(&l:tags, join(map(copy(s:ruby_paths),'v:val."/tags"'),',')) == -1
142 let &l:tags = &tags . ',' . join(map(copy(s:ruby_paths),'v:val."/tags"'),',')
143 endif
144 endfunction
145
146 call SetRubyPath()
147 141
148 if (has("gui_win32") || has("gui_gtk")) && !exists("b:browsefilter") 142 if (has("gui_win32") || has("gui_gtk")) && !exists("b:browsefilter")
149 let b:browsefilter = "Ruby Source Files (*.rb)\t*.rb\n" . 143 let b:browsefilter = "Ruby Source Files (*.rb)\t*.rb\n" .
150 \ "All Files (*.*)\t*.*\n" 144 \ "All Files (*.*)\t*.*\n"
151 endif 145 endif