From dad7c9cd088f9e16cf0e3d9e25c4ee4a363e2f9d Mon Sep 17 00:00:00 2001 From: Marco Hinz Date: Thu, 25 Apr 2013 12:38:07 +0200 Subject: [PATCH] change shellslash handling --- autoload/startify.vim | 8 ++++++++ plugin/startify.vim | 18 ++++++------------ 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/autoload/startify.vim b/autoload/startify.vim index e84bb12..afdb1b7 100644 --- a/autoload/startify.vim +++ b/autoload/startify.vim @@ -16,6 +16,14 @@ function! startify#get_session_names_as_string(lead, ...) abort return join(map(split(globpath(g:startify_session_dir, '*'.a:lead.'*', '\n')), 'fnamemodify(v:val, ":t")'), "\n") endfunction +function! startify#escape(path) abort + return !exists('+shellslash') || &shellslash ? a:path : escape(a:path, '\') +endfunction + +function! startify#get_sep() abort + return !exists('+shellslash') || &shellslash ? '/' : '\' +endfunction + function! startify#save_session(...) abort if !isdirectory(g:startify_session_dir) echo 'The session directory does not exist: '. g:startify_session_dir diff --git a/plugin/startify.vim b/plugin/startify.vim index 652d694..3d6c05b 100644 --- a/plugin/startify.vim +++ b/plugin/startify.vim @@ -33,25 +33,22 @@ function! s:start() abort if get(g:, 'startify_unlisted_buffer', 1) setlocal nobuflisted endif - if exists('+shellslash') - let old_ssl = &shellslash - set noshellslash - endif call append('$', [' startify>', '', ' [e] ']) let cnt = 0 + let sep = startify#get_sep() if get(g:, 'startify_show_files', 1) && !empty(v:oldfiles) let numfiles = get(g:, 'startify_show_files_number', 10) call append('$', '') for fname in v:oldfiles if !filereadable(expand(fname)) - \ || (expand(fname) =~# $VIMRUNTIME .'/doc') - \ || (fname =~# 'bundle/.*/doc') + \ || (expand(fname) =~# $VIMRUNTIME . sep .'doc') + \ || (fname =~# 'bundle'. sep .'.*'. sep .'doc') continue endif call append('$', ' ['. cnt .']'. repeat(' ', 3 - strlen(string(cnt))) . fname) - execute 'nnoremap '. cnt .' :edit '. fnameescape(fname) .'' + execute 'nnoremap '. cnt .' :edit '. startify#escape(fname) .'' let cnt += 1 if cnt == numfiles break @@ -66,7 +63,7 @@ function! s:start() abort for i in range(len(sfiles)) let idx = i + cnt call append('$', ' ['. idx .']'. repeat(' ', 3 - strlen(string(idx))) . fnamemodify(sfiles[i], ':t:r')) - execute 'nnoremap '. idx .' :source '. fnameescape(sfiles[i]) .'' + execute 'nnoremap '. idx .' :source '. startify#escape(sfiles[i]) .'' endfor let cnt = idx endif @@ -79,7 +76,7 @@ function! s:start() abort endif let cnt += 1 call append('$', ' ['. cnt .']'. repeat(' ', 3 - strlen(string(cnt))) . fname) - execute 'nnoremap '. cnt .' :edit '. fnameescape(fname) .'' + execute 'nnoremap '. cnt .' :edit '. startify#escape(fname) .'' endfor endif @@ -95,9 +92,6 @@ function! s:start() abort autocmd startify CursorMoved call cursor(line('.') < 4 ? 4 : 0, 5) autocmd startify BufLeave autocmd! startify * - if exists('old_ssl') - let &shellslash = old_ssl - endif call cursor(6, 5) endfunction