Mercurial > vim
comparison runtime/ftplugin/ruby.vim @ 548:f43150a669dc
updated for version 7.0155
author | vimboss |
---|---|
date | Mon, 10 Oct 2005 20:59:28 +0000 |
parents | 339999b511a0 |
children | 862863033fdd |
comparison
equal
deleted
inserted
replaced
547:513d037fad50 | 548:f43150a669dc |
---|---|
1 " Vim filetype plugin | 1 " Vim filetype plugin |
2 " Language: Ruby | 2 " Language: Ruby |
3 " Maintainer: Gavin Sinclair <gsinclair at soyabean.com.au> | 3 " Maintainer: Gavin Sinclair <gsinclair at soyabean.com.au> |
4 " Info: $Id$ | 4 " Info: $Id$ |
5 " URL: http://vim-ruby.sourceforge.net | 5 " URL: http://vim-ruby.sourceforge.net |
6 " Anon CVS: See above site | 6 " Anon CVS: See above site |
7 " Licence: GPL (http://www.gnu.org) | 7 " Licence: GPL (http://www.gnu.org) |
8 " Disclaimer: | 8 " Disclaimer: |
9 " This program is distributed in the hope that it will be useful, | 9 " This program is distributed in the hope that it will be useful, |
10 " but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 " but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 " MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 11 " MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 " GNU General Public License for more details. | 12 " GNU General Public License for more details. |
13 " ---------------------------------------------------------------------------- | 13 " ---------------------------------------------------------------------------- |
14 " | 14 " |
15 " Original matchit support thanks to Ned Konz. See his ftplugin/ruby.vim at | 15 " Original matchit support thanks to Ned Konz. See his ftplugin/ruby.vim at |
16 " http://bike-nomad.com/vim/ruby.vim. | 16 " http://bike-nomad.com/vim/ruby.vim. |
17 " ---------------------------------------------------------------------------- | 17 " ---------------------------------------------------------------------------- |
18 | 18 |
19 " Only do this when not done yet for this buffer | 19 " Only do this when not done yet for this buffer |
20 if (exists("b:did_ftplugin")) | 20 if (exists("b:did_ftplugin")) |
30 let b:match_ignorecase = 0 | 30 let b:match_ignorecase = 0 |
31 | 31 |
32 " TODO: improve optional do loops | 32 " TODO: improve optional do loops |
33 let b:match_words = | 33 let b:match_words = |
34 \ '\%(' . | 34 \ '\%(' . |
35 \ '\%(\%(\.\|\:\:\)\s*\)\@<!\<\%(class\|module\|begin\|def\|case\|for\|do\)\>' . | 35 \ '\%(\%(\.\|\:\:\)\s*\|\:\)\@<!\<\%(class\|module\|begin\|def\|case\|for\|do\)\>' . |
36 \ '\|' . | 36 \ '\|' . |
37 \ '\%(\%(^\|\.\.\.\=\|[\,;=([<>~\*/%!&^|+-]\)\s*\)\@<=\%(if\|unless\|until\|while\)\>' . | 37 \ '\%(\%(^\|\.\.\.\=\|[\,;=([<>~\*/%!&^|+-]\)\s*\)\@<=\%(if\|unless\|until\|while\)\>' . |
38 \ '\)' . | 38 \ '\)' . |
39 \ ':' . | 39 \ ':' . |
40 \ '\%(' . | 40 \ '\%(' . |
41 \ '\%(\%(\.\|\:\:\)\s*\)\@<!\<\%(else\|elsif\|ensure\|when\)\>' . | 41 \ '\%(\%(\.\|\:\:\)\s*\|\:\)\@<!\<\%(else\|elsif\|ensure\|when\)\>' . |
42 \ '\|' . | 42 \ '\|' . |
43 \ '\%(\%(^\|;\)\s*\)\@<=\<rescue\>' . | 43 \ '\%(\%(^\|;\)\s*\)\@<=\<rescue\>' . |
44 \ '\)' . | 44 \ '\)' . |
45 \ ':' . | 45 \ ':' . |
46 \ '\%(\%(\.\|\:\:\)\s*\)\@<!\<end\>' | 46 \ '\%(\%(\.\|\:\:\)\s*\|\:\)\@<!\<end\>' |
47 | 47 |
48 let b:match_skip = | 48 let b:match_skip = |
49 \ "synIDattr(synID(line('.'),col('.'),0),'name') =~ '" . | 49 \ "synIDattr(synID(line('.'),col('.'),0),'name') =~ '" . |
50 \ "\\<ruby\\%(String\\|StringDelimiter\\|ASCIICode\\|Interpolation\\|" . | 50 \ "\\<ruby\\%(String\\|StringDelimiter\\|ASCIICode\\|Interpolation\\|" . |
51 \ "NoInterpolation\\|Escape\\|Comment\\|Documentation\\)\\>'" | 51 \ "NoInterpolation\\|Escape\\|Comment\\|Documentation\\)\\>'" |
64 setlocal comments=:# | 64 setlocal comments=:# |
65 setlocal commentstring=#\ %s | 65 setlocal commentstring=#\ %s |
66 | 66 |
67 if !exists("s:rubypath") | 67 if !exists("s:rubypath") |
68 if executable("ruby") | 68 if executable("ruby") |
69 let s:code = "print ($: + begin; require %q{rubygems}; Gem.all_load_paths.sort.uniq; rescue LoadError; []; end).join(%q{,})" | |
69 if &shellxquote == "'" | 70 if &shellxquote == "'" |
70 let s:rubypath = system('ruby -e "puts (begin; require %q{rubygems}; Gem.all_load_paths; rescue LoadError; []; end + $:).join(%q{,})"') | 71 let s:rubypath = system('ruby -e "' . s:code . '"') |
71 else | 72 else |
72 let s:rubypath = system("ruby -e 'puts (begin; require %q{rubygems}; Gem.all_load_paths; rescue LoadError; []; end + $:).join(%q{,})'") | 73 let s:rubypath = system("ruby -e '" . s:code . "'") |
73 endif | 74 endif |
74 let s:rubypath = substitute(s:rubypath,',.$',',,','') | 75 let s:rubypath = '.,' . substitute(s:rubypath, '\%(^\|,\)\.\%(,\|$\)', ',,', '') |
75 else | 76 else |
76 " If we can't call ruby to get its path, just default to using the | 77 " If we can't call ruby to get its path, just default to using the |
77 " current directory and the directory of the current file. | 78 " current directory and the directory of the current file. |
78 let s:rubypath = ".,," | 79 let s:rubypath = ".,," |
79 endif | 80 endif |
81 | 82 |
82 let &l:path = s:rubypath | 83 let &l:path = s:rubypath |
83 | 84 |
84 if has("gui_win32") && !exists("b:browsefilter") | 85 if has("gui_win32") && !exists("b:browsefilter") |
85 let b:browsefilter = "Ruby Source Files (*.rb)\t*.rb\n" . | 86 let b:browsefilter = "Ruby Source Files (*.rb)\t*.rb\n" . |
86 \ "All Files (*.*)\t*.*\n" | 87 \ "All Files (*.*)\t*.*\n" |
87 endif | 88 endif |
88 | 89 |
89 let b:undo_ftplugin = "setl fo< inc< inex< sua< def< com< cms< path< " | 90 let b:undo_ftplugin = "setl fo< inc< inex< sua< def< com< cms< path< " |
90 \ "| unlet! b:browsefilter b:match_ignorecase b:match_words b:match_skip" | 91 \ "| unlet! b:browsefilter b:match_ignorecase b:match_words b:match_skip" |
91 | 92 |
95 " | 96 " |
96 " Instructions for enabling "matchit" support: | 97 " Instructions for enabling "matchit" support: |
97 " | 98 " |
98 " 1. Look for the latest "matchit" plugin at | 99 " 1. Look for the latest "matchit" plugin at |
99 " | 100 " |
100 " http://www.vim.org/scripts/script.php?script_id=39 | 101 " http://www.vim.org/scripts/script.php?script_id=39 |
101 " | 102 " |
102 " It is also packaged with Vim, in the $VIMRUNTIME/macros directory. | 103 " It is also packaged with Vim, in the $VIMRUNTIME/macros directory. |
103 " | 104 " |
104 " 2. Copy "matchit.txt" into a "doc" directory (e.g. $HOME/.vim/doc). | 105 " 2. Copy "matchit.txt" into a "doc" directory (e.g. $HOME/.vim/doc). |
105 " | 106 " |
106 " 3. Copy "matchit.vim" into a "plugin" directory (e.g. $HOME/.vim/plugin). | 107 " 3. Copy "matchit.vim" into a "plugin" directory (e.g. $HOME/.vim/plugin). |
107 " | 108 " |
108 " 4. Ensure this file (ftplugin/ruby.vim) is installed. | 109 " 4. Ensure this file (ftplugin/ruby.vim) is installed. |
109 " | 110 " |
110 " 5. Ensure you have this line in your $HOME/.vimrc: | 111 " 5. Ensure you have this line in your $HOME/.vimrc: |
111 " filetype plugin on | 112 " filetype plugin on |
112 " | 113 " |
113 " 6. Restart Vim and create the matchit documentation: | 114 " 6. Restart Vim and create the matchit documentation: |
114 " | 115 " |
115 " :helptags ~/.vim/doc | 116 " :helptags ~/.vim/doc |
116 " | 117 " |
117 " Now you can do ":help matchit", and you should be able to use "%" on Ruby | 118 " Now you can do ":help matchit", and you should be able to use "%" on Ruby |
118 " keywords. Try ":echo b:match_words" to be sure. | 119 " keywords. Try ":echo b:match_words" to be sure. |
119 " | 120 " |
120 " Thanks to Mark J. Reed for the instructions. See ":help vimrc" for the | 121 " Thanks to Mark J. Reed for the instructions. See ":help vimrc" for the |
121 " locations of plugin directories, etc., as there are several options, and it | 122 " locations of plugin directories, etc., as there are several options, and it |
122 " differs on Windows. Email gsinclair@soyabean.com.au if you need help. | 123 " differs on Windows. Email gsinclair@soyabean.com.au if you need help. |
123 " | 124 " |
124 | 125 |
125 " vim: nowrap sw=2 sts=2 ts=8 ff=unix: | 126 " vim: nowrap sw=2 sts=2 ts=8 ff=unix: |