|
@@ -117,7 +117,6 @@ endfunction
|
|
|
" Script variables {{{2
|
|
" Script variables {{{2
|
|
|
let s:MRU_Exclude_List = ["[BufExplorer]","__MRU_Files__","[Buf\ List]"]
|
|
let s:MRU_Exclude_List = ["[BufExplorer]","__MRU_Files__","[Buf\ List]"]
|
|
|
let s:name = '[BufExplorer]'
|
|
let s:name = '[BufExplorer]'
|
|
|
-let s:originBuffer = 0
|
|
|
|
|
" Buffer number of the BufExplorer window.
|
|
" Buffer number of the BufExplorer window.
|
|
|
let s:bufExplorerBuffer = 0
|
|
let s:bufExplorerBuffer = 0
|
|
|
let s:running = 0
|
|
let s:running = 0
|
|
@@ -600,9 +599,8 @@ function! BufExplorer()
|
|
|
return
|
|
return
|
|
|
endif
|
|
endif
|
|
|
|
|
|
|
|
- " Add zero to ensure the variable is treated as a number.
|
|
|
|
|
- let s:originBuffer = bufnr("%") + 0
|
|
|
|
|
let s:tabIdAtLaunch = s:MRUEnsureTabId(tabpagenr())
|
|
let s:tabIdAtLaunch = s:MRUEnsureTabId(tabpagenr())
|
|
|
|
|
+ let s:windowAtLaunch = winnr()
|
|
|
|
|
|
|
|
" Forget any cached MRU ordering from previous invocations.
|
|
" Forget any cached MRU ordering from previous invocations.
|
|
|
unlet! s:mruOrder
|
|
unlet! s:mruOrder
|
|
@@ -661,6 +659,9 @@ endfunction
|
|
|
" Tracks `tabId` at BufExplorer launch.
|
|
" Tracks `tabId` at BufExplorer launch.
|
|
|
let s:tabIdAtLaunch = ''
|
|
let s:tabIdAtLaunch = ''
|
|
|
|
|
|
|
|
|
|
+" Tracks window number at BufExplorer launch.
|
|
|
|
|
+let s:windowAtLaunch = 0
|
|
|
|
|
+
|
|
|
" DisplayBufferList {{{2
|
|
" DisplayBufferList {{{2
|
|
|
function! s:DisplayBufferList()
|
|
function! s:DisplayBufferList()
|
|
|
setlocal buftype=nofile
|
|
setlocal buftype=nofile
|
|
@@ -704,6 +705,7 @@ function! s:MapKeys()
|
|
|
nnoremap <silent> <buffer> <Plug>(BufExplorer_Close) :call <SID>Close()<CR>
|
|
nnoremap <silent> <buffer> <Plug>(BufExplorer_Close) :call <SID>Close()<CR>
|
|
|
nnoremap <silent> <buffer> <Plug>(BufExplorer_OpenBuffer) :call <SID>SelectBuffer()<CR>
|
|
nnoremap <silent> <buffer> <Plug>(BufExplorer_OpenBuffer) :call <SID>SelectBuffer()<CR>
|
|
|
nnoremap <silent> <buffer> <Plug>(BufExplorer_OpenBufferAsk) :call <SID>SelectBuffer("ask")<CR>
|
|
nnoremap <silent> <buffer> <Plug>(BufExplorer_OpenBufferAsk) :call <SID>SelectBuffer("ask")<CR>
|
|
|
|
|
+ nnoremap <silent> <buffer> <Plug>(BufExplorer_OpenBufferOriginalWindow) :call <SID>SelectBuffer("original_window")<CR>
|
|
|
nnoremap <silent> <buffer> <Plug>(BufExplorer_OpenBufferSplitAbove) :call <SID>SelectBuffer("split", "st")<CR>
|
|
nnoremap <silent> <buffer> <Plug>(BufExplorer_OpenBufferSplitAbove) :call <SID>SelectBuffer("split", "st")<CR>
|
|
|
nnoremap <silent> <buffer> <Plug>(BufExplorer_OpenBufferSplitBelow) :call <SID>SelectBuffer("split", "sb")<CR>
|
|
nnoremap <silent> <buffer> <Plug>(BufExplorer_OpenBufferSplitBelow) :call <SID>SelectBuffer("split", "sb")<CR>
|
|
|
nnoremap <silent> <buffer> <Plug>(BufExplorer_OpenBufferSplitLeft) :call <SID>SelectBuffer("split", "vl")<CR>
|
|
nnoremap <silent> <buffer> <Plug>(BufExplorer_OpenBufferSplitLeft) :call <SID>SelectBuffer("split", "vl")<CR>
|
|
@@ -737,6 +739,7 @@ function! s:MapKeys()
|
|
|
nmap <nowait> <buffer> f <Plug>(BufExplorer_OpenBufferSplitBelow)
|
|
nmap <nowait> <buffer> f <Plug>(BufExplorer_OpenBufferSplitBelow)
|
|
|
nmap <nowait> <buffer> F <Plug>(BufExplorer_OpenBufferSplitAbove)
|
|
nmap <nowait> <buffer> F <Plug>(BufExplorer_OpenBufferSplitAbove)
|
|
|
nmap <nowait> <buffer> o <Plug>(BufExplorer_OpenBuffer)
|
|
nmap <nowait> <buffer> o <Plug>(BufExplorer_OpenBuffer)
|
|
|
|
|
+ nmap <nowait> <buffer> O <Plug>(BufExplorer_OpenBufferOriginalWindow)
|
|
|
nmap <nowait> <buffer> p <Plug>(BufExplorer_ToggleSplitOutPathName)
|
|
nmap <nowait> <buffer> p <Plug>(BufExplorer_ToggleSplitOutPathName)
|
|
|
nmap <nowait> <buffer> q <Plug>(BufExplorer_Close)
|
|
nmap <nowait> <buffer> q <Plug>(BufExplorer_Close)
|
|
|
nmap <nowait> <buffer> r <Plug>(BufExplorer_ToggleReverseSort)
|
|
nmap <nowait> <buffer> r <Plug>(BufExplorer_ToggleReverseSort)
|
|
@@ -862,6 +865,7 @@ function! s:CreateHelp()
|
|
|
call add(header, '" D : wipe buffer')
|
|
call add(header, '" D : wipe buffer')
|
|
|
call add(header, '" F : open buffer in another window above the current')
|
|
call add(header, '" F : open buffer in another window above the current')
|
|
|
call add(header, '" f : open buffer in another window below the current')
|
|
call add(header, '" f : open buffer in another window below the current')
|
|
|
|
|
+ call add(header, '" O : open buffer in original window')
|
|
|
call add(header, '" p : toggle splitting of file and path name')
|
|
call add(header, '" p : toggle splitting of file and path name')
|
|
|
call add(header, '" q : quit')
|
|
call add(header, '" q : quit')
|
|
|
call add(header, '" r : reverse sort')
|
|
call add(header, '" r : reverse sort')
|
|
@@ -1162,6 +1166,15 @@ function! s:MakeLines(table)
|
|
|
endfunction
|
|
endfunction
|
|
|
|
|
|
|
|
" SelectBuffer {{{2
|
|
" SelectBuffer {{{2
|
|
|
|
|
+" Valid arguments:
|
|
|
|
|
+" `()` Open in current window.
|
|
|
|
|
+" `("ask")` Prompt for buffer, then open in current window.
|
|
|
|
|
+" `("original_window")` Open in original window.
|
|
|
|
|
+" `("split", "st")` Open in horizontal split above current window.
|
|
|
|
|
+" `("split", "sb")` Open in horizontal split below current window.
|
|
|
|
|
+" `("split", "vl")` Open in vertical split left of current window.
|
|
|
|
|
+" `("split", "vr")` Open in vertical split right of current window.
|
|
|
|
|
+" `("tab")` Open in a new tab.
|
|
|
function! s:SelectBuffer(...)
|
|
function! s:SelectBuffer(...)
|
|
|
" Sometimes messages are not cleared when we get here so it looks like an
|
|
" Sometimes messages are not cleared when we get here so it looks like an
|
|
|
" error has occurred when it really has not.
|
|
" error has occurred when it really has not.
|
|
@@ -1237,6 +1250,11 @@ function! s:SelectBuffer(...)
|
|
|
else " = sb
|
|
else " = sb
|
|
|
execute "belowright sb "._bufNbr
|
|
execute "belowright sb "._bufNbr
|
|
|
endif
|
|
endif
|
|
|
|
|
+ " Are we supposed to open the selected buffer in the original window?
|
|
|
|
|
+ elseif (a:0 == 1) && (a:1 == "original_window")
|
|
|
|
|
+ call s:Close()
|
|
|
|
|
+ execute s:windowAtLaunch . "wincmd w"
|
|
|
|
|
+ execute "keepjumps keepalt silent b!" _bufNbr
|
|
|
else
|
|
else
|
|
|
" Request to open in current (BufExplorer) window.
|
|
" Request to open in current (BufExplorer) window.
|
|
|
if g:bufExplorerFindActive && tabNbr > 0
|
|
if g:bufExplorerFindActive && tabNbr > 0
|