annotate runtime/ftplugin/ruby.vim @ 831:f24a95dae8ee

updated for version 7.0d05
author vimboss
date Sat, 15 Apr 2006 20:25:09 +0000
parents dc8197342755
children a5677b7ce858
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1 " Vim filetype plugin
831
f24a95dae8ee updated for version 7.0d05
vimboss
parents: 829
diff changeset
2 " Language: Ruby
f24a95dae8ee updated for version 7.0d05
vimboss
parents: 829
diff changeset
3 " Maintainer: Gavin Sinclair <gsinclair at soyabean.com.au>
f24a95dae8ee updated for version 7.0d05
vimboss
parents: 829
diff changeset
4 " Info: $Id$
f24a95dae8ee updated for version 7.0d05
vimboss
parents: 829
diff changeset
5 " URL: http://vim-ruby.rubyforge.org
f24a95dae8ee updated for version 7.0d05
vimboss
parents: 829
diff changeset
6 " Anon CVS: See above site
f24a95dae8ee updated for version 7.0d05
vimboss
parents: 829
diff changeset
7 " Release Coordinator: Doug Kearns <dougkearns@gmail.com>
530
339999b511a0 updated for version 7.0148
vimboss
parents: 7
diff changeset
8 " ----------------------------------------------------------------------------
339999b511a0 updated for version 7.0148
vimboss
parents: 7
diff changeset
9 "
548
f43150a669dc updated for version 7.0155
vimboss
parents: 530
diff changeset
10 " Original matchit support thanks to Ned Konz. See his ftplugin/ruby.vim at
530
339999b511a0 updated for version 7.0148
vimboss
parents: 7
diff changeset
11 " http://bike-nomad.com/vim/ruby.vim.
339999b511a0 updated for version 7.0148
vimboss
parents: 7
diff changeset
12 " ----------------------------------------------------------------------------
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
13
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
14 " Only do this when not done yet for this buffer
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
15 if (exists("b:did_ftplugin"))
530
339999b511a0 updated for version 7.0148
vimboss
parents: 7
diff changeset
16 finish
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
17 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
18 let b:did_ftplugin = 1
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
19
530
339999b511a0 updated for version 7.0148
vimboss
parents: 7
diff changeset
20 let s:cpo_save = &cpo
339999b511a0 updated for version 7.0148
vimboss
parents: 7
diff changeset
21 set cpo&vim
339999b511a0 updated for version 7.0148
vimboss
parents: 7
diff changeset
22
339999b511a0 updated for version 7.0148
vimboss
parents: 7
diff changeset
23 " Matchit support
339999b511a0 updated for version 7.0148
vimboss
parents: 7
diff changeset
24 if exists("loaded_matchit") && !exists("b:match_words")
339999b511a0 updated for version 7.0148
vimboss
parents: 7
diff changeset
25 let b:match_ignorecase = 0
339999b511a0 updated for version 7.0148
vimboss
parents: 7
diff changeset
26
339999b511a0 updated for version 7.0148
vimboss
parents: 7
diff changeset
27 " TODO: improve optional do loops
339999b511a0 updated for version 7.0148
vimboss
parents: 7
diff changeset
28 let b:match_words =
339999b511a0 updated for version 7.0148
vimboss
parents: 7
diff changeset
29 \ '\%(' .
548
f43150a669dc updated for version 7.0155
vimboss
parents: 530
diff changeset
30 \ '\%(\%(\.\|\:\:\)\s*\|\:\)\@<!\<\%(class\|module\|begin\|def\|case\|for\|do\)\>' .
f43150a669dc updated for version 7.0155
vimboss
parents: 530
diff changeset
31 \ '\|' .
f43150a669dc updated for version 7.0155
vimboss
parents: 530
diff changeset
32 \ '\%(\%(^\|\.\.\.\=\|[\,;=([<>~\*/%!&^|+-]\)\s*\)\@<=\%(if\|unless\|until\|while\)\>' .
530
339999b511a0 updated for version 7.0148
vimboss
parents: 7
diff changeset
33 \ '\)' .
339999b511a0 updated for version 7.0148
vimboss
parents: 7
diff changeset
34 \ ':' .
339999b511a0 updated for version 7.0148
vimboss
parents: 7
diff changeset
35 \ '\%(' .
548
f43150a669dc updated for version 7.0155
vimboss
parents: 530
diff changeset
36 \ '\%(\%(\.\|\:\:\)\s*\|\:\)\@<!\<\%(else\|elsif\|ensure\|when\)\>' .
f43150a669dc updated for version 7.0155
vimboss
parents: 530
diff changeset
37 \ '\|' .
f43150a669dc updated for version 7.0155
vimboss
parents: 530
diff changeset
38 \ '\%(\%(^\|;\)\s*\)\@<=\<rescue\>' .
530
339999b511a0 updated for version 7.0148
vimboss
parents: 7
diff changeset
39 \ '\)' .
339999b511a0 updated for version 7.0148
vimboss
parents: 7
diff changeset
40 \ ':' .
548
f43150a669dc updated for version 7.0155
vimboss
parents: 530
diff changeset
41 \ '\%(\%(\.\|\:\:\)\s*\|\:\)\@<!\<end\>'
530
339999b511a0 updated for version 7.0148
vimboss
parents: 7
diff changeset
42
339999b511a0 updated for version 7.0148
vimboss
parents: 7
diff changeset
43 let b:match_skip =
339999b511a0 updated for version 7.0148
vimboss
parents: 7
diff changeset
44 \ "synIDattr(synID(line('.'),col('.'),0),'name') =~ '" .
339999b511a0 updated for version 7.0148
vimboss
parents: 7
diff changeset
45 \ "\\<ruby\\%(String\\|StringDelimiter\\|ASCIICode\\|Interpolation\\|" .
339999b511a0 updated for version 7.0148
vimboss
parents: 7
diff changeset
46 \ "NoInterpolation\\|Escape\\|Comment\\|Documentation\\)\\>'"
339999b511a0 updated for version 7.0148
vimboss
parents: 7
diff changeset
47
339999b511a0 updated for version 7.0148
vimboss
parents: 7
diff changeset
48 endif
339999b511a0 updated for version 7.0148
vimboss
parents: 7
diff changeset
49
339999b511a0 updated for version 7.0148
vimboss
parents: 7
diff changeset
50 setlocal formatoptions-=t formatoptions+=croql
339999b511a0 updated for version 7.0148
vimboss
parents: 7
diff changeset
51
339999b511a0 updated for version 7.0148
vimboss
parents: 7
diff changeset
52 setlocal include=^\\s*\\<\\(load\\\|\w*require\\)\\>
339999b511a0 updated for version 7.0148
vimboss
parents: 7
diff changeset
53 setlocal includeexpr=substitute(substitute(v:fname,'::','/','g'),'$','.rb','')
339999b511a0 updated for version 7.0148
vimboss
parents: 7
diff changeset
54 setlocal suffixesadd=.rb
831
f24a95dae8ee updated for version 7.0d05
vimboss
parents: 829
diff changeset
55
f24a95dae8ee updated for version 7.0d05
vimboss
parents: 829
diff changeset
56 if version >= 700
f24a95dae8ee updated for version 7.0d05
vimboss
parents: 829
diff changeset
57 setlocal omnifunc=rubycomplete#Complete
f24a95dae8ee updated for version 7.0d05
vimboss
parents: 829
diff changeset
58 endif
530
339999b511a0 updated for version 7.0148
vimboss
parents: 7
diff changeset
59
339999b511a0 updated for version 7.0148
vimboss
parents: 7
diff changeset
60 " TODO:
339999b511a0 updated for version 7.0148
vimboss
parents: 7
diff changeset
61 "setlocal define=^\\s*def
339999b511a0 updated for version 7.0148
vimboss
parents: 7
diff changeset
62
339999b511a0 updated for version 7.0148
vimboss
parents: 7
diff changeset
63 setlocal comments=:#
339999b511a0 updated for version 7.0148
vimboss
parents: 7
diff changeset
64 setlocal commentstring=#\ %s
339999b511a0 updated for version 7.0148
vimboss
parents: 7
diff changeset
65
339999b511a0 updated for version 7.0148
vimboss
parents: 7
diff changeset
66 if !exists("s:rubypath")
339999b511a0 updated for version 7.0148
vimboss
parents: 7
diff changeset
67 if executable("ruby")
548
f43150a669dc updated for version 7.0155
vimboss
parents: 530
diff changeset
68 let s:code = "print ($: + begin; require %q{rubygems}; Gem.all_load_paths.sort.uniq; rescue LoadError; []; end).join(%q{,})"
530
339999b511a0 updated for version 7.0148
vimboss
parents: 7
diff changeset
69 if &shellxquote == "'"
548
f43150a669dc updated for version 7.0155
vimboss
parents: 530
diff changeset
70 let s:rubypath = system('ruby -e "' . s:code . '"')
530
339999b511a0 updated for version 7.0148
vimboss
parents: 7
diff changeset
71 else
548
f43150a669dc updated for version 7.0155
vimboss
parents: 530
diff changeset
72 let s:rubypath = system("ruby -e '" . s:code . "'")
530
339999b511a0 updated for version 7.0148
vimboss
parents: 7
diff changeset
73 endif
548
f43150a669dc updated for version 7.0155
vimboss
parents: 530
diff changeset
74 let s:rubypath = '.,' . substitute(s:rubypath, '\%(^\|,\)\.\%(,\|$\)', ',,', '')
530
339999b511a0 updated for version 7.0148
vimboss
parents: 7
diff changeset
75 else
339999b511a0 updated for version 7.0148
vimboss
parents: 7
diff changeset
76 " If we can't call ruby to get its path, just default to using the
339999b511a0 updated for version 7.0148
vimboss
parents: 7
diff changeset
77 " current directory and the directory of the current file.
339999b511a0 updated for version 7.0148
vimboss
parents: 7
diff changeset
78 let s:rubypath = ".,,"
339999b511a0 updated for version 7.0148
vimboss
parents: 7
diff changeset
79 endif
339999b511a0 updated for version 7.0148
vimboss
parents: 7
diff changeset
80 endif
339999b511a0 updated for version 7.0148
vimboss
parents: 7
diff changeset
81
339999b511a0 updated for version 7.0148
vimboss
parents: 7
diff changeset
82 let &l:path = s:rubypath
339999b511a0 updated for version 7.0148
vimboss
parents: 7
diff changeset
83
339999b511a0 updated for version 7.0148
vimboss
parents: 7
diff changeset
84 if has("gui_win32") && !exists("b:browsefilter")
339999b511a0 updated for version 7.0148
vimboss
parents: 7
diff changeset
85 let b:browsefilter = "Ruby Source Files (*.rb)\t*.rb\n" .
548
f43150a669dc updated for version 7.0155
vimboss
parents: 530
diff changeset
86 \ "All Files (*.*)\t*.*\n"
530
339999b511a0 updated for version 7.0148
vimboss
parents: 7
diff changeset
87 endif
339999b511a0 updated for version 7.0148
vimboss
parents: 7
diff changeset
88
339999b511a0 updated for version 7.0148
vimboss
parents: 7
diff changeset
89 let b:undo_ftplugin = "setl fo< inc< inex< sua< def< com< cms< path< "
339999b511a0 updated for version 7.0148
vimboss
parents: 7
diff changeset
90 \ "| unlet! b:browsefilter b:match_ignorecase b:match_words b:match_skip"
339999b511a0 updated for version 7.0148
vimboss
parents: 7
diff changeset
91
339999b511a0 updated for version 7.0148
vimboss
parents: 7
diff changeset
92 let &cpo = s:cpo_save
339999b511a0 updated for version 7.0148
vimboss
parents: 7
diff changeset
93 unlet s:cpo_save
339999b511a0 updated for version 7.0148
vimboss
parents: 7
diff changeset
94
339999b511a0 updated for version 7.0148
vimboss
parents: 7
diff changeset
95 "
339999b511a0 updated for version 7.0148
vimboss
parents: 7
diff changeset
96 " Instructions for enabling "matchit" support:
339999b511a0 updated for version 7.0148
vimboss
parents: 7
diff changeset
97 "
339999b511a0 updated for version 7.0148
vimboss
parents: 7
diff changeset
98 " 1. Look for the latest "matchit" plugin at
339999b511a0 updated for version 7.0148
vimboss
parents: 7
diff changeset
99 "
548
f43150a669dc updated for version 7.0155
vimboss
parents: 530
diff changeset
100 " http://www.vim.org/scripts/script.php?script_id=39
530
339999b511a0 updated for version 7.0148
vimboss
parents: 7
diff changeset
101 "
339999b511a0 updated for version 7.0148
vimboss
parents: 7
diff changeset
102 " It is also packaged with Vim, in the $VIMRUNTIME/macros directory.
339999b511a0 updated for version 7.0148
vimboss
parents: 7
diff changeset
103 "
339999b511a0 updated for version 7.0148
vimboss
parents: 7
diff changeset
104 " 2. Copy "matchit.txt" into a "doc" directory (e.g. $HOME/.vim/doc).
339999b511a0 updated for version 7.0148
vimboss
parents: 7
diff changeset
105 "
339999b511a0 updated for version 7.0148
vimboss
parents: 7
diff changeset
106 " 3. Copy "matchit.vim" into a "plugin" directory (e.g. $HOME/.vim/plugin).
339999b511a0 updated for version 7.0148
vimboss
parents: 7
diff changeset
107 "
339999b511a0 updated for version 7.0148
vimboss
parents: 7
diff changeset
108 " 4. Ensure this file (ftplugin/ruby.vim) is installed.
339999b511a0 updated for version 7.0148
vimboss
parents: 7
diff changeset
109 "
339999b511a0 updated for version 7.0148
vimboss
parents: 7
diff changeset
110 " 5. Ensure you have this line in your $HOME/.vimrc:
548
f43150a669dc updated for version 7.0155
vimboss
parents: 530
diff changeset
111 " filetype plugin on
530
339999b511a0 updated for version 7.0148
vimboss
parents: 7
diff changeset
112 "
339999b511a0 updated for version 7.0148
vimboss
parents: 7
diff changeset
113 " 6. Restart Vim and create the matchit documentation:
339999b511a0 updated for version 7.0148
vimboss
parents: 7
diff changeset
114 "
548
f43150a669dc updated for version 7.0155
vimboss
parents: 530
diff changeset
115 " :helptags ~/.vim/doc
530
339999b511a0 updated for version 7.0148
vimboss
parents: 7
diff changeset
116 "
339999b511a0 updated for version 7.0148
vimboss
parents: 7
diff changeset
117 " Now you can do ":help matchit", and you should be able to use "%" on Ruby
548
f43150a669dc updated for version 7.0155
vimboss
parents: 530
diff changeset
118 " keywords. Try ":echo b:match_words" to be sure.
530
339999b511a0 updated for version 7.0148
vimboss
parents: 7
diff changeset
119 "
548
f43150a669dc updated for version 7.0155
vimboss
parents: 530
diff changeset
120 " Thanks to Mark J. Reed for the instructions. See ":help vimrc" for the
530
339999b511a0 updated for version 7.0148
vimboss
parents: 7
diff changeset
121 " locations of plugin directories, etc., as there are several options, and it
339999b511a0 updated for version 7.0148
vimboss
parents: 7
diff changeset
122 " differs on Windows. Email gsinclair@soyabean.com.au if you need help.
339999b511a0 updated for version 7.0148
vimboss
parents: 7
diff changeset
123 "
339999b511a0 updated for version 7.0148
vimboss
parents: 7
diff changeset
124
339999b511a0 updated for version 7.0148
vimboss
parents: 7
diff changeset
125 " vim: nowrap sw=2 sts=2 ts=8 ff=unix: