From 0bc6e863d6360e30232167921153a90102f3859b Mon Sep 17 00:00:00 2001 From: Marco Hinz Date: Tue, 30 Oct 2018 21:23:47 +0100 Subject: [PATCH] Allow custom indices per list Implements #338 --- autoload/startify.vim | 8 ++++++-- doc/startify.txt | 7 ++++++- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/autoload/startify.vim b/autoload/startify.vim index 92589af..1a06847 100644 --- a/autoload/startify.vim +++ b/autoload/startify.vim @@ -91,7 +91,7 @@ function! startify#insane_in_the_membrane() abort endif call append('$', g:startify_header) - let b:startify = { 'tick': 0, 'entries': {} } + let b:startify = { 'tick': 0, 'entries': {}, 'indices': [] } if s:show_special call append('$', [s:padding_left .'[e] ', '']) @@ -454,6 +454,8 @@ function! s:show_lists(lists) abort continue endif + let b:startify.indices = copy(get(list, 'indices', [])) + if type(list.type) == type('') if has_key(list, 'header') let s:last_message = list.header @@ -924,7 +926,9 @@ endfunction " Function: s:get_index_as_string {{{1 function! s:get_index_as_string(idx) abort - if exists('g:startify_custom_indices') + if !empty(b:startify.indices) + return remove(b:startify.indices, 0) + elseif 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 diff --git a/doc/startify.txt b/doc/startify.txt index 4bf2eeb..3d96380 100644 --- a/doc/startify.txt +++ b/doc/startify.txt @@ -151,13 +151,18 @@ This option is DEPRECATED in favor of |g:startify_lists|. \ { 'type': 'commands', 'header': [' Commands'] }, \ ] < -Startify displays lists. Each list consists of a type and an optional header. +Startify displays lists. Each list consists of a `type` and optionally a `header` +and custom `indices`. The 'type' is either a string of a built-in type or a |Funcref|. The 'header' is a list of strings, whereas each string will be put on its own line in the header. +The 'indices' is a list of strings, which act as indices for the current list. +Opposed to the global |g:startify_custom_indices|, this is limited to the +current list. + Built-in types:~ 'files'