New option: g:startify_show_dir

Closes #29.
This commit is contained in:
Marco Hinz 2013-07-19 00:39:51 +02:00
parent 6b08a71b94
commit 9dd72dd2cd
2 changed files with 45 additions and 4 deletions

View file

@ -43,10 +43,38 @@ function! startify#insane_in_the_membrane() abort
call append('$', ' [e] <empty buffer>')
endif
if get(g:, 'startify_show_dir')
let files = []
let numfiles = get(g:, 'startify_show_files_number', 10)
if special
call append('$', '')
endif
for fname in split(glob('.\=*'))
if (fname == '.') || (fname == '..')
continue
endif
call add(files, [getftime(fname), fname])
endfor
function! l:compare(x, y)
return a:y[0] - a:x[0]
endfunction
call sort(files, 'l:compare')
for items in files
let index = s:get_index_as_string(cnt)
let fname = items[1]
call append('$', ' ['. index .']'. repeat(' ', (3 - strlen(index))) . fname)
execute 'nnoremap <buffer>' index ':edit' fnameescape(fname) '<cr>'
let cnt += 1
if (cnt == numfiles)
break
endif
endfor
endif
if get(g:, 'startify_show_files', 1) && !empty(v:oldfiles)
let entries = {}
let numfiles = get(g:, 'startify_show_files_number', 10)
if special
if special || get(g:, 'startify_show_dir')
call append('$', '')
endif
for fname in v:oldfiles
@ -61,9 +89,10 @@ function! startify#insane_in_the_membrane() abort
let entries[expfname] = 1
let index = s:get_index_as_string(cnt)
call append('$', ' ['. index .']'. repeat(' ', (3 - strlen(index))) . fname)
execute 'nnoremap <buffer> '. index .' :edit '. fnameescape(fname) . s:cmd
execute 'nnoremap <buffer>' index ':edit' fnameescape(fname) s:cmd
let cnt += 1
if (cnt == numfiles)
let numfiles -= 1
if !numfiles
break
endif
endfor
@ -223,6 +252,7 @@ function! startify#get_separator() abort
return !exists('+shellslash') || &shellslash ? '/' : '\'
endfunction
" Function: s:is_in_skiplist {{{1
function! s:is_in_skiplist(arg) abort
for regexp in g:startify_skiplist

View file

@ -108,12 +108,23 @@ List saved sessions in g:startify_session_dir.
List recently used files using viminfo.
The number is limited by g:startify_show_files_number.
============-
let g:startify_show_files_number = 10
The amount of files to list.
The number of files to list.
============-
let g:startify_show_dir = 0
Show files from the current directory sorted by modification time.
The number is limited by g:startify_show_files_number.
============-