lf/etc/lf.vim

35 lines
805 B
VimL
Raw Normal View History

2017-10-21 19:14:58 +00:00
" Use lf to select and open file(s) in vim (adapted from ranger).
2016-08-13 12:49:04 +00:00
"
2016-09-06 22:47:08 +00:00
" You need to either copy the content of this file to your ~/.vimrc or source
2017-10-21 19:14:58 +00:00
" this file directly:
2016-08-13 12:49:04 +00:00
"
2017-10-21 19:14:58 +00:00
" let lfvim = "/path/to/lf.vim"
2016-09-06 22:47:08 +00:00
" if filereadable(lfvim)
" exec "source " . lfvim
" endif
"
" You may also like to assign a key to this command:
"
2017-10-21 19:14:58 +00:00
" nnoremap <leader>l :LF<cr>
2016-08-13 12:49:04 +00:00
"
2016-09-06 22:47:08 +00:00
function! LF()
2016-08-13 12:49:04 +00:00
let temp = tempname()
exec 'silent !lf -selection-path=' . shellescape(temp)
if !filereadable(temp)
redraw!
return
endif
let names = readfile(temp)
if empty(names)
redraw!
return
endif
exec 'edit ' . fnameescape(names[0])
for name in names[1:]
exec 'argadd ' . fnameescape(name)
endfor
redraw!
endfunction
2016-09-06 22:47:08 +00:00
command! -bar LF call LF()