Ver código fonte

add and document preview and fullscreen option (#65)

Inspired by [0]

Links:

[0]: https://github.com/mg979/vim-mini-plugins/blob/master/plugin/mru.vim
Enno 1 ano atrás
pai
commit
b6718c95da
2 arquivos alterados com 21 adições e 7 exclusões
  1. 6 1
      doc/mru.txt
  2. 15 6
      plugin/mru.vim

+ 6 - 1
doc/mru.txt

@@ -454,7 +454,12 @@ To select a file from the MRU file list using FZF, run the following command:
 >
 	:FZFMru
 <
-This will invoke FZF to select a file from the MRU list.
+This will invoke FZF to select a file from the MRU list. With a bang :FZFMru!
+the FZF menu will open fullscreen. With
+
+      	let MRU_FZF_Preview = 1
+
+a preview window is shown if the fzf.vim plug-in is installed.
 
 ==============================================================================
 

+ 15 - 6
plugin/mru.vim

@@ -1,7 +1,7 @@
 " File: mru.vim
 " Author: Yegappan Lakshmanan (yegappan AT yahoo DOT com)
 " Version: 3.11
-" Last Modified: October 16, 2022
+" Last Modified: June 06, 2024
 " Copyright: Copyright (C) 2003-2022 Yegappan Lakshmanan
 " License:   Permission is hereby granted to use and distribute this code,
 "            with or without modifications, provided that this copyright
@@ -122,6 +122,10 @@ if !exists('MRU_FuzzyMatch')
   endif
 endif
 
+if !exists('MRU_FZF_Preview')
+  let MRU_FZF_Preview = 0
+endif
+
 " Controls whether the alternate file (:help alternate-file) is set when the
 " plugin is loaded to the first file in the MRU list. Default is to set the
 " alternate file.
@@ -1104,7 +1108,7 @@ func s:MRU_FZF_EditFile(fname) abort
   call s:MRU_Window_Edit_File(a:fname, 0, 'edit', 'useopen')
 endfunc
 
-func s:MRU_FZF_Run() abort
+func s:MRU_FZF_Run(bang) abort
   if !exists('*fzf#run')
     call s:MRU_Warn_Msg('FZF plugin is not present')
     return
@@ -1113,11 +1117,16 @@ func s:MRU_FZF_Run() abort
   " Load the latest MRU list
   call s:MRU_LoadList()
 
-  call fzf#run(fzf#wrap({'source' : s:MRU_files,
-    \ 'options' : '--no-sort',
-    \ 'sink' : function('s:MRU_FZF_EditFile')}, 0))
+  let dict = {'source' : s:MRU_files,
+            \ 'options' : '--no-sort --prompt="MRU> " ' .. $FZF_DEFAULT_OPTS,
+            \ 'sink' : function('s:MRU_FZF_EditFile')}
+   if g:MRU_FZF_Preview && exists('*fzf#complete') " fzf.vim plugin present
+      call fzf#vim#files('', fzf#vim#with_preview(dict), a:bang)
+   else
+      call fzf#run(fzf#wrap(dict, a:bang))
+   endif
 endfunc
-command! -nargs=0 FZFMru call s:MRU_FZF_Run()
+command! -bang -nargs=0 FZFMru call s:MRU_FZF_Run(<bang>0)
 
 " }}}