Преглед на файлове

New option: show relative paths

Closes #72.
Øystein Walle преди 12 години
родител
ревизия
5370a743f2
променени са 2 файла, в които са добавени 14 реда и са изтрити 2 реда
  1. 5 2
      autoload/startify.vim
  2. 9 0
      doc/startify.txt

+ 5 - 2
autoload/startify.vim

@@ -15,6 +15,7 @@ let s:numfiles         = get(g:, 'startify_files_number', 10)
 let s:show_special     = get(g:, 'startify_enable_special', 1)
 let s:restore_position = get(g:, 'startify_restore_position')
 let s:delete_buffers   = get(g:, 'startify_session_delete_buffers')
+let s:relative_path    = get(g:, 'startify_relative_path')
 let s:session_dir      = resolve(expand(get(g:, 'startify_session_dir',
       \ has('win32') ? '$HOME\vimfiles\session' : '~/.vim/session')))
 
@@ -291,8 +292,9 @@ function! s:show_dir(cnt) abort
 
       let entries[fullpath] = 1
       let index = s:get_index_as_string(cnt)
+      let display_fname = s:relative_path ? fnamemodify(fname, ':.') : fname
 
-      call append('$', '   ['. index .']'. repeat(' ', (3 - strlen(index))) . fname)
+      call append('$', '   ['. index .']'. repeat(' ', (3 - strlen(index))) . display_fname)
       execute 'nnoremap <buffer>' index ':edit' fnameescape(fname) '<bar> call <sid>check_user_options()<cr>'
 
       let cnt += 1
@@ -336,8 +338,9 @@ function! s:show_files(cnt) abort
 
     let entries[fullpath] = 1
     let index = s:get_index_as_string(cnt)
+    let display_fname = s:relative_path ? fnamemodify(fname, ':.') : fname
 
-    call append('$', '   ['. index .']'. repeat(' ', (3 - strlen(index))) . fname)
+    call append('$', '   ['. index .']'. repeat(' ', (3 - strlen(index))) . display_fname)
     execute 'nnoremap <buffer>' index ':edit' fnameescape(fname) '<bar> call <sid>check_user_options()<cr>'
 
     let cnt += 1

+ 9 - 0
doc/startify.txt

@@ -105,6 +105,7 @@ default values.
     |g:startify_session_savevars|
     |g:startify_session_savecmds|
     |g:startify_disable_at_vimenter|
+    |g:startify_relative_path|
 
 ------------------------------------------------------------------------------
                                                         *g:startify_session_dir*
@@ -405,6 +406,14 @@ Same as the custom header, but shown at the bottom of the startify buffer.
 Don't run Startify at Vim startup. You can still call it anytime via
 :Startify.
 
+-----------------------------------------------------------------------------
+                                                     *g:startify_relative_path*
+>
+    let g:startify_relative_path = 0
+<
+Show filenames relative to the current working directory instead of as
+absolute paths.
+
 ==============================================================================
 COMMANDS                                                     *startify-commands*
 >