tomkersten-vixploder 0.1.1 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/History.txt +4 -0
- data/Manifest.txt +105 -0
- data/PostInstall.txt +21 -0
- data/README.rdoc +131 -0
- data/Rakefile +21 -0
- data/bin/256colors2.pl +63 -0
- data/bin/colortest +365 -0
- data/bin/vixplode +10 -0
- data/lib/dotfiles/aliases +30 -0
- data/lib/dotfiles/gvimrc +20 -0
- data/lib/dotfiles/vim/.VimballRecord +2 -0
- data/lib/dotfiles/vim/after/ftplugin/actionscript_snippets.vim +9 -0
- data/lib/dotfiles/vim/after/ftplugin/aspvbs_snippets.vim +17 -0
- data/lib/dotfiles/vim/after/ftplugin/c_snippets.vim +58 -0
- data/lib/dotfiles/vim/after/ftplugin/css_snippets.vim +30 -0
- data/lib/dotfiles/vim/after/ftplugin/django_model_snippets.vim +61 -0
- data/lib/dotfiles/vim/after/ftplugin/django_template_snippets.vim +32 -0
- data/lib/dotfiles/vim/after/ftplugin/f-script_snippets.vim +14 -0
- data/lib/dotfiles/vim/after/ftplugin/haskell_snippets.vim +9 -0
- data/lib/dotfiles/vim/after/ftplugin/html_snippets.vim +57 -0
- data/lib/dotfiles/vim/after/ftplugin/java_snippets.vim +52 -0
- data/lib/dotfiles/vim/after/ftplugin/javascript_snippets.vim +10 -0
- data/lib/dotfiles/vim/after/ftplugin/latex_snippets.vim +13 -0
- data/lib/dotfiles/vim/after/ftplugin/logo_snippets.vim +9 -0
- data/lib/dotfiles/vim/after/ftplugin/markdown_snippets.vim +10 -0
- data/lib/dotfiles/vim/after/ftplugin/movable_type_snippets.vim +14 -0
- data/lib/dotfiles/vim/after/ftplugin/objc_snippets.vim +53 -0
- data/lib/dotfiles/vim/after/ftplugin/ocaml_snippets.vim +26 -0
- data/lib/dotfiles/vim/after/ftplugin/perl_snippets.vim +23 -0
- data/lib/dotfiles/vim/after/ftplugin/php_snippets.vim +30 -0
- data/lib/dotfiles/vim/after/ftplugin/phpdoc_snippets.vim +19 -0
- data/lib/dotfiles/vim/after/ftplugin/propel_snippets.vim +14 -0
- data/lib/dotfiles/vim/after/ftplugin/python_snippets.vim +202 -0
- data/lib/dotfiles/vim/after/ftplugin/rails_snippets.vim +54 -0
- data/lib/dotfiles/vim/after/ftplugin/ruby_snippets.vim +32 -0
- data/lib/dotfiles/vim/after/ftplugin/sh_snippets.vim +12 -0
- data/lib/dotfiles/vim/after/ftplugin/slate_snippets.vim +19 -0
- data/lib/dotfiles/vim/after/ftplugin/smarty_snippets.vim +35 -0
- data/lib/dotfiles/vim/after/ftplugin/symfony_snippets.vim +21 -0
- data/lib/dotfiles/vim/after/ftplugin/tcl_snippets.vim +14 -0
- data/lib/dotfiles/vim/after/ftplugin/template_toolkit_snippets.vim +13 -0
- data/lib/dotfiles/vim/after/ftplugin/tex_snippets.vim +13 -0
- data/lib/dotfiles/vim/after/ftplugin/xhtml_snippets.vim +48 -0
- data/lib/dotfiles/vim/autoload/fakeclip.vim +253 -0
- data/lib/dotfiles/vim/autoload/rails.vim +4377 -0
- data/lib/dotfiles/vim/autoload/rubycomplete.vim +802 -0
- data/lib/dotfiles/vim/colors/inkpot.vim +212 -0
- data/lib/dotfiles/vim/colors/ir_black.vim +212 -0
- data/lib/dotfiles/vim/colors/ir_black_mod.vim +213 -0
- data/lib/dotfiles/vim/colors/railscasts.vim +100 -0
- data/lib/dotfiles/vim/colors/rubyblue.vim +74 -0
- data/lib/dotfiles/vim/colors/twilight.vim +75 -0
- data/lib/dotfiles/vim/colors/twilight2.vim +74 -0
- data/lib/dotfiles/vim/colors/wombat256.vim +302 -0
- data/lib/dotfiles/vim/compiler/eruby.vim +41 -0
- data/lib/dotfiles/vim/compiler/ruby.vim +68 -0
- data/lib/dotfiles/vim/compiler/rubyunit.vim +35 -0
- data/lib/dotfiles/vim/doc/NERD_tree.txt +1235 -0
- data/lib/dotfiles/vim/doc/fakeclip.txt +190 -0
- data/lib/dotfiles/vim/doc/matchit.txt +406 -0
- data/lib/dotfiles/vim/doc/project.txt +710 -0
- data/lib/dotfiles/vim/doc/rails.txt +1123 -0
- data/lib/dotfiles/vim/doc/snippets_emu.txt +354 -0
- data/lib/dotfiles/vim/doc/surround.txt +218 -0
- data/lib/dotfiles/vim/doc/tags +433 -0
- data/lib/dotfiles/vim/filetype.vim +13 -0
- data/lib/dotfiles/vim/ftdetect/gist.vim +3 -0
- data/lib/dotfiles/vim/ftdetect/ruby.vim +14 -0
- data/lib/dotfiles/vim/ftplugin/eruby.vim +101 -0
- data/lib/dotfiles/vim/ftplugin/ruby.vim +230 -0
- data/lib/dotfiles/vim/indent/eruby.vim +73 -0
- data/lib/dotfiles/vim/indent/ruby.vim +373 -0
- data/lib/dotfiles/vim/plugin/NERD_tree.vim +3536 -0
- data/lib/dotfiles/vim/plugin/comments.vim +321 -0
- data/lib/dotfiles/vim/plugin/fakeclip.vim +174 -0
- data/lib/dotfiles/vim/plugin/fuzzyfinder.vim +1676 -0
- data/lib/dotfiles/vim/plugin/fuzzyfinder_textmate.vim +150 -0
- data/lib/dotfiles/vim/plugin/gist.vim +241 -0
- data/lib/dotfiles/vim/plugin/gitdiff.vim +141 -0
- data/lib/dotfiles/vim/plugin/matchit.vim +812 -0
- data/lib/dotfiles/vim/plugin/mru.vim +787 -0
- data/lib/dotfiles/vim/plugin/rails.vim +310 -0
- data/lib/dotfiles/vim/plugin/rspec.vim +12 -0
- data/lib/dotfiles/vim/plugin/snippets.vim +17 -0
- data/lib/dotfiles/vim/plugin/snippetsEmu.vim +973 -0
- data/lib/dotfiles/vim/plugin/supertab.vim +531 -0
- data/lib/dotfiles/vim/plugin/surround.vim +632 -0
- data/lib/dotfiles/vim/ref_vimrc +80 -0
- data/lib/dotfiles/vim/ruby/fuzzy_file_finder.rb +353 -0
- data/lib/dotfiles/vim/syntax/eruby.vim +85 -0
- data/lib/dotfiles/vim/syntax/haml.vim +113 -0
- data/lib/dotfiles/vim/syntax/mkd.vim +86 -0
- data/lib/dotfiles/vim/syntax/ruby.vim +324 -0
- data/lib/dotfiles/vim/syntax/sass.vim +93 -0
- data/lib/dotfiles/vimrc +269 -0
- data/lib/vixplode/cli.rb +73 -0
- data/lib/vixploder.rb +6 -0
- data/script/console +10 -0
- data/script/destroy +14 -0
- data/script/generate +14 -0
- data/spec/spec.opts +1 -0
- data/spec/spec_helper.rb +10 -0
- data/spec/vixplode_cli_spec.rb +15 -0
- data/spec/vixploder_spec.rb +7 -0
- data/tasks/rspec.rake +21 -0
- metadata +202 -8
@@ -0,0 +1,787 @@
|
|
1
|
+
" File: mru.vim
|
2
|
+
" Author: Yegappan Lakshmanan (yegappan AT yahoo DOT com)
|
3
|
+
" Version: 3.2
|
4
|
+
" Last Modified: September 22, 2008
|
5
|
+
"
|
6
|
+
" Overview
|
7
|
+
" --------
|
8
|
+
" The Most Recently Used (MRU) plugin provides an easy access to a list of
|
9
|
+
" recently opened/edited files in Vim. This plugin automatically stores the
|
10
|
+
" file names as you open/edit them in Vim.
|
11
|
+
"
|
12
|
+
" This plugin will work on all the platforms where Vim is supported. This
|
13
|
+
" plugin will work in both console and GUI Vim. This version of the MRU
|
14
|
+
" plugin needs Vim 7.0 and above. If you are using an earlier version of
|
15
|
+
" Vim, then you should use an older version of the MRU plugin.
|
16
|
+
"
|
17
|
+
" The recently used filenames are stored in a file specified by the Vim
|
18
|
+
" MRU_File variable.
|
19
|
+
"
|
20
|
+
" Installation
|
21
|
+
" ------------
|
22
|
+
" 1. Copy the mru.vim file to one of the following directories:
|
23
|
+
"
|
24
|
+
" $HOME/.vim/plugin - Unix like systems
|
25
|
+
" $HOME/vimfiles/plugin - MS-Windows
|
26
|
+
" $VIM:vimfiles:plugin - Macintosh
|
27
|
+
" $VIM/vimfiles/plugin - All
|
28
|
+
"
|
29
|
+
" Refer to the following Vim help topics for more information about Vim
|
30
|
+
" plugins:
|
31
|
+
"
|
32
|
+
" :help add-plugin
|
33
|
+
" :help add-global-plugin
|
34
|
+
" :help runtimepath
|
35
|
+
"
|
36
|
+
" 2. Set the MRU_File Vim variable in the .vimrc file to the location of a
|
37
|
+
" file to store the most recently edited file names. This step is needed
|
38
|
+
" only if you want to change the default MRU filename.
|
39
|
+
" 3. Restart Vim.
|
40
|
+
" 4. You can use the ":MRU" command to list and edit the recently used files.
|
41
|
+
" In GUI Vim, you can use the 'File->Recent Files' menu to access the
|
42
|
+
" recently used files.
|
43
|
+
"
|
44
|
+
" To uninstall this plugin, remove this file (mru.vim) from the
|
45
|
+
" $HOME/.vim/plugin or $HOME/vimfiles/plugin or the $VIM/vimfile/plugin
|
46
|
+
" directory.
|
47
|
+
"
|
48
|
+
" Usage
|
49
|
+
" -----
|
50
|
+
" To list and edit files from the MRU list, you have to use the ":MRU"
|
51
|
+
" command. The ":MRU" command displays the MRU file list in a temporary Vim
|
52
|
+
" window. If the MRU window is already opened, then the MRU list displayed in
|
53
|
+
" the window is refreshed.
|
54
|
+
"
|
55
|
+
" If you are using GUI Vim, then the names of the recently edited files are
|
56
|
+
" added to the "File->Recent Files" menu. You can select the name of a file
|
57
|
+
" from this sub-menu to edit the file.
|
58
|
+
"
|
59
|
+
" You can use the normal Vim commands to move around in the MRU window. You
|
60
|
+
" cannot make changes in the MRU window.
|
61
|
+
"
|
62
|
+
" You can select a file name to edit by pressing the <Enter> key or by double
|
63
|
+
" clicking the left mouse button on a file name. The selected file will be
|
64
|
+
" opened. If the file is already opened in a window, the cursor will be moved
|
65
|
+
" to that window. Otherwise, the file is opened in the previous window. If the
|
66
|
+
" previous window has a modified buffer or is the preview window or is used by
|
67
|
+
" some other plugin, then the file is opened in a new window.
|
68
|
+
"
|
69
|
+
" You can press the 'o' key to open the file name under the cursor in the
|
70
|
+
" MRU window in a new window.
|
71
|
+
"
|
72
|
+
" To open a file from the MRU window in a new tab, press the 't' key. If the
|
73
|
+
" file is already opened in a window in the current or in another tab, then
|
74
|
+
" the cursor is moved to that tab. Otherwise, a new tab is opened.
|
75
|
+
"
|
76
|
+
" You can press the 'u' key in the MRU window to update the file list. This is
|
77
|
+
" useful if you keep the MRU window open always.
|
78
|
+
"
|
79
|
+
" You can close the MRU window by pressing the 'q' key or using one of the Vim
|
80
|
+
" window commands.
|
81
|
+
"
|
82
|
+
" To display only files matching a pattern from the MRU list in the MRU
|
83
|
+
" window, you can specify a pattern to the ":MRU" command. For example, to
|
84
|
+
" display only file names containing "vim" in them, you can use the following
|
85
|
+
" command ":MRU vim". When you specify a partial file name and only one
|
86
|
+
" matching filename is found, then the ":MRU" command will edit that file.
|
87
|
+
"
|
88
|
+
" The ":MRU" command supports command-line completion of file names from
|
89
|
+
" the MRU list. You can enter a partial file name and then press <Tab>
|
90
|
+
" or <Ctrl-D> to complete or list all the matching file names.
|
91
|
+
"
|
92
|
+
" Whenever the MRU list changes, the MRU file is updated with the latest MRU
|
93
|
+
" list. When you have multiple instances of Vim running at the same time, the
|
94
|
+
" latest MRU list will show up in all the instances of Vim.
|
95
|
+
"
|
96
|
+
" Configuration
|
97
|
+
" -------------
|
98
|
+
" By changing the following variables you can configure the behavior of this
|
99
|
+
" plugin. Set the following variables in your .vimrc file using the 'let'
|
100
|
+
" command.
|
101
|
+
"
|
102
|
+
" The list of recently edited file names is stored in the file specified by the
|
103
|
+
" MRU_File variable. The default setting for this variable is
|
104
|
+
" $HOME/.vim_mru_files for Unix-like systems and $USERPROFILE/_vim_mru_files
|
105
|
+
" for MS-Windows systems. You can change this variable to point to a file by
|
106
|
+
" adding the following line to the .vimrc file:
|
107
|
+
"
|
108
|
+
" let MRU_File = 'd:\myhome\_vim_mru_files'
|
109
|
+
"
|
110
|
+
" By default, the plugin will remember the names of the last 10 used files.
|
111
|
+
" As you edit more files, old file names will be removed from the MRU list.
|
112
|
+
" You can set the 'MRU_Max_Entries' variable to remember more file names. For
|
113
|
+
" example, to remember 20 most recently used file names, you can use
|
114
|
+
"
|
115
|
+
" let MRU_Max_Entries = 20
|
116
|
+
"
|
117
|
+
" By default, all the edited file names will be added to the MRU list. If you
|
118
|
+
" want to exclude file names matching a list of patterns, you can set the
|
119
|
+
" MRU_Exclude_Files variable to a list of Vim regular expressions. By default,
|
120
|
+
" this variable is set to an empty string. For example, to not include files
|
121
|
+
" in the temporary (/tmp, /var/tmp and d:\temp) directories, you can set the
|
122
|
+
" MRU_Exclude_Files variable to
|
123
|
+
"
|
124
|
+
" let MRU_Exclude_Files = '^/tmp/.*\|^/var/tmp/.*' " For Unix
|
125
|
+
" let MRU_Exclude_Files = '^c:\\temp\\.*' " For MS-Windows
|
126
|
+
"
|
127
|
+
" The specified pattern should be a Vim regular expression pattern.
|
128
|
+
"
|
129
|
+
" If you want to add only file names matching a set of patterns to the MRU
|
130
|
+
" list, then you can set the MRU_Include_Files variable. This variable should
|
131
|
+
" be set to a Vim regular expression pattern. For example, to add only .c and
|
132
|
+
" .h files to the MRU list, you can set this variable as below:
|
133
|
+
"
|
134
|
+
" let MRU_Include_Files = '\.c$\|\.h$'
|
135
|
+
"
|
136
|
+
" By default, MRU_Include_Files is set to an empty string and all the edited
|
137
|
+
" filenames are added to the MRU list.
|
138
|
+
"
|
139
|
+
" The default height of the MRU window is 8. You can set the MRU_Window_Height
|
140
|
+
" variable to change the window height.
|
141
|
+
"
|
142
|
+
" let MRU_Window_Height = 15
|
143
|
+
"
|
144
|
+
" By default, when the :MRU command is invoked, the MRU list will be displayed
|
145
|
+
" in a new window. Instead, if you want the MRU plugin to reuse the current
|
146
|
+
" window, then you can set the 'MRU_Use_Current_Window' variable to one.
|
147
|
+
"
|
148
|
+
" let MRU_Use_Current_Window = 1
|
149
|
+
"
|
150
|
+
" The MRU plugin will reuse the current window. When a file name is selected,
|
151
|
+
" the file is also opened in the current window.
|
152
|
+
"
|
153
|
+
" When you select a file from the MRU window, the MRU window will be
|
154
|
+
" automatically closed and the selected file will be opened in the previous
|
155
|
+
" window. You can set the 'MRU_Auto_Close' variable to zero to keep the MRU
|
156
|
+
" window open.
|
157
|
+
"
|
158
|
+
" let MRU_Auto_Close = 0
|
159
|
+
"
|
160
|
+
" If you don't use the "File->Recent Files" menu and want to disable it,
|
161
|
+
" then you can set the 'MRU_Add_Menu' variable to zero. By default, the
|
162
|
+
" menu is enabled.
|
163
|
+
"
|
164
|
+
" let MRU_Add_Menu = 0
|
165
|
+
"
|
166
|
+
" ****************** Do not modify after this line ************************
|
167
|
+
if exists('loaded_mru')
|
168
|
+
finish
|
169
|
+
endif
|
170
|
+
let loaded_mru=1
|
171
|
+
|
172
|
+
if v:version < 700
|
173
|
+
finish
|
174
|
+
endif
|
175
|
+
|
176
|
+
" Line continuation used here
|
177
|
+
let s:cpo_save = &cpo
|
178
|
+
set cpo&vim
|
179
|
+
|
180
|
+
" Maximum number of entries allowed in the MRU list
|
181
|
+
if !exists('MRU_Max_Entries')
|
182
|
+
let MRU_Max_Entries = 10
|
183
|
+
endif
|
184
|
+
|
185
|
+
" Files to exclude from the MRU list
|
186
|
+
if !exists('MRU_Exclude_Files')
|
187
|
+
let MRU_Exclude_Files = ''
|
188
|
+
endif
|
189
|
+
|
190
|
+
" Files to include in the MRU list
|
191
|
+
if !exists('MRU_Include_Files')
|
192
|
+
let MRU_Include_Files = ''
|
193
|
+
endif
|
194
|
+
|
195
|
+
" Height of the MRU window
|
196
|
+
" Default height is 8
|
197
|
+
if !exists('MRU_Window_Height')
|
198
|
+
let MRU_Window_Height = 8
|
199
|
+
endif
|
200
|
+
|
201
|
+
if !exists('MRU_Use_Current_Window')
|
202
|
+
let MRU_Use_Current_Window = 0
|
203
|
+
endif
|
204
|
+
|
205
|
+
if !exists('MRU_Auto_Close')
|
206
|
+
let MRU_Auto_Close = 1
|
207
|
+
endif
|
208
|
+
|
209
|
+
if !exists('MRU_File')
|
210
|
+
if has('unix') || has('macunix')
|
211
|
+
let MRU_File = $HOME . '/.vim_mru_files'
|
212
|
+
else
|
213
|
+
let MRU_File = $VIM . '/_vim_mru_files'
|
214
|
+
if has('win32')
|
215
|
+
" MS-Windows
|
216
|
+
if $USERPROFILE != ''
|
217
|
+
let MRU_File = $USERPROFILE . '\_vim_mru_files'
|
218
|
+
endif
|
219
|
+
endif
|
220
|
+
endif
|
221
|
+
endif
|
222
|
+
|
223
|
+
" Option for enabling or disabling the MRU menu
|
224
|
+
if !exists('MRU_Add_Menu')
|
225
|
+
let MRU_Add_Menu = 1
|
226
|
+
endif
|
227
|
+
|
228
|
+
" Control to temporarily lock the MRU list. Used to prevent files from
|
229
|
+
" getting added to the MRU list when the ':vimgrep' command is executed.
|
230
|
+
let s:mru_list_locked = 0
|
231
|
+
|
232
|
+
" MRU_LoadList
|
233
|
+
" Load the latest MRU file list from the MRU file
|
234
|
+
function! s:MRU_LoadList()
|
235
|
+
" Read the list from the MRU file.
|
236
|
+
if filereadable(g:MRU_File)
|
237
|
+
let s:MRU_files = readfile(g:MRU_File)
|
238
|
+
if s:MRU_files[0] =~# '^\s*" Most recently edited files in Vim'
|
239
|
+
" Generated by the previous version of the MRU plugin.
|
240
|
+
" Discard the list.
|
241
|
+
let s:MRU_files = []
|
242
|
+
elseif s:MRU_files[0] =~# '^#'
|
243
|
+
" Remove the comment line
|
244
|
+
call remove(s:MRU_files, 0)
|
245
|
+
else
|
246
|
+
" Unsupported format
|
247
|
+
let s:MRU_files = []
|
248
|
+
endif
|
249
|
+
else
|
250
|
+
let s:MRU_files = []
|
251
|
+
endif
|
252
|
+
|
253
|
+
" Refresh the MRU menu
|
254
|
+
call s:MRU_Refresh_Menu()
|
255
|
+
endfunction
|
256
|
+
|
257
|
+
" MRU_SaveList
|
258
|
+
" Save the MRU list to the file
|
259
|
+
function! s:MRU_SaveList()
|
260
|
+
let l = []
|
261
|
+
call add(l, '# Most recently edited files in Vim (version 3.0)')
|
262
|
+
call extend(l, s:MRU_files)
|
263
|
+
call writefile(l, g:MRU_File)
|
264
|
+
endfunction
|
265
|
+
|
266
|
+
" MRU_AddFile
|
267
|
+
" Add a file to the MRU file list
|
268
|
+
function! s:MRU_AddFile(acmd_bufnr)
|
269
|
+
if s:mru_list_locked
|
270
|
+
" MRU list is currently locked
|
271
|
+
return
|
272
|
+
endif
|
273
|
+
|
274
|
+
" Get the full path to the filename
|
275
|
+
let fname = fnamemodify(bufname(a:acmd_bufnr + 0), ':p')
|
276
|
+
if fname == ''
|
277
|
+
return
|
278
|
+
endif
|
279
|
+
|
280
|
+
" Skip temporary buffer with buftype set
|
281
|
+
if &buftype != ''
|
282
|
+
return
|
283
|
+
endif
|
284
|
+
|
285
|
+
if g:MRU_Include_Files != ''
|
286
|
+
" If MRU_Include_Files is set, include only files matching the
|
287
|
+
" specified pattern
|
288
|
+
if fname !~# g:MRU_Include_Files
|
289
|
+
return
|
290
|
+
endif
|
291
|
+
endif
|
292
|
+
|
293
|
+
if g:MRU_Exclude_Files != ''
|
294
|
+
" Do not add files matching the pattern specified in the
|
295
|
+
" MRU_Exclude_Files to the MRU list
|
296
|
+
if fname =~# g:MRU_Exclude_Files
|
297
|
+
return
|
298
|
+
endif
|
299
|
+
endif
|
300
|
+
|
301
|
+
" If the filename is not already present in the MRU list and is not
|
302
|
+
" readable then ignore it
|
303
|
+
let idx = index(s:MRU_files, fname)
|
304
|
+
if idx == -1
|
305
|
+
if !filereadable(fname)
|
306
|
+
" File is not readable and is not in the MRU list
|
307
|
+
return
|
308
|
+
endif
|
309
|
+
endif
|
310
|
+
|
311
|
+
" Load the latest MRU file list
|
312
|
+
call s:MRU_LoadList()
|
313
|
+
|
314
|
+
" Remove the new file name from the existing MRU list (if already present)
|
315
|
+
call filter(s:MRU_files, 'v:val !=# fname')
|
316
|
+
|
317
|
+
" Add the new file list to the beginning of the updated old file list
|
318
|
+
call insert(s:MRU_files, fname, 0)
|
319
|
+
|
320
|
+
" Trim the list
|
321
|
+
if len(s:MRU_files) > g:MRU_Max_Entries
|
322
|
+
call remove(s:MRU_files, g:MRU_Max_Entries, -1)
|
323
|
+
endif
|
324
|
+
|
325
|
+
" Save the updated MRU list
|
326
|
+
call s:MRU_SaveList()
|
327
|
+
|
328
|
+
" Refresh the MRU menu
|
329
|
+
call s:MRU_Refresh_Menu()
|
330
|
+
|
331
|
+
" If the MRU window is open, update the displayed MRU list
|
332
|
+
let bname = '__MRU_Files__'
|
333
|
+
let winnum = bufwinnr(bname)
|
334
|
+
if winnum != -1
|
335
|
+
let cur_winnr = winnr()
|
336
|
+
call s:MRU_Open_Window()
|
337
|
+
if winnr() != cur_winnr
|
338
|
+
exe cur_winnr . 'wincmd w'
|
339
|
+
endif
|
340
|
+
endif
|
341
|
+
endfunction
|
342
|
+
|
343
|
+
" Special characters in file names that should be escaped (for security
|
344
|
+
" reasons)
|
345
|
+
let s:esc_filename_chars = ' *?[{`$%#"|!<>();&' . "'\t\n"
|
346
|
+
function! s:MRU_escape_filename(fname)
|
347
|
+
return escape(a:fname, s:esc_filename_chars)
|
348
|
+
endfunction
|
349
|
+
|
350
|
+
" MRU_Edit_File
|
351
|
+
" Edit the specified file
|
352
|
+
function! s:MRU_Edit_File(filename, sanitized)
|
353
|
+
if !a:sanitized
|
354
|
+
let esc_fname = s:MRU_escape_filename(a:filename)
|
355
|
+
else
|
356
|
+
let esc_fname = a:filename
|
357
|
+
endif
|
358
|
+
" If the file is already open in one of the windows, jump to it
|
359
|
+
let winnum = bufwinnr('^' . a:filename . '$')
|
360
|
+
if winnum != -1
|
361
|
+
if winnum != winnr()
|
362
|
+
exe winnum . 'wincmd w'
|
363
|
+
endif
|
364
|
+
else
|
365
|
+
if &modified || &buftype != '' || &previewwindow
|
366
|
+
" Current buffer has unsaved changes or is a special buffer or is
|
367
|
+
" the preview window. So open the file in a new window
|
368
|
+
exe 'split ' . esc_fname
|
369
|
+
else
|
370
|
+
exe 'edit ' . esc_fname
|
371
|
+
endif
|
372
|
+
endif
|
373
|
+
endfunction
|
374
|
+
|
375
|
+
" MRU_Window_Edit_File
|
376
|
+
" Open a file selected from the MRU window
|
377
|
+
" win_opt == useopen, open file in previous window
|
378
|
+
" win_opt == newwin, open file in new window
|
379
|
+
" win_opt == newtab, open file in new tab
|
380
|
+
function! s:MRU_Window_Edit_File(win_opt)
|
381
|
+
let fname = getline('.')
|
382
|
+
|
383
|
+
if fname == ''
|
384
|
+
return
|
385
|
+
endif
|
386
|
+
|
387
|
+
let esc_fname = s:MRU_escape_filename(fname)
|
388
|
+
|
389
|
+
if a:win_opt == 'newwin'
|
390
|
+
" Edit the file in a new window
|
391
|
+
exe 'leftabove new ' . esc_fname
|
392
|
+
|
393
|
+
if g:MRU_Auto_Close == 1 && g:MRU_Use_Current_Window == 0
|
394
|
+
" Go back to the MRU window and close it
|
395
|
+
let cur_winnr = winnr()
|
396
|
+
|
397
|
+
wincmd p
|
398
|
+
silent! close
|
399
|
+
|
400
|
+
if winnr() != cur_winnr
|
401
|
+
exe cur_winnr . 'wincmd w'
|
402
|
+
endif
|
403
|
+
endif
|
404
|
+
elseif a:win_opt == 'newtab'
|
405
|
+
if g:MRU_Auto_Close == 1 && g:MRU_Use_Current_Window == 0
|
406
|
+
" Automatically close the window if the file window is
|
407
|
+
" not used to display the MRU list.
|
408
|
+
silent! close
|
409
|
+
endif
|
410
|
+
|
411
|
+
" If the selected file is already open in the current tab or in
|
412
|
+
" another tab, jump to it. Otherwise open it in a new tab
|
413
|
+
if bufwinnr('^' . fname . '$') == -1
|
414
|
+
let tabnum = -1
|
415
|
+
let i = 1
|
416
|
+
let bnum = bufnr('^' . fname . '$')
|
417
|
+
while i <= tabpagenr('$')
|
418
|
+
if index(tabpagebuflist(i), bnum) != -1
|
419
|
+
let tabnum = i
|
420
|
+
break
|
421
|
+
endif
|
422
|
+
let i += 1
|
423
|
+
endwhile
|
424
|
+
|
425
|
+
if tabnum != -1
|
426
|
+
" Goto the tab containing the file
|
427
|
+
exe 'tabnext ' . i
|
428
|
+
else
|
429
|
+
" Open a new tab as the last tab page
|
430
|
+
exe '999tabnew ' . esc_fname
|
431
|
+
endif
|
432
|
+
endif
|
433
|
+
|
434
|
+
" Jump to the window containing the file
|
435
|
+
let winnum = bufwinnr('^' . fname . '$')
|
436
|
+
if winnum != winnr()
|
437
|
+
exe winnum . 'wincmd w'
|
438
|
+
endif
|
439
|
+
else
|
440
|
+
" If the selected file is already open in one of the windows,
|
441
|
+
" jump to it
|
442
|
+
let winnum = bufwinnr('^' . fname . '$')
|
443
|
+
if winnum != -1
|
444
|
+
if g:MRU_Auto_Close == 1 && g:MRU_Use_Current_Window == 0
|
445
|
+
" Automatically close the window if the file window is
|
446
|
+
" not used to display the MRU list.
|
447
|
+
silent! close
|
448
|
+
endif
|
449
|
+
" As the window numbers will change after closing a window,
|
450
|
+
" get the window number again and jump to it, if the cursor
|
451
|
+
" is not already in that window
|
452
|
+
let winnum = bufwinnr('^' . fname . '$')
|
453
|
+
if winnum != winnr()
|
454
|
+
exe winnum . 'wincmd w'
|
455
|
+
endif
|
456
|
+
else
|
457
|
+
if g:MRU_Auto_Close == 1 && g:MRU_Use_Current_Window == 0
|
458
|
+
" Automatically close the window if the file window is
|
459
|
+
" not used to display the MRU list.
|
460
|
+
silent! close
|
461
|
+
|
462
|
+
" Jump to the window from which the MRU window was opened
|
463
|
+
if exists('s:MRU_last_buffer')
|
464
|
+
let last_winnr = bufwinnr(s:MRU_last_buffer)
|
465
|
+
if last_winnr != -1 && last_winnr != winnr()
|
466
|
+
exe last_winnr . 'wincmd w'
|
467
|
+
endif
|
468
|
+
endif
|
469
|
+
else
|
470
|
+
if g:MRU_Use_Current_Window == 0
|
471
|
+
" Goto the previous window
|
472
|
+
" If MRU_Use_Current_Window is set to one, then the
|
473
|
+
" current window is used to open the file
|
474
|
+
wincmd p
|
475
|
+
endif
|
476
|
+
endif
|
477
|
+
|
478
|
+
" Edit the file
|
479
|
+
if &modified || &buftype != '' || &previewwindow
|
480
|
+
" Current buffer has unsaved changes or is a special buffer or
|
481
|
+
" is the preview window. So open the file in a new window
|
482
|
+
exe 'split ' . esc_fname
|
483
|
+
else
|
484
|
+
exe 'edit ' . esc_fname
|
485
|
+
endif
|
486
|
+
endif
|
487
|
+
endif
|
488
|
+
endfunction
|
489
|
+
|
490
|
+
" MRU_Warn_Msg
|
491
|
+
" Display a warning message
|
492
|
+
function! s:MRU_Warn_Msg(msg)
|
493
|
+
echohl WarningMsg
|
494
|
+
echo a:msg
|
495
|
+
echohl None
|
496
|
+
endfunction
|
497
|
+
|
498
|
+
" MRU_Open_Window
|
499
|
+
" Display the Most Recently Used file list in a temporary window.
|
500
|
+
function! s:MRU_Open_Window(...)
|
501
|
+
|
502
|
+
" Load the latest MRU file list
|
503
|
+
call s:MRU_LoadList()
|
504
|
+
|
505
|
+
" Empty MRU list
|
506
|
+
if empty(s:MRU_files)
|
507
|
+
call s:MRU_Warn_Msg('MRU file list is empty')
|
508
|
+
return
|
509
|
+
endif
|
510
|
+
|
511
|
+
" Save the current buffer number. This is used later to open a file when a
|
512
|
+
" entry is selected from the MRU window. The window number is not saved,
|
513
|
+
" as the window number will change when new windows are opened.
|
514
|
+
let s:MRU_last_buffer = bufnr('%')
|
515
|
+
|
516
|
+
let bname = '__MRU_Files__'
|
517
|
+
|
518
|
+
" If the window is already open, jump to it
|
519
|
+
let winnum = bufwinnr(bname)
|
520
|
+
if winnum != -1
|
521
|
+
if winnr() != winnum
|
522
|
+
" If not already in the window, jump to it
|
523
|
+
exe winnum . 'wincmd w'
|
524
|
+
endif
|
525
|
+
|
526
|
+
setlocal modifiable
|
527
|
+
|
528
|
+
" Delete the contents of the buffer to the black-hole register
|
529
|
+
silent! %delete _
|
530
|
+
else
|
531
|
+
if g:MRU_Use_Current_Window
|
532
|
+
" Reuse the current window
|
533
|
+
"
|
534
|
+
" If the __MRU_Files__ buffer exists, then reuse it. Otherwise open
|
535
|
+
" a new buffer
|
536
|
+
let bufnum = bufnr(bname)
|
537
|
+
if bufnum == -1
|
538
|
+
let cmd = 'edit ' . bname
|
539
|
+
else
|
540
|
+
let cmd = 'buffer ' . bufnum
|
541
|
+
endif
|
542
|
+
|
543
|
+
exe cmd
|
544
|
+
|
545
|
+
if bufnr('%') != bufnr(bname)
|
546
|
+
" Failed to edit the MRU buffer
|
547
|
+
return
|
548
|
+
endif
|
549
|
+
else
|
550
|
+
" Open a new window at the bottom
|
551
|
+
|
552
|
+
" If the __MRU_Files__ buffer exists, then reuse it. Otherwise open
|
553
|
+
" a new buffer
|
554
|
+
let bufnum = bufnr(bname)
|
555
|
+
if bufnum == -1
|
556
|
+
let wcmd = bname
|
557
|
+
else
|
558
|
+
let wcmd = '+buffer' . bufnum
|
559
|
+
endif
|
560
|
+
|
561
|
+
exe 'silent! botright ' . g:MRU_Window_Height . 'split ' . wcmd
|
562
|
+
endif
|
563
|
+
endif
|
564
|
+
|
565
|
+
" Mark the buffer as scratch
|
566
|
+
setlocal buftype=nofile
|
567
|
+
setlocal bufhidden=delete
|
568
|
+
setlocal noswapfile
|
569
|
+
setlocal nowrap
|
570
|
+
setlocal nobuflisted
|
571
|
+
" Use fixed height for the MRU window
|
572
|
+
if v:version >= 602
|
573
|
+
setlocal winfixheight
|
574
|
+
endif
|
575
|
+
|
576
|
+
" Setup the cpoptions properly for the maps to work
|
577
|
+
let old_cpoptions = &cpoptions
|
578
|
+
set cpoptions&vim
|
579
|
+
|
580
|
+
" Create a mapping to jump to the file
|
581
|
+
nnoremap <buffer> <silent> <CR>
|
582
|
+
\ :call <SID>MRU_Window_Edit_File('useopen')<CR>
|
583
|
+
nnoremap <buffer> <silent> o
|
584
|
+
\ :call <SID>MRU_Window_Edit_File('newwin')<CR>
|
585
|
+
nnoremap <buffer> <silent> t
|
586
|
+
\ :call <SID>MRU_Window_Edit_File('newtab')<CR>
|
587
|
+
nnoremap <buffer> <silent> u :MRU<CR>
|
588
|
+
nnoremap <buffer> <silent> <2-LeftMouse>
|
589
|
+
\ :call <SID>MRU_Window_Edit_File('useopen')<CR>
|
590
|
+
nnoremap <buffer> <silent> q :close<CR>
|
591
|
+
|
592
|
+
" Restore the previous cpoptions settings
|
593
|
+
let &cpoptions = old_cpoptions
|
594
|
+
|
595
|
+
" Display the MRU list
|
596
|
+
if a:0 == 0
|
597
|
+
" No search pattern specified. Display the complete list
|
598
|
+
silent! 0put =s:MRU_files
|
599
|
+
else
|
600
|
+
" Display only the entries matching the specified pattern
|
601
|
+
" First try using it as a literal pattern
|
602
|
+
let m = filter(copy(s:MRU_files), 'stridx(v:val, a:1) != -1')
|
603
|
+
if len(m) == 0
|
604
|
+
" No match. Try using it as a regular expression
|
605
|
+
let m = filter(copy(s:MRU_files), 'v:val =~# a:1')
|
606
|
+
endif
|
607
|
+
silent! 0put =m
|
608
|
+
endif
|
609
|
+
|
610
|
+
" Move the cursor to the beginning of the file
|
611
|
+
normal! gg
|
612
|
+
|
613
|
+
setlocal nomodifiable
|
614
|
+
endfunction
|
615
|
+
|
616
|
+
" MRU_Complete
|
617
|
+
" Command-line completion function used by :MRU command
|
618
|
+
function! s:MRU_Complete(ArgLead, CmdLine, CursorPos)
|
619
|
+
if a:ArgLead == ''
|
620
|
+
" Return the list of MRU files
|
621
|
+
return s:MRU_files
|
622
|
+
else
|
623
|
+
return filter(copy(s:MRU_files), 'v:val =~? a:ArgLead')
|
624
|
+
endif
|
625
|
+
endfunction
|
626
|
+
|
627
|
+
" MRU_Cmd
|
628
|
+
" Function to handle the MRU command
|
629
|
+
function! s:MRU_Cmd(pat)
|
630
|
+
if a:pat == ''
|
631
|
+
" No arguments specified. Open the MRU window
|
632
|
+
call s:MRU_Open_Window()
|
633
|
+
return
|
634
|
+
endif
|
635
|
+
|
636
|
+
" Load the latest MRU file
|
637
|
+
call s:MRU_LoadList()
|
638
|
+
|
639
|
+
" Empty MRU list
|
640
|
+
if empty(s:MRU_files)
|
641
|
+
call s:MRU_Warn_Msg('MRU file list is empty')
|
642
|
+
return
|
643
|
+
endif
|
644
|
+
|
645
|
+
" First use the specified string as a literal string and search for
|
646
|
+
" filenames containing the string. If only one filename is found,
|
647
|
+
" then edit it.
|
648
|
+
let m = filter(copy(s:MRU_files), 'stridx(v:val, a:pat) != -1')
|
649
|
+
if len(m) > 0
|
650
|
+
if len(m) == 1
|
651
|
+
call s:MRU_Edit_File(m[0], 0)
|
652
|
+
return
|
653
|
+
endif
|
654
|
+
|
655
|
+
" More than one file matches. Try find an accurate match
|
656
|
+
let new_m = filter(m, 'v:val ==# a:pat')
|
657
|
+
if len(new_m) == 1
|
658
|
+
call s:MRU_Edit_File(new_m[0], 0)
|
659
|
+
return
|
660
|
+
endif
|
661
|
+
|
662
|
+
" Couldn't find an exact match, open the MRU window
|
663
|
+
call s:MRU_Open_Window(a:pat)
|
664
|
+
return
|
665
|
+
endif
|
666
|
+
|
667
|
+
" Use the specified string as a regular expression pattern and search
|
668
|
+
" for filenames matching the pattern
|
669
|
+
let m = filter(copy(s:MRU_files), 'v:val =~? a:pat')
|
670
|
+
|
671
|
+
if len(m) == 0
|
672
|
+
" No filenames matching the specified pattern are found
|
673
|
+
call s:MRU_Warn_Msg("MRU file list doesn't contain " .
|
674
|
+
\ "files containing " . a:pat)
|
675
|
+
return
|
676
|
+
endif
|
677
|
+
|
678
|
+
if len(m) == 1
|
679
|
+
call s:MRU_Edit_File(m[0], 0)
|
680
|
+
return
|
681
|
+
endif
|
682
|
+
|
683
|
+
call s:MRU_Open_Window(a:pat)
|
684
|
+
endfunction
|
685
|
+
|
686
|
+
function! s:MRU_add_files_to_menu(prefix, file_list)
|
687
|
+
for fname in a:file_list
|
688
|
+
" Escape special characters in the filename
|
689
|
+
let esc_fname = escape(fnamemodify(fname, ':t'), ".\\" .
|
690
|
+
\ s:esc_filename_chars)
|
691
|
+
let esc_fname = substitute(esc_fname, '&', '&&', 'g')
|
692
|
+
|
693
|
+
" Truncate the directory name if it is long
|
694
|
+
let dir_name = fnamemodify(fname, ':h')
|
695
|
+
let len = strlen(dir_name)
|
696
|
+
" Shorten long file names by adding only few characters from
|
697
|
+
" the beginning and end.
|
698
|
+
if len > 30
|
699
|
+
let dir_name = strpart(dir_name, 0, 10) .
|
700
|
+
\ '...' .
|
701
|
+
\ strpart(dir_name, len - 20)
|
702
|
+
endif
|
703
|
+
let esc_dir_name = escape(dir_name, ".\\" . s:esc_filename_chars)
|
704
|
+
let esc_dir_name = substitute(esc_dir_name, '&', '&&', 'g')
|
705
|
+
|
706
|
+
let menu_path = '&File.Recent\ Files.' . a:prefix . esc_fname .
|
707
|
+
\ '\ (' . esc_dir_name . ')'
|
708
|
+
let esc_mfname = s:MRU_escape_filename(fname)
|
709
|
+
exe 'anoremenu <silent> ' . menu_path .
|
710
|
+
\ " :call <SID>MRU_Edit_File('" . esc_mfname . "', 1)<CR>"
|
711
|
+
exe 'tmenu ' . menu_path . ' Edit file ' . esc_mfname
|
712
|
+
endfor
|
713
|
+
endfunction
|
714
|
+
|
715
|
+
" MRU_Refresh_Menu()
|
716
|
+
" Refresh the MRU menu
|
717
|
+
function! s:MRU_Refresh_Menu()
|
718
|
+
if !has('menu') || !g:MRU_Add_Menu
|
719
|
+
" No support for menus
|
720
|
+
return
|
721
|
+
endif
|
722
|
+
|
723
|
+
" Setup the cpoptions properly for the maps to work
|
724
|
+
let old_cpoptions = &cpoptions
|
725
|
+
set cpoptions&vim
|
726
|
+
|
727
|
+
" Remove the MRU menu
|
728
|
+
" To retain the teared-off MRU menu, we need to add a dummy entry
|
729
|
+
silent! unmenu &File.Recent\ Files
|
730
|
+
" The menu priority of the File menu is 10. If the MRU plugin runs
|
731
|
+
" first before menu.vim, the File menu order may not be correct.
|
732
|
+
" So specify the priority of the File menu here.
|
733
|
+
10noremenu &File.Recent\ Files.Dummy <Nop>
|
734
|
+
silent! unmenu! &File.Recent\ Files
|
735
|
+
|
736
|
+
anoremenu <silent> &File.Recent\ Files.Refresh\ list
|
737
|
+
\ :call <SID>MRU_LoadList()<CR>
|
738
|
+
exe 'tmenu File.Recent\ Files.Refresh\ list Reload the MRU file list from '
|
739
|
+
\ . s:MRU_escape_filename(g:MRU_File)
|
740
|
+
anoremenu File.Recent\ Files.-SEP1- :
|
741
|
+
|
742
|
+
" Add the filenames in the MRU list to the menu
|
743
|
+
let entry_cnt = len(s:MRU_files)
|
744
|
+
if entry_cnt > 10
|
745
|
+
" Split the MRU menu into sub-menus
|
746
|
+
for start_idx in range(0, entry_cnt, 10)
|
747
|
+
let last_idx = start_idx + 9
|
748
|
+
if last_idx >= entry_cnt
|
749
|
+
let last_idx = entry_cnt - 1
|
750
|
+
endif
|
751
|
+
let prefix = 'Files\ (' . (start_idx + 1) . '\.\.\.' .
|
752
|
+
\ (last_idx + 1) . ').'
|
753
|
+
call s:MRU_add_files_to_menu(prefix,
|
754
|
+
\ s:MRU_files[start_idx : last_idx])
|
755
|
+
endfor
|
756
|
+
else
|
757
|
+
call s:MRU_add_files_to_menu('', s:MRU_files)
|
758
|
+
endif
|
759
|
+
|
760
|
+
" Remove the dummy menu entry
|
761
|
+
unmenu &File.Recent\ Files.Dummy
|
762
|
+
|
763
|
+
" Restore the previous cpoptions settings
|
764
|
+
let &cpoptions = old_cpoptions
|
765
|
+
endfunction
|
766
|
+
|
767
|
+
" Load the MRU list on plugin startup
|
768
|
+
call s:MRU_LoadList()
|
769
|
+
|
770
|
+
" Autocommands to detect the most recently used files
|
771
|
+
autocmd BufRead * call s:MRU_AddFile(expand('<abuf>'))
|
772
|
+
autocmd BufNewFile * call s:MRU_AddFile(expand('<abuf>'))
|
773
|
+
autocmd BufWritePost * call s:MRU_AddFile(expand('<abuf>'))
|
774
|
+
|
775
|
+
" The ':vimgrep' command adds all the files searched to the buffer list.
|
776
|
+
" This also modifies the MRU list, even though the user didn't edit the
|
777
|
+
" files. Use the following autocmds to prevent this.
|
778
|
+
autocmd QuickFixCmdPre *vimgrep* let s:mru_list_locked = 1
|
779
|
+
autocmd QuickFixCmdPost *vimgrep* let s:mru_list_locked = 0
|
780
|
+
|
781
|
+
" Command to open the MRU window
|
782
|
+
command! -nargs=? -complete=customlist,s:MRU_Complete MRU
|
783
|
+
\ call s:MRU_Cmd(<q-args>)
|
784
|
+
|
785
|
+
" restore 'cpo'
|
786
|
+
let &cpo = s:cpo_save
|
787
|
+
unlet s:cpo_save
|