Awesome
vital-Vim-Buffer-Anchor
Introductions
This module is used to find/focus a suitable anchor buffer which is used for
opening a new buffer from a non-file buffer such as quickfix
window.
Use this module to focus an anchor buffer prior to open a new buffer. The following code is an example simple file manager.
let s:Anchor = vital#{plugin-name}#import('Vim.Buffer.Anchor')
function! s:open_file(opener) abort
let filename = expand(getline('.'))
" Note: focus() is not called when 'opener' is pedit or tabedit
call s:Anchor.focus_if_available(a:opener)
execute a:opener . ' ' . fnameescape(filename)
endfunction
function! s:open_file_manager(root) abort
topleft 50 vsplit FileManager
let candidates = split(glob(a:root . '/*'), "\r\\?\n")
let candidates = filter(candidates, 'filereadable(v:val)')
let candidates = map(candidates, 'fnamemodify(v:val, '':~:.'')')
let candidates = ['File Manager'] + candidates
call setline(1, candidates)
nnoremap <buffer> e :<C-u>call <SID>open_file('ed')<CR>
nnoremap <buffer> s :<C-u>call <SID>open_file('sp')<CR>
nnoremap <buffer> v :<C-u>call <SID>open_file('vs')<CR>
nnoremap <buffer> p :<C-u>call <SID>open_file('ped')<CR>
nnoremap <buffer> t :<C-u>call <SID>open_file('tabe')<CR>
" Attach an anchoring feature
call s:Anchor.attach()
endfunction
command! FileManager call s:open_file_manager(getcwd())
Install
Install this repository with your favorite Vim plugin manager and then
:Vitalize . +Vim.Buffer.Anchor
To activate Vim.Buffer.Anchor on your plugin.