Просмотр исходного кода

Add `split`, `vsplit` actions for `BufExplorer()`.

This addresses several issues:

- Issue #3, "Can <leader>\be do a toggle instead?".
- Issue #94, "Add variable setting, instead of command for
  BufExplorerVerticalSplit".
- Issue #106, "Support toggle for vertical/horizontal splits".

The ability to toggle BufExplorer using various split modes has been a
popular request.  This may be done now via:

```vim
:ToggleBufExplorer split
:ToggleBufExplorer vsplit
```

It's also possible now to adjust the default split mode for
`:BufExplorer` to be a preferred split mode (say, `vsplit`) via:

```vim
let g:bufExplorerDefaultAction = 'vsplit'
```
Michael Henry 9 месяцев назад
Родитель
Сommit
8212aad6f3
1 измененных файлов с 8 добавлено и 12 удалено
  1. 8 12
      plugin/bufexplorer.vim

+ 8 - 12
plugin/bufexplorer.vim

@@ -97,6 +97,8 @@ endif
 let s:actions = [
 let s:actions = [
         \ 'current',
         \ 'current',
         \ 'close',
         \ 'close',
+        \ 'split',
+        \ 'vsplit',
         \ ]
         \ ]
 
 
 " Command-line completion function for `s:actions`.
 " Command-line completion function for `s:actions`.
@@ -134,7 +136,6 @@ let s:name = '[BufExplorer]'
 let s:bufExplorerBuffer = 0
 let s:bufExplorerBuffer = 0
 let s:running = 0
 let s:running = 0
 let s:sort_by = ["number", "name", "fullpath", "mru", "extension"]
 let s:sort_by = ["number", "name", "fullpath", "mru", "extension"]
-let s:splitMode = ""
 let s:didSplit = 0
 let s:didSplit = 0
 let s:types = ["fullname", "homename", "path", "relativename", "relativepath", "shortname"]
 let s:types = ["fullname", "homename", "path", "relativename", "relativepath", "shortname"]
 
 
@@ -541,7 +542,6 @@ function! s:Cleanup()
     endif
     endif
 
 
     let s:running = 0
     let s:running = 0
-    let s:splitMode = ""
     let s:didSplit = 0
     let s:didSplit = 0
 
 
     delmarks!
     delmarks!
@@ -572,16 +572,12 @@ endfunction
 
 
 " BufExplorerHorizontalSplit {{{2
 " BufExplorerHorizontalSplit {{{2
 function! BufExplorerHorizontalSplit()
 function! BufExplorerHorizontalSplit()
-    let s:splitMode = "sp"
-    execute "BufExplorer"
-    let s:splitMode = ""
+    call BufExplorer('split')
 endfunction
 endfunction
 
 
 " BufExplorerVerticalSplit {{{2
 " BufExplorerVerticalSplit {{{2
 function! BufExplorerVerticalSplit()
 function! BufExplorerVerticalSplit()
-    let s:splitMode = "vsp"
-    execute "BufExplorer"
-    let s:splitMode = ""
+    call BufExplorer('vsplit')
 endfunction
 endfunction
 
 
 " ToggleBufExplorer {{{2
 " ToggleBufExplorer {{{2
@@ -662,19 +658,19 @@ function! BufExplorer(...)
     call s:MRUGarbageCollectTabs()
     call s:MRUGarbageCollectTabs()
 
 
     " We may have to split the current window.
     " We may have to split the current window.
-    if s:splitMode != ""
+    if action != 'current'
         " Save off the original settings.
         " Save off the original settings.
         let [_splitbelow, _splitright] = [&splitbelow, &splitright]
         let [_splitbelow, _splitright] = [&splitbelow, &splitright]
 
 
         " Set the setting to ours.
         " Set the setting to ours.
         let [&splitbelow, &splitright] = [g:bufExplorerSplitBelow, g:bufExplorerSplitRight]
         let [&splitbelow, &splitright] = [g:bufExplorerSplitBelow, g:bufExplorerSplitRight]
-        let _size = (s:splitMode == "sp") ? g:bufExplorerSplitHorzSize : g:bufExplorerSplitVertSize
+        let _size = (action == "split") ? g:bufExplorerSplitHorzSize : g:bufExplorerSplitVertSize
 
 
         " Split the window either horizontally or vertically.
         " Split the window either horizontally or vertically.
         if _size <= 0
         if _size <= 0
-            execute 'keepalt ' . s:splitMode
+            execute 'keepalt ' . action
         else
         else
-            execute 'keepalt ' . _size . s:splitMode
+            execute 'keepalt ' . _size . action
         endif
         endif
 
 
         " Restore the original settings.
         " Restore the original settings.