This commit is contained in:
parent
2ef74326f0
commit
71ca6d0ec8
3 changed files with 138 additions and 61 deletions
|
@ -14,6 +14,10 @@ Vim, then you should use an older version of the MRU plugin.
|
||||||
The recently used filenames are stored in a file specified by the Vim
|
The recently used filenames are stored in a file specified by the Vim
|
||||||
MRU_File variable.
|
MRU_File variable.
|
||||||
|
|
||||||
|
The Github repository for the MRU plugin is available at:
|
||||||
|
|
||||||
|
http://github.com/yegappan/mru
|
||||||
|
|
||||||
Usage
|
Usage
|
||||||
|
|
||||||
To list and edit files from the MRU list, you can use the ":MRU" command.
|
To list and edit files from the MRU list, you can use the ":MRU" command.
|
||||||
|
@ -36,7 +40,8 @@ previous window has a modified buffer or is the preview window or is used by
|
||||||
some other plugin, then the file is opened in a new window.
|
some other plugin, then the file is opened in a new window.
|
||||||
|
|
||||||
You can press the 'o' key to open the file name under the cursor in the
|
You can press the 'o' key to open the file name under the cursor in the
|
||||||
MRU window in a new window.
|
MRU window in a new window. You can also press <Shift-Enter> instead of 'o'
|
||||||
|
to open the file in a new window.
|
||||||
|
|
||||||
To open a file from the MRU window in read-only mode (view), press the 'v'
|
To open a file from the MRU window in read-only mode (view), press the 'v'
|
||||||
key.
|
key.
|
||||||
|
@ -46,19 +51,20 @@ file is already opened in a window in the current or in another tab, then
|
||||||
the cursor is moved to that tab. Otherwise, a new tab is opened.
|
the cursor is moved to that tab. Otherwise, a new tab is opened.
|
||||||
|
|
||||||
You can open multiple files from the MRU window by specifying a count before
|
You can open multiple files from the MRU window by specifying a count before
|
||||||
pressing '<Enter>' or 'v' or 'o' or 't'. You can also visually select
|
pressing '<Enter>' or 'v' or 'o' or 't'. You can also visually (using
|
||||||
multiple filenames and invoke the commands to open the files. Each selected
|
linewise visual mode) select multiple filenames and invoke the commands to
|
||||||
file will be opened in a separate window or tab.
|
open the files. Each selected file will be opened in a separate window or
|
||||||
|
tab.
|
||||||
|
|
||||||
You can press the 'u' key in the MRU window to update the file list. This is
|
You can press the 'u' key in the MRU window to update the file list. This is
|
||||||
useful if you keep the MRU window open always.
|
useful if you keep the MRU window open always.
|
||||||
|
|
||||||
You can close the MRU window by pressing the 'q' key or using one of the Vim
|
You can close the MRU window by pressing the 'q' key or the <Esc> key or
|
||||||
window commands.
|
using one of the Vim window commands.
|
||||||
|
|
||||||
To display only files matching a pattern from the MRU list in the MRU
|
To display only files matching a pattern from the MRU list in the MRU
|
||||||
window, you can specify a pattern to the ":MRU" command. For example, to
|
window, you can specify a pattern to the ":MRU" command. For example, to
|
||||||
display only file names containing "vim" in them, you can use the following
|
display only file names matching "vim" in them, you can use the following
|
||||||
command ":MRU vim". When you specify a partial file name and only one
|
command ":MRU vim". When you specify a partial file name and only one
|
||||||
matching filename is found, then the ":MRU" command will edit that file.
|
matching filename is found, then the ":MRU" command will edit that file.
|
||||||
|
|
||||||
|
@ -79,6 +85,16 @@ Whenever the MRU list changes, the MRU file is updated with the latest MRU
|
||||||
list. When you have multiple instances of Vim running at the same time, the
|
list. When you have multiple instances of Vim running at the same time, the
|
||||||
latest MRU list will show up in all the instances of Vim.
|
latest MRU list will show up in all the instances of Vim.
|
||||||
|
|
||||||
|
The MRUFilename syntax group is used to highlight the file names in the MRU
|
||||||
|
window. By default, this syntax group is linked to the Identifier highlight
|
||||||
|
group. You can change the highlight group by adding the following line in
|
||||||
|
your .vimrc:
|
||||||
|
|
||||||
|
highlight link MRUFileName LineNr
|
||||||
|
|
||||||
|
The MRU buffer uses the 'mru file type. You can use this file type to add
|
||||||
|
custom auto commands, syntax highlighting, etc.
|
||||||
|
|
||||||
Configuration
|
Configuration
|
||||||
|
|
||||||
By changing the following variables you can configure the behavior of this
|
By changing the following variables you can configure the behavior of this
|
||||||
|
@ -164,3 +180,13 @@ number of file names displayed in a single sub-menu:
|
||||||
|
|
||||||
let MRU_Max_Submenu_Entries = 15
|
let MRU_Max_Submenu_Entries = 15
|
||||||
|
|
||||||
|
In the MRU window, the filenames are displayed in two parts. The first part
|
||||||
|
contains the file name without the path and the second part contains the
|
||||||
|
full path to the file in parenthesis. This format is controlled by the
|
||||||
|
MRU_Filename_Format variable. If you prefer to change this to some other
|
||||||
|
format, then you can modify the MRU_Filename_Format variable. For example,
|
||||||
|
to display the full path without splitting it, you can set this variable
|
||||||
|
as shown below:
|
||||||
|
|
||||||
|
let MRU_Filename_Format={'formatter':'v:val', 'parser':'.*'}
|
||||||
|
|
|
@ -1,14 +1,14 @@
|
||||||
" File: mru.vim
|
" File: mru.vim
|
||||||
" Author: Yegappan Lakshmanan (yegappan AT yahoo DOT com)
|
" Author: Yegappan Lakshmanan (yegappan AT yahoo DOT com)
|
||||||
" Version: 3.4
|
" Version: 3.9
|
||||||
" Last Modified: April 13, 2012
|
" Last Modified: Feb 3, 2015
|
||||||
" Copyright: Copyright (C) 2003-2012 Yegappan Lakshmanan
|
" Copyright: Copyright (C) 2003-2015 Yegappan Lakshmanan
|
||||||
" Permission is hereby granted to use and distribute this code,
|
" License: Permission is hereby granted to use and distribute this code,
|
||||||
" with or without modifications, provided that this copyright
|
" with or without modifications, provided that this copyright
|
||||||
" notice is copied with it. Like anything else that's free,
|
" notice is copied with it. Like anything else that's free,
|
||||||
" mru.vim is provided *as is* and comes with no warranty of any
|
" mru.vim is provided *as is* and comes with no warranty of any
|
||||||
" kind, either expressed or implied. In no event will the copyright
|
" kind, either expressed or implied. In no event will the copyright
|
||||||
" holder be liable for any damamges resulting from the use of this
|
" holder be liable for any damages resulting from the use of this
|
||||||
" software.
|
" software.
|
||||||
"
|
"
|
||||||
" Overview
|
" Overview
|
||||||
|
@ -25,27 +25,19 @@
|
||||||
" The recently used filenames are stored in a file specified by the Vim
|
" The recently used filenames are stored in a file specified by the Vim
|
||||||
" MRU_File variable.
|
" MRU_File variable.
|
||||||
"
|
"
|
||||||
|
" The Github repository for the MRU plugin is available at:
|
||||||
|
"
|
||||||
|
" http://github.com/yegappan/mru
|
||||||
|
"
|
||||||
" Installation
|
" Installation
|
||||||
" ------------
|
" ------------
|
||||||
" 1. Copy the mru.vim file to one of the following directories:
|
" 1. Copy the mru.vim file to one of the following directories:
|
||||||
"
|
|
||||||
" $HOME/.vim/plugin - Unix like systems
|
" $HOME/.vim/plugin - Unix like systems
|
||||||
" $HOME/vimfiles/plugin - MS-Windows
|
" $HOME/vimfiles/plugin - MS-Windows
|
||||||
" $VIM:vimfiles:plugin - Macintosh
|
" $VIM:vimfiles:plugin - Macintosh
|
||||||
" $VIM/vimfiles/plugin - All
|
" $VIM/vimfiles/plugin - All
|
||||||
"
|
" 2. Restart Vim.
|
||||||
" Refer to the following Vim help topics for more information about Vim
|
" 3. You can use the ":MRU" command to list and edit the recently used files.
|
||||||
" plugins:
|
|
||||||
"
|
|
||||||
" :help add-plugin
|
|
||||||
" :help add-global-plugin
|
|
||||||
" :help runtimepath
|
|
||||||
"
|
|
||||||
" 2. Set the MRU_File Vim variable in the .vimrc file to the location of a
|
|
||||||
" file to store the most recently edited file names. This step is needed
|
|
||||||
" only if you want to change the default MRU filename.
|
|
||||||
" 3. Restart Vim.
|
|
||||||
" 4. You can use the ":MRU" command to list and edit the recently used files.
|
|
||||||
" In GUI Vim, you can use the 'File->Recent Files' menu to access the
|
" In GUI Vim, you can use the 'File->Recent Files' menu to access the
|
||||||
" recently used files.
|
" recently used files.
|
||||||
"
|
"
|
||||||
|
@ -75,7 +67,8 @@
|
||||||
" some other plugin, then the file is opened in a new window.
|
" some other plugin, then the file is opened in a new window.
|
||||||
"
|
"
|
||||||
" You can press the 'o' key to open the file name under the cursor in the
|
" You can press the 'o' key to open the file name under the cursor in the
|
||||||
" MRU window in a new window.
|
" MRU window in a new window. You can also press <Shift-Enter> instead of 'o'
|
||||||
|
" to open the file in a new window.
|
||||||
"
|
"
|
||||||
" To open a file from the MRU window in read-only mode (view), press the 'v'
|
" To open a file from the MRU window in read-only mode (view), press the 'v'
|
||||||
" key.
|
" key.
|
||||||
|
@ -85,15 +78,16 @@
|
||||||
" the cursor is moved to that tab. Otherwise, a new tab is opened.
|
" the cursor is moved to that tab. Otherwise, a new tab is opened.
|
||||||
"
|
"
|
||||||
" You can open multiple files from the MRU window by specifying a count before
|
" You can open multiple files from the MRU window by specifying a count before
|
||||||
" pressing '<Enter>' or 'v' or 'o' or 't'. You can also visually select
|
" pressing '<Enter>' or 'v' or 'o' or 't'. You can also visually (using
|
||||||
" multiple filenames and invoke the commands to open the files. Each selected
|
" linewise visual mode) select multiple filenames and invoke the commands to
|
||||||
" file will be opened in a separate window or tab.
|
" open the files. Each selected file will be opened in a separate window or
|
||||||
|
" tab.
|
||||||
"
|
"
|
||||||
" You can press the 'u' key in the MRU window to update the file list. This is
|
" You can press the 'u' key in the MRU window to update the file list. This is
|
||||||
" useful if you keep the MRU window open always.
|
" useful if you keep the MRU window open always.
|
||||||
"
|
"
|
||||||
" You can close the MRU window by pressing the 'q' key or using one of the Vim
|
" You can close the MRU window by pressing the 'q' key or the <Esc> key or
|
||||||
" window commands.
|
" using one of the Vim window commands.
|
||||||
"
|
"
|
||||||
" To display only files matching a pattern from the MRU list in the MRU
|
" To display only files matching a pattern from the MRU list in the MRU
|
||||||
" window, you can specify a pattern to the ":MRU" command. For example, to
|
" window, you can specify a pattern to the ":MRU" command. For example, to
|
||||||
|
@ -118,6 +112,16 @@
|
||||||
" list. When you have multiple instances of Vim running at the same time, the
|
" list. When you have multiple instances of Vim running at the same time, the
|
||||||
" latest MRU list will show up in all the instances of Vim.
|
" latest MRU list will show up in all the instances of Vim.
|
||||||
"
|
"
|
||||||
|
" The MRUFilename syntax group is used to highlight the file names in the MRU
|
||||||
|
" window. By default, this syntax group is linked to the Identifier highlight
|
||||||
|
" group. You can change the highlight group by adding the following line in
|
||||||
|
" your .vimrc:
|
||||||
|
"
|
||||||
|
" highlight link MRUFileName LineNr
|
||||||
|
"
|
||||||
|
" The MRU buffer uses the 'mru file type. You can use this file type to add
|
||||||
|
" custom auto commands, syntax highlighting, etc.
|
||||||
|
"
|
||||||
" Configuration
|
" Configuration
|
||||||
" -------------
|
" -------------
|
||||||
" By changing the following variables you can configure the behavior of this
|
" By changing the following variables you can configure the behavior of this
|
||||||
|
@ -203,6 +207,17 @@
|
||||||
"
|
"
|
||||||
" let MRU_Max_Submenu_Entries = 15
|
" let MRU_Max_Submenu_Entries = 15
|
||||||
"
|
"
|
||||||
|
" In the MRU window, the filenames are displayed in two parts. The first part
|
||||||
|
" contains the file name without the path and the second part contains the
|
||||||
|
" full path to the file in parenthesis. This format is controlled by the
|
||||||
|
" MRU_Filename_Format variable. If you prefer to change this to some other
|
||||||
|
" format, then you can modify the MRU_Filename_Format variable. For example,
|
||||||
|
" to display the full path without splitting it, you can set this variable
|
||||||
|
" as shown below:
|
||||||
|
"
|
||||||
|
" let MRU_Filename_Format =
|
||||||
|
" \ {'formatter':'v:val', 'parser':'.*', 'syntax': '[^/\\]\+$'}
|
||||||
|
"
|
||||||
" ****************** Do not modify after this line ************************
|
" ****************** Do not modify after this line ************************
|
||||||
if exists('loaded_mru')
|
if exists('loaded_mru')
|
||||||
finish
|
finish
|
||||||
|
@ -296,6 +311,21 @@ if !exists('MRU_Open_File_Use_Tabs')
|
||||||
let MRU_Open_File_Use_Tabs = 0
|
let MRU_Open_File_Use_Tabs = 0
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
" Format of the file names displayed in the MRU window.
|
||||||
|
" The default is to display the filename followed by the complete path to the
|
||||||
|
" file in parenthesis. This variable controls the expressions used to format
|
||||||
|
" and parse the path. This can be changed to display the filenames in a
|
||||||
|
" different format. The 'formatter' specifies how to split/format the filename
|
||||||
|
" and 'parser' specifies how to read the filename back; 'syntax' matches the
|
||||||
|
" part to be highlighted.
|
||||||
|
if !exists('MRU_Filename_Format')
|
||||||
|
let MRU_Filename_Format = {
|
||||||
|
\ 'formatter': 'fnamemodify(v:val, ":t") . " (" . v:val . ")"',
|
||||||
|
\ 'parser': '(\zs.*\ze)',
|
||||||
|
\ 'syntax': '^.\{-}\ze('
|
||||||
|
\}
|
||||||
|
endif
|
||||||
|
|
||||||
" Control to temporarily lock the MRU list. Used to prevent files from
|
" Control to temporarily lock the MRU list. Used to prevent files from
|
||||||
" getting added to the MRU list when the ':vimgrep' command is executed.
|
" getting added to the MRU list when the ':vimgrep' command is executed.
|
||||||
let s:mru_list_locked = 0
|
let s:mru_list_locked = 0
|
||||||
|
@ -419,7 +449,11 @@ endfunction
|
||||||
" that should be escaped (for security reasons)
|
" that should be escaped (for security reasons)
|
||||||
let s:esc_filename_chars = ' *?[{`$%#"|!<>();&' . "'\t\n"
|
let s:esc_filename_chars = ' *?[{`$%#"|!<>();&' . "'\t\n"
|
||||||
function! s:MRU_escape_filename(fname)
|
function! s:MRU_escape_filename(fname)
|
||||||
return escape(a:fname, s:esc_filename_chars)
|
if exists("*fnameescape")
|
||||||
|
return fnameescape(a:fname)
|
||||||
|
else
|
||||||
|
return escape(a:fname, s:esc_filename_chars)
|
||||||
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
" MRU_Edit_File {{{1
|
" MRU_Edit_File {{{1
|
||||||
|
@ -449,11 +483,13 @@ function! s:MRU_Edit_File(filename, sanitized)
|
||||||
exe winnum . 'wincmd w'
|
exe winnum . 'wincmd w'
|
||||||
endif
|
endif
|
||||||
else
|
else
|
||||||
if &modified || &buftype != '' || &previewwindow
|
if !&hidden && (&modified || &buftype != '' || &previewwindow)
|
||||||
" Current buffer has unsaved changes or is a special buffer or is
|
" Current buffer has unsaved changes or is a special buffer or is
|
||||||
" the preview window. So open the file in a new window
|
" the preview window. The 'hidden' option is also not set.
|
||||||
|
" So open the file in a new window.
|
||||||
exe 'split ' . esc_fname
|
exe 'split ' . esc_fname
|
||||||
else
|
else
|
||||||
|
" The current file can be replaced with the selected file.
|
||||||
exe 'edit ' . esc_fname
|
exe 'edit ' . esc_fname
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
@ -484,7 +520,7 @@ function! s:MRU_Open_File_In_Tab(fname, esc_fname)
|
||||||
exe 'tabnext ' . i
|
exe 'tabnext ' . i
|
||||||
else
|
else
|
||||||
" Open a new tab as the last tab page
|
" Open a new tab as the last tab page
|
||||||
exe '999tabnew ' . a:esc_fname
|
exe '$tabnew ' . a:esc_fname
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
@ -503,8 +539,7 @@ endfunction
|
||||||
" 'edit' - Edit the file as a regular file
|
" 'edit' - Edit the file as a regular file
|
||||||
" multi : Specifies whether a single file or multiple files need to be
|
" multi : Specifies whether a single file or multiple files need to be
|
||||||
" opened.
|
" opened.
|
||||||
" open_type : Specifies where to open the file. Can be one of 'useopen' or
|
" open_type : Specifies where to open the file.
|
||||||
" 'newwin' or 'newtab'.
|
|
||||||
" useopen - If the file is already present in a window, then
|
" useopen - If the file is already present in a window, then
|
||||||
" jump to that window. Otherwise, open the file in
|
" jump to that window. Otherwise, open the file in
|
||||||
" the previous window.
|
" the previous window.
|
||||||
|
@ -512,21 +547,25 @@ endfunction
|
||||||
" newwin_vert - Open the file in a new vertical window.
|
" newwin_vert - Open the file in a new vertical window.
|
||||||
" newtab - Open the file in a new tab. If the file is already
|
" newtab - Open the file in a new tab. If the file is already
|
||||||
" opened in a tab, then jump to that tab.
|
" opened in a tab, then jump to that tab.
|
||||||
|
" preview - Open the file in the preview window
|
||||||
function! s:MRU_Window_Edit_File(fname, multi, edit_type, open_type)
|
function! s:MRU_Window_Edit_File(fname, multi, edit_type, open_type)
|
||||||
let esc_fname = s:MRU_escape_filename(a:fname)
|
let esc_fname = s:MRU_escape_filename(a:fname)
|
||||||
|
|
||||||
if a:open_type == 'newwin_horiz'
|
if a:open_type ==# 'newwin_horiz'
|
||||||
" Edit the file in a new horizontally split window above the previous
|
" Edit the file in a new horizontally split window above the previous
|
||||||
" window
|
" window
|
||||||
wincmd p
|
wincmd p
|
||||||
exe 'belowright new ' . esc_fname
|
exe 'belowright new ' . esc_fname
|
||||||
elseif a:open_type == 'newwin_vert'
|
elseif a:open_type ==# 'newwin_vert'
|
||||||
" Edit the file in a new vertically split window above the previous
|
" Edit the file in a new vertically split window above the previous
|
||||||
" window
|
" window
|
||||||
wincmd p
|
wincmd p
|
||||||
exe 'belowright vnew ' . esc_fname
|
exe 'belowright vnew ' . esc_fname
|
||||||
elseif a:open_type == 'newtab' || g:MRU_Open_File_Use_Tabs
|
elseif a:open_type ==# 'newtab' || g:MRU_Open_File_Use_Tabs
|
||||||
call s:MRU_Open_File_In_Tab(a:fname, esc_fname)
|
call s:MRU_Open_File_In_Tab(a:fname, esc_fname)
|
||||||
|
elseif a:open_type ==# 'preview'
|
||||||
|
" Edit the file in the preview window
|
||||||
|
exe 'topleft pedit ' . esc_fname
|
||||||
else
|
else
|
||||||
" If the selected file is already open in one of the windows,
|
" If the selected file is already open in one of the windows,
|
||||||
" jump to it
|
" jump to it
|
||||||
|
@ -553,7 +592,7 @@ function! s:MRU_Window_Edit_File(fname, multi, edit_type, open_type)
|
||||||
|
|
||||||
let split_window = 0
|
let split_window = 0
|
||||||
|
|
||||||
if &modified || &previewwindow || a:multi
|
if (!&hidden && (&modified || &previewwindow)) || a:multi
|
||||||
" Current buffer has unsaved changes or is the preview window
|
" Current buffer has unsaved changes or is the preview window
|
||||||
" or the user is opening multiple files
|
" or the user is opening multiple files
|
||||||
" So open the file in a new window
|
" So open the file in a new window
|
||||||
|
@ -572,13 +611,13 @@ function! s:MRU_Window_Edit_File(fname, multi, edit_type, open_type)
|
||||||
if split_window
|
if split_window
|
||||||
" Current buffer has unsaved changes or is a special buffer or
|
" Current buffer has unsaved changes or is a special buffer or
|
||||||
" is the preview window. So open the file in a new window
|
" is the preview window. So open the file in a new window
|
||||||
if a:edit_type == 'edit'
|
if a:edit_type ==# 'edit'
|
||||||
exe 'split ' . esc_fname
|
exe 'split ' . esc_fname
|
||||||
else
|
else
|
||||||
exe 'sview ' . esc_fname
|
exe 'sview ' . esc_fname
|
||||||
endif
|
endif
|
||||||
else
|
else
|
||||||
if a:edit_type == 'edit'
|
if a:edit_type ==# 'edit'
|
||||||
exe 'edit ' . esc_fname
|
exe 'edit ' . esc_fname
|
||||||
else
|
else
|
||||||
exe 'view ' . esc_fname
|
exe 'view ' . esc_fname
|
||||||
|
@ -619,7 +658,7 @@ function! s:MRU_Select_File_Cmd(opt) range
|
||||||
endif
|
endif
|
||||||
|
|
||||||
" The text in the MRU window contains the filename in parenthesis
|
" The text in the MRU window contains the filename in parenthesis
|
||||||
let file = matchstr(f, '(\zs.*\ze)')
|
let file = matchstr(f, g:MRU_Filename_Format.parser)
|
||||||
|
|
||||||
call s:MRU_Window_Edit_File(file, multi, edit_type, open_type)
|
call s:MRU_Window_Edit_File(file, multi, edit_type, open_type)
|
||||||
|
|
||||||
|
@ -707,17 +746,20 @@ function! s:MRU_Open_Window(...)
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
setlocal modifiable
|
||||||
|
|
||||||
" Mark the buffer as scratch
|
" Mark the buffer as scratch
|
||||||
setlocal buftype=nofile
|
setlocal buftype=nofile
|
||||||
setlocal bufhidden=delete
|
setlocal bufhidden=delete
|
||||||
setlocal noswapfile
|
setlocal noswapfile
|
||||||
setlocal nowrap
|
setlocal nowrap
|
||||||
setlocal nobuflisted
|
setlocal nobuflisted
|
||||||
|
" Set the 'filetype' to 'mru'. This allows the user to apply custom
|
||||||
|
" syntax highlighting or other changes to the MRU bufer.
|
||||||
|
setlocal filetype=mru
|
||||||
" Use fixed height for the MRU window
|
" Use fixed height for the MRU window
|
||||||
setlocal winfixheight
|
setlocal winfixheight
|
||||||
|
|
||||||
call MRU_SetupSyntax()
|
|
||||||
|
|
||||||
" Setup the cpoptions properly for the maps to work
|
" Setup the cpoptions properly for the maps to work
|
||||||
let old_cpoptions = &cpoptions
|
let old_cpoptions = &cpoptions
|
||||||
set cpoptions&vim
|
set cpoptions&vim
|
||||||
|
@ -731,6 +773,10 @@ function! s:MRU_Open_Window(...)
|
||||||
\ :call <SID>MRU_Select_File_Cmd('edit,newwin_horiz')<CR>
|
\ :call <SID>MRU_Select_File_Cmd('edit,newwin_horiz')<CR>
|
||||||
vnoremap <buffer> <silent> o
|
vnoremap <buffer> <silent> o
|
||||||
\ :call <SID>MRU_Select_File_Cmd('edit,newwin_horiz')<CR>
|
\ :call <SID>MRU_Select_File_Cmd('edit,newwin_horiz')<CR>
|
||||||
|
nnoremap <buffer> <silent> <S-CR>
|
||||||
|
\ :call <SID>MRU_Select_File_Cmd('edit,newwin_horiz')<CR>
|
||||||
|
vnoremap <buffer> <silent> <S-CR>
|
||||||
|
\ :call <SID>MRU_Select_File_Cmd('edit,newwin_horiz')<CR>
|
||||||
nnoremap <buffer> <silent> O
|
nnoremap <buffer> <silent> O
|
||||||
\ :call <SID>MRU_Select_File_Cmd('edit,newwin_vert')<CR>
|
\ :call <SID>MRU_Select_File_Cmd('edit,newwin_vert')<CR>
|
||||||
vnoremap <buffer> <silent> O
|
vnoremap <buffer> <silent> O
|
||||||
|
@ -741,6 +787,14 @@ function! s:MRU_Open_Window(...)
|
||||||
\ :call <SID>MRU_Select_File_Cmd('edit,newtab')<CR>
|
\ :call <SID>MRU_Select_File_Cmd('edit,newtab')<CR>
|
||||||
nnoremap <buffer> <silent> v
|
nnoremap <buffer> <silent> v
|
||||||
\ :call <SID>MRU_Select_File_Cmd('view,useopen')<CR>
|
\ :call <SID>MRU_Select_File_Cmd('view,useopen')<CR>
|
||||||
|
nnoremap <buffer> <silent> p
|
||||||
|
\ :call <SID>MRU_Select_File_Cmd('view,preview')<CR>
|
||||||
|
vnoremap <buffer> <silent> p
|
||||||
|
\ :<C-u>if line("'<") == line("'>")<Bar>
|
||||||
|
\ call <SID>MRU_Select_File_Cmd('open,preview')<Bar>
|
||||||
|
\ else<Bar>
|
||||||
|
\ echoerr "Only a single file can be previewed"<Bar>
|
||||||
|
\ endif<CR>
|
||||||
nnoremap <buffer> <silent> u :MRU<CR>
|
nnoremap <buffer> <silent> u :MRU<CR>
|
||||||
nnoremap <buffer> <silent> <2-LeftMouse>
|
nnoremap <buffer> <silent> <2-LeftMouse>
|
||||||
\ :call <SID>MRU_Select_File_Cmd('edit,useopen')<CR>
|
\ :call <SID>MRU_Select_File_Cmd('edit,useopen')<CR>
|
||||||
|
@ -764,16 +818,22 @@ function! s:MRU_Open_Window(...)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
" Get the tail part of the file name (without the directory) and display
|
" Get the tail part of the file name (without the directory) and display
|
||||||
" it along with the full path
|
" it along with the full path in parenthesis.
|
||||||
let output = map(m, 'fnamemodify(v:val, ":t") . " (" . v:val . ")"')
|
let output = map(m, g:MRU_Filename_Format.formatter)
|
||||||
silent! 0put =output
|
silent! 0put =output
|
||||||
|
|
||||||
" Delete the empty line at the end of the buffer
|
" Delete the empty line at the end of the buffer
|
||||||
$delete
|
silent! $delete _
|
||||||
|
|
||||||
" Move the cursor to the beginning of the file
|
" Move the cursor to the beginning of the file
|
||||||
normal! gg
|
normal! gg
|
||||||
|
|
||||||
|
" Add syntax highlighting for the file names
|
||||||
|
if has_key(g:MRU_Filename_Format, 'syntax')
|
||||||
|
exe "syntax match MRUFileName '" . g:MRU_Filename_Format.syntax . "'"
|
||||||
|
highlight default link MRUFileName Identifier
|
||||||
|
endif
|
||||||
|
|
||||||
setlocal nomodifiable
|
setlocal nomodifiable
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
@ -921,7 +981,7 @@ function! s:MRU_Refresh_Menu()
|
||||||
let entry_cnt = len(s:MRU_files)
|
let entry_cnt = len(s:MRU_files)
|
||||||
if entry_cnt > g:MRU_Max_Menu_Entries
|
if entry_cnt > g:MRU_Max_Menu_Entries
|
||||||
" Show only MRU_Max_Menu_Entries file names in the menu
|
" Show only MRU_Max_Menu_Entries file names in the menu
|
||||||
let mru_list = s:MRU_files[1 : g:MRU_Max_Menu_Entries]
|
let mru_list = s:MRU_files[0 : g:MRU_Max_Menu_Entries - 1]
|
||||||
let entry_cnt = g:MRU_Max_Menu_Entries
|
let entry_cnt = g:MRU_Max_Menu_Entries
|
||||||
else
|
else
|
||||||
let mru_list = s:MRU_files
|
let mru_list = s:MRU_files
|
||||||
|
@ -949,16 +1009,6 @@ function! s:MRU_Refresh_Menu()
|
||||||
let &cpoptions = old_cpoptions
|
let &cpoptions = old_cpoptions
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
" Setup syntax highlight
|
|
||||||
function! MRU_SetupSyntax()
|
|
||||||
if has("syntax")
|
|
||||||
syn match mruName /.\+\s/
|
|
||||||
syn match mruDir /(.\+)/
|
|
||||||
hi def link mruDir Folded
|
|
||||||
hi def link mruName String
|
|
||||||
endif
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
" Load the MRU list on plugin startup
|
" Load the MRU list on plugin startup
|
||||||
call s:MRU_LoadList()
|
call s:MRU_LoadList()
|
||||||
|
|
|
@ -52,6 +52,7 @@ vim-pug https://github.com/digitaltoad/vim-pug
|
||||||
vim-yankstack https://github.com/maxbrunsfeld/vim-yankstack
|
vim-yankstack https://github.com/maxbrunsfeld/vim-yankstack
|
||||||
lightline.vim https://github.com/itchyny/lightline.vim
|
lightline.vim https://github.com/itchyny/lightline.vim
|
||||||
tpope-vim-abolish https://github.com/tpope/tpope-vim-abolish
|
tpope-vim-abolish https://github.com/tpope/tpope-vim-abolish
|
||||||
|
mru.vim https://github.com/vim-scripts/mru.vim
|
||||||
""".strip()
|
""".strip()
|
||||||
|
|
||||||
GITHUB_ZIP = '%s/archive/master.zip'
|
GITHUB_ZIP = '%s/archive/master.zip'
|
||||||
|
|
Loading…
Reference in a new issue