| 1 |
" Use lf to select and open file(s) in vim (adapted from ranger). |
| 2 |
" |
| 3 |
" You need to either copy the content of this file to your ~/.vimrc or source |
| 4 |
" this file directly: |
| 5 |
" |
| 6 |
" let lfvim = "/path/to/lf.vim" |
| 7 |
" if filereadable(lfvim) |
| 8 |
" exec "source " . lfvim |
| 9 |
" endif |
| 10 |
" |
| 11 |
" You may also like to assign a key to this command: |
| 12 |
" |
| 13 |
" nnoremap <leader>l :LF<cr> |
| 14 |
" |
| 15 |
|
| 16 |
function! LF() |
| 17 |
let temp = tempname() |
| 18 |
exec 'silent !lf -selection-path=' . shellescape(temp) |
| 19 |
if !filereadable(temp) |
| 20 |
redraw! |
| 21 |
return |
| 22 |
endif |
| 23 |
let names = readfile(temp) |
| 24 |
if empty(names) |
| 25 |
redraw! |
| 26 |
return |
| 27 |
endif |
| 28 |
exec 'edit ' . fnameescape(names[0]) |
| 29 |
for name in names[1:] |
| 30 |
exec 'argadd ' . fnameescape(name) |
| 31 |
endfor |
| 32 |
redraw! |
| 33 |
endfunction |
| 34 |
command! -bar LF call LF() |