1
0
mirror of https://github.com/SpaceVim/SpaceVim.git synced 2025-01-24 06:30:03 +08:00
SpaceVim/config/plugins/vimfiler.vim

158 lines
5.3 KiB
VimL
Raw Normal View History

2016-12-26 21:11:19 +08:00
scriptencoding utf-8
2017-12-01 14:05:46 +08:00
let s:VCOP = SpaceVim#api#import('vim#compatible')
2017-03-08 20:53:20 +08:00
let g:vimfiler_as_default_explorer = get(g:, 'vimfiler_as_default_explorer', 1)
let g:vimfiler_restore_alternate_file = get(g:, 'vimfiler_restore_alternate_file', 1)
let g:vimfiler_tree_indentation = get(g:, 'vimfiler_tree_indentation', 1)
let g:vimfiler_tree_leaf_icon = get(g:, 'vimfiler_tree_leaf_icon', '')
let g:vimfiler_tree_opened_icon = get(g:, 'vimfiler_tree_opened_icon', '▼')
let g:vimfiler_tree_closed_icon = get(g:, 'vimfiler_tree_closed_icon', '▷')
let g:vimfiler_file_icon = get(g:, 'vimfiler_file_icon', '')
let g:vimfiler_readonly_file_icon = get(g:, 'vimfiler_readonly_file_icon', '*')
let g:vimfiler_marked_file_icon = get(g:, 'vimfiler_marked_file_icon', '√')
2017-06-29 04:49:44 +08:00
let g:vimfiler_direction = get(g:, 'vimfiler_direction', 'rightbelow')
2016-12-26 21:11:19 +08:00
"let g:vimfiler_preview_action = 'auto_preview'
2017-04-14 19:43:27 +08:00
let g:vimfiler_ignore_pattern = get(g:, 'vimfiler_ignore_pattern', [
2017-03-06 23:26:26 +08:00
\ '^\.git$',
\ '^\.DS_Store$',
\ '^\.init\.vim-rplugin\~$',
\ '^\.netrwhist$',
2017-12-05 10:08:10 +08:00
\ '\.class$',
\ '^\.'
2017-04-14 19:43:27 +08:00
\])
2016-12-26 21:11:19 +08:00
if has('mac')
2017-03-06 23:26:26 +08:00
let g:vimfiler_quick_look_command =
\ '/Applications//Sublime\ Text.app/Contents/MacOS/Sublime\ Text'
2016-12-26 21:11:19 +08:00
else
2017-03-06 23:26:26 +08:00
let g:vimfiler_quick_look_command = 'gloobus-preview'
2016-12-26 21:11:19 +08:00
endif
function! s:setcolum() abort
if g:spacevim_enable_vimfiler_filetypeicon && !g:spacevim_enable_vimfiler_gitstatus
return 'filetypeicon'
elseif !g:spacevim_enable_vimfiler_filetypeicon && g:spacevim_enable_vimfiler_gitstatus
return 'gitstatus'
elseif g:spacevim_enable_vimfiler_filetypeicon && g:spacevim_enable_vimfiler_gitstatus
return 'filetypeicon:gitstatus'
else
return ''
endif
endfunction
"try
call vimfiler#custom#profile('default', 'context', {
\ 'explorer' : 1,
\ 'winwidth' : g:spacevim_sidebar_width,
\ 'winminwidth' : 30,
\ 'toggle' : 1,
\ 'auto_expand': 1,
2017-06-29 04:49:44 +08:00
\ 'direction' : g:vimfiler_direction,
\ 'explorer_columns' : s:setcolum(),
\ 'parent': 0,
\ 'status' : 1,
\ 'safe' : 0,
\ 'split' : 1,
\ 'hidden': 1,
\ 'no_quit' : 1,
\ 'force_hide' : 0,
\ })
"catch
"endtry
2016-12-26 21:11:19 +08:00
augroup vfinit
2017-03-06 23:26:26 +08:00
au!
autocmd FileType vimfiler call s:vimfilerinit()
autocmd BufEnter * nested if (!has('vim_starting') && winnr('$') == 1 && &filetype ==# 'vimfiler') |
2017-03-06 23:26:26 +08:00
\ q | endif
2016-12-26 21:11:19 +08:00
augroup END
function! s:vimfilerinit()
2017-05-06 19:56:54 +08:00
setl nonumber
setl norelativenumber
2017-01-12 22:09:03 +08:00
2017-03-06 23:26:26 +08:00
silent! nunmap <buffer> <Space>
silent! nunmap <buffer> <C-l>
silent! nunmap <buffer> <C-j>
silent! nunmap <buffer> E
silent! nunmap <buffer> gr
silent! nunmap <buffer> gf
silent! nunmap <buffer> -
silent! nunmap <buffer> s
2017-01-12 22:09:03 +08:00
2017-03-06 23:26:26 +08:00
nnoremap <silent><buffer> gr :<C-u>Denite grep:<C-R>=<SID>selected()<CR> -buffer-name=grep<CR>
nnoremap <silent><buffer> gf :<C-u>Denite file_rec:<C-R>=<SID>selected()<CR><CR>
nnoremap <silent><buffer> gd :<C-u>call <SID>change_vim_current_dir()<CR>
2018-03-24 20:50:18 +08:00
nnoremap <silent><buffer> sg :<C-u>call <SID>vimfiler_vsplit()<CR>
nnoremap <silent><buffer> sv :<C-u>call <SID>vimfiler_split()<CR>
2017-03-06 23:26:26 +08:00
nnoremap <silent><buffer><expr> st vimfiler#do_action('tabswitch')
2017-12-01 14:05:46 +08:00
nnoremap <silent><buffer> yY :<C-u>call <SID>copy_to_system_clipboard()<CR>
2017-12-01 14:46:42 +08:00
nnoremap <silent><buffer> P :<C-u>call <SID>paste_to_file_manager()<CR>
nmap <buffer> gx <Plug>(vimfiler_execute_vimfiler_associated)
nmap <buffer> ' <Plug>(vimfiler_toggle_mark_current_line)
nmap <buffer> v <Plug>(vimfiler_quick_look)
nmap <buffer> p <Plug>(vimfiler_preview_file)
nmap <buffer> V <Plug>(vimfiler_clear_mark_all_lines)
nmap <buffer> i <Plug>(vimfiler_switch_to_history_directory)
nmap <buffer> <Tab> <Plug>(vimfiler_switch_to_other_window)
nmap <buffer> <C-r> <Plug>(vimfiler_redraw_screen)
nmap <buffer> <Left> <Plug>(vimfiler_smart_h)
nmap <buffer> <Right> <Plug>(vimfiler_smart_l)
2016-12-26 21:11:19 +08:00
endf
2017-03-06 23:26:26 +08:00
2018-03-24 20:50:18 +08:00
function! s:vimfiler_vsplit() abort
let path = vimfiler#get_filename()
if !isdirectory(path)
wincmd w
exe 'vsplit' path
else
echohl ModeMsg
echo path . ' is a directory!'
echohl NONE
endif
endfunction
function! s:vimfiler_split() abort
let path = vimfiler#get_filename()
if !isdirectory(path)
wincmd w
exe 'split' path
else
echohl ModeMsg
echo path . ' is a directory!'
echohl NONE
endif
endfunction
2017-12-01 14:46:42 +08:00
function! s:paste_to_file_manager() abort
let path = vimfiler#get_filename()
if !isdirectory(path)
let path = fnamemodify(path, ':p:h')
endif
let old_wd = getcwd()
if old_wd == path
call s:VCOP.systemlist(['xclip-pastefile'])
else
noautocmd exe 'cd' fnameescape(path)
call s:VCOP.systemlist(['xclip-pastefile'])
noautocmd exe 'cd' fnameescape(old_wd)
endif
endfunction
2017-12-01 14:05:46 +08:00
function! s:copy_to_system_clipboard() abort
let filename = vimfiler#get_marked_filenames(b:vimfiler)
if empty(filename)
" Use cursor filename.
let filename = vimfiler#get_filename()
2017-12-01 14:13:33 +08:00
if filename ==# '..' || empty(vimfiler#get_file(b:vimfiler))
2017-12-01 14:05:46 +08:00
let filename = b:vimfiler.current_dir
else
let filename = vimfiler#get_file(b:vimfiler).action__path
endif
2017-12-01 14:13:33 +08:00
call s:VCOP.systemlist(['xclip-copyfile', filename])
else
call s:VCOP.systemlist(['xclip-copyfile'] + filename)
2017-12-01 14:05:46 +08:00
endif
2017-12-01 14:13:33 +08:00
echo 'Yanked:' . (type(filename) == 3 ? len(filename) : 1 ) . ' files'
2017-12-01 14:05:46 +08:00
endfunction
2017-03-06 23:26:26 +08:00
" vim:set et sw=2: