new option: g:startify_custom_indices
People can now choose to create their own index mapping instead of having the default behaviour of increasing numbers. Closes #17.
This commit is contained in:
parent
7ab3ca8565
commit
4711a54cf5
|
@ -144,6 +144,34 @@ name contained in this list.
|
|||
Example: let g:startify_skiplist_server = [ 'GVIM' ]
|
||||
|
||||
|
||||
============-
|
||||
|
||||
let g:startify_custom_indices = []
|
||||
|
||||
Use any list of strings as custom indices instead of increasing numbers. If
|
||||
there are more paths to fill in the startify buffer than actual items in the
|
||||
custom list, the rest will be filled up using the default numbering scheme
|
||||
starting from 0.
|
||||
|
||||
NOTE: There is no sanitizing going on, so you should know what you do!
|
||||
|
||||
E.g. you don't want to use duplicates. Same for 'e', 'i', 'q'. Actually you
|
||||
can use them, but they would be overwritten by mappings for creating the empty
|
||||
buffer and quitting. You may want to keep 'j' and 'k', too.
|
||||
|
||||
Example: let g:startify_custom_indices = ['a','s','d','f']
|
||||
|
||||
This would result in:
|
||||
|
||||
[a] /last/recently/used/file1
|
||||
[s] /last/recently/used/file2
|
||||
[d] /last/recently/used/file3
|
||||
[f] /last/recently/used/file4
|
||||
[0] /last/recently/used/file5
|
||||
[1] /last/recently/used/file6
|
||||
etc.
|
||||
|
||||
|
||||
============-
|
||||
|
||||
let g:startify_unlisted_buffer = 1
|
||||
|
|
|
@ -60,8 +60,9 @@ function! s:insane_in_the_membrane() abort
|
|||
if !filereadable(expfname) || (exists('g:startify_skiplist') && startify#is_in_skiplist(expfname))
|
||||
continue
|
||||
endif
|
||||
call append('$', ' ['. cnt .']'. repeat(' ', 3 - strlen(string(cnt))) . fname)
|
||||
execute 'nnoremap <buffer> '. cnt .' :edit '. startify#escape(fname) .' <bar> lcd %:h<cr>'
|
||||
let index = s:get_index_as_string(cnt)
|
||||
call append('$', ' ['. index .']'. repeat(' ', (3 - strlen(index))) . fname)
|
||||
execute 'nnoremap <buffer> '. index .' :edit '. startify#escape(fname) .' <bar> lcd %:h<cr>'
|
||||
let cnt += 1
|
||||
if (cnt == numfiles)
|
||||
break
|
||||
|
@ -74,9 +75,10 @@ function! s:insane_in_the_membrane() abort
|
|||
if get(g:, 'startify_show_sessions', 1) && !empty(sfiles)
|
||||
call append('$', '')
|
||||
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 <buffer> '. idx .' :source '. startify#escape(sfiles[i]) .'<cr>'
|
||||
let idx = (i + cnt)
|
||||
let index = s:get_index_as_string(idx)
|
||||
call append('$', ' ['. index .']'. repeat(' ', (3 - strlen(index))) . fnamemodify(sfiles[i], ':t:r'))
|
||||
execute 'nnoremap <buffer> '. index .' :source '. startify#escape(sfiles[i]) .'<cr>'
|
||||
endfor
|
||||
let cnt = idx
|
||||
endif
|
||||
|
@ -85,8 +87,9 @@ function! s:insane_in_the_membrane() abort
|
|||
call append('$', '')
|
||||
for fname in g:startify_bookmarks
|
||||
let cnt += 1
|
||||
call append('$', ' ['. cnt .']'. repeat(' ', 3 - strlen(string(cnt))) . fname)
|
||||
execute 'nnoremap <buffer> '. cnt .' :edit '. startify#escape(fname) .' <bar> lcd %:h<cr>'
|
||||
let index = s:get_index_as_string(cnt)
|
||||
call append('$', ' ['. index .']'. repeat(' ', (3 - strlen(index))) . fname)
|
||||
execute 'nnoremap <buffer> '. index .' :edit '. startify#escape(fname) .' <bar> lcd %:h<cr>'
|
||||
endfor
|
||||
endif
|
||||
|
||||
|
@ -118,6 +121,16 @@ function! s:insane_in_the_membrane() abort
|
|||
call cursor(special ? 4 : 2, 5)
|
||||
endfunction
|
||||
|
||||
" Function: s:get_index_as_string {{{1
|
||||
function! s:get_index_as_string(idx) abort
|
||||
if exists('g:startify_custom_indices')
|
||||
let listlen = len(g:startify_custom_indices)
|
||||
return (a:idx < listlen) ? g:startify_custom_indices[a:idx] : string(a:idx - listlen)
|
||||
else
|
||||
return string(a:idx)
|
||||
endif
|
||||
endfunction
|
||||
|
||||
" Function: s:set_cursor {{{1
|
||||
function! s:set_cursor() abort
|
||||
let s:line_old = exists('s:line_new') ? s:line_new : 5
|
||||
|
|
|
@ -11,7 +11,7 @@ let s:sep = startify#get_sep()
|
|||
|
||||
syntax match StartifySpecial /\V<empty buffer>\|<quit>/
|
||||
syntax match StartifyBracket /\[\|\]/
|
||||
syntax match StartifyNumber /\v\[[eq[:digit:]]+\]/hs=s+1,he=e-1 contains=StartifyBracket
|
||||
syntax match StartifyNumber /\v\[.+\]/hs=s+1,he=e-1 contains=StartifyBracket
|
||||
syntax match StartifyFile /.*/ contains=StartifyBracket,StartifyNumber,StartifyPath,StartifySpecial
|
||||
|
||||
execute 'syntax match StartifySlash /\'. s:sep .'/'
|
||||
|
|
Loading…
Reference in a new issue