Add ranger file picker to vim on linux

This commit is contained in:
Talia 2019-09-13 23:39:58 +02:00
parent 13a1c0f6dc
commit 9f0409dc3c
1 changed files with 38 additions and 4 deletions

42
vimrc
View File

@ -32,7 +32,7 @@ set history=50 " keep 50 lines of command line history
set nonumber
" set relativenumber
set langmenu=en_UK
let $LANG = 'en_UK'
let $LANG = 'en_GB.UTF-8'
source $VIMRUNTIME/delmenu.vim
source $VIMRUNTIME/menu.vim
set guioptions-=r
@ -178,6 +178,43 @@ endfun
command! -nargs=1 FTSnippet call s:insert_ft_snippet(&filetype, <f-args>)
command! -range -nargs=1 FTMkSnippet call s:make_ft_snippet_range(&filetype, <f-args>, <line1>, <line2>)
function! RangeChooser()
let temp = tempname()
if has("gui_running")
exec 'silent !xterm -e ranger --choosefiles=' . shellescape(temp).' '.expand("%:p:h")
else
exec 'silent !ranger --choosefiles=' . shellescape(temp).' '.expand("%:p:h")
endif
if !filereadable(temp)
redraw!
return
endif
let names = readfile(temp)
if empty(names)
redraw!
return
endif
1,$argd
for name in names
exec 'argadd ' . fnameescape(name)
endfor
rewind
redraw!
endfunction
command! -bar RangerChooser call RangeChooser()
if has("unix")
nnoremap <leader><space> :<C-U>RangerChooser<CR>
elseif has("win32")
nnoremap <leader><space> :e %:p:h<CR>
end
" --- AUTO CLOSE ---
function! s:autoClose_HelperOpen(open, close)
@ -466,9 +503,6 @@ nnoremap <C-l> e
nnoremap <leader>m :marks abcdefghijklmnopqrstuvwxyz<CR>
nnoremap <leader>M :marks ABCDEFGHIJKLMNOPQRSTUVWXYZ<CR>
" --- Windows, Tabs and More --
nnoremap <leader><space> :e %:p:h<CR>
" --- modes ---
nnoremap <ins> <ins><ins>