-
-
Save jebaum/01622bf3045c09f05254 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let g:MRUList = [] | |
autocmd VimEnter * call MRUSetup() | |
function! MRUSetup() | |
let g:MRUList = range(1, bufnr('$')) | |
augroup MRU | |
autocmd! | |
autocmd BufEnter,BufNew * call MRUPush(bufnr("%")) | |
autocmd BufWipeout,BufDelete * call MRUPop(str2nr(expand("<abuf>"))) | |
augroup END | |
endfunction | |
function! MRUPop(bufnr) | |
call filter(g:MRUList, 'v:val != ' . a:bufnr) | |
endfunction | |
function! MRUPush(bufnr) | |
if empty(getbufvar(a:bufnr, "&buftype") == 0) || empty(bufname(a:bufnr)) == 1 | |
return | |
endif | |
call MRUPop(a:bufnr) | |
call insert(g:MRUList, a:bufnr) | |
endfunction | |
function! MRUFzf() | |
let MRUNames = map(copy(g:MRUList), 'bufname(v:val)') | |
call fzf#run({'source': MRUNames}) | |
endfunction |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment