diff --git a/autoload/startify.vim b/autoload/startify.vim index c609f25..d6f49a8 100644 --- a/autoload/startify.vim +++ b/autoload/startify.vim @@ -728,9 +728,13 @@ function! s:set_mappings() abort nnoremap n ' j'[v:searchforward].'n' nnoremap N 'j '[v:searchforward].'N' - for k in keys(b:startify.entries) - execute 'nnoremap '. b:startify.entries[k].nowait b:startify.entries[k].index - \ ':call startify#open_buffers('. string(k) .')' + function! s:compare_by_index(foo, bar) + return a:foo.index - a:bar.index + endfunction + + for entry in sort(values(b:startify.entries), 's:compare_by_index') + execute 'nnoremap '. entry.nowait entry.index + \ ':call startify#open_buffers('. string(entry.line) .')' endfor " Prevent 'nnoremap j gj' mappings, since they would break navigation. @@ -851,6 +855,7 @@ function! s:register(line, index, type, cmd, path, wait) let b:startify.entries[a:line] = { \ 'index': a:index, \ 'type': a:type, + \ 'line': a:line, \ 'cmd': a:cmd, \ 'path': a:path, \ 'nowait': a:wait,