Bläddra i källkod

Support for custom indices for g:startify_bookmarks

g:startify_bookmarks now supports custom indices directly. E.g.

    let g:startify_bookmarks = [ {'v': '~/.vimrc'} ]

References #176, #178.
Marco Hinz 10 år sedan
förälder
incheckning
df8b4e1fde
2 ändrade filer med 14 tillägg och 7 borttagningar
  1. 8 3
      autoload/startify.vim
  2. 6 4
      doc/startify.txt

+ 8 - 3
autoload/startify.vim

@@ -529,14 +529,19 @@ function! s:show_bookmarks() abort
     call s:print_section_header()
   endif
 
-  for fname in g:startify_bookmarks
-    let index = s:get_index_as_string(s:entry_number)
+  for bookmark in g:startify_bookmarks
+    if type(bookmark) == 4  " dict?
+      let [index, fname] = items(bookmark)[0]
+    else  " string
+      let [index, fname] = [s:get_index_as_string(s:entry_number), bookmark]
+      let s:entry_number += 1
+    endif
     call append('$', '   ['. index .']'. repeat(' ', (3 - strlen(index))) . fname)
     if has('win32')
       let fname = substitute(fname, '\[', '\[[]', 'g')
     endif
     call s:register(line('$'), index, 'file', 'edit', fname)
-    let s:entry_number += 1
+    unlet bookmark  " avoid type mismatch for heterogeneous lists
   endfor
 
   call append('$', '')

+ 6 - 4
doc/startify.txt

@@ -177,12 +177,13 @@ Feel free to add some cool ASCII action!
 >
     let g:startify_bookmarks = []
 <
-A list of files to bookmark. Those files will always be shown at the bottom of
-the start screen.
+A list of files or directories to bookmark. The list can contain two kinds of
+types. Either a path or a dictionary whereas the key is the custom index and
+the value the path.
 
 Example:
 >
-    let g:startify_bookmarks = [ '~/.vimrc' ]
+    let g:startify_bookmarks = [ {'v': '~/.vimrc'}, '~/.zshrc' ]
 <
 ------------------------------------------------------------------------------
                                                        *g:startify_files_number*
@@ -714,7 +715,8 @@ This is my configuration..
                 \ ]
 
     let g:startify_bookmarks = [
-                \ '~/.vim/vimrc',
+                \ { 'v': '~/.vim/vimrc' },
+                \ { 't': '/tmp' },
                 \ '/data/vim/golfing',
                 \ ]