From c14a67749672a89a4241e840a2745ebb45550b4a Mon Sep 17 00:00:00 2001
From: Nate <nw3455@gmail.com>
Date: Sat, 26 Nov 2016 02:23:02 -0800
Subject: [PATCH] Add g:startify_padding_left

Closes https://github.com/mhinz/vim-startify/pull/250
---
 autoload/startify.vim | 30 +++++++++++++++---------------
 syntax/startify.vim   |  7 ++++---
 2 files changed, 19 insertions(+), 18 deletions(-)

diff --git a/autoload/startify.vim b/autoload/startify.vim
index d39dcb6..c609f25 100644
--- a/autoload/startify.vim
+++ b/autoload/startify.vim
@@ -12,6 +12,7 @@ let g:autoloaded_startify = 1
 " Init: values {{{1
 let s:nowait_string  = v:version >= 704 || (v:version == 703 && has('patch1261')) ? '<nowait>' : ''
 let s:nowait         = get(g:, 'startify_mapping_nowait', 1) ? s:nowait_string : ''
+let s:padding_left   = repeat(' ', get(g:, 'startify_padding_left', 3))
 let s:numfiles       = get(g:, 'startify_files_number', 10)
 let s:show_special   = get(g:, 'startify_enable_special', 1)
 let s:delete_buffers = get(g:, 'startify_session_delete_buffers')
@@ -85,13 +86,13 @@ function! startify#insane_in_the_membrane() abort
   let b:startify = { 'tick': 0, 'entries': {} }
 
   if s:show_special
-    call append('$', ['   [e]  <empty buffer>', ''])
+    call append('$', [s:padding_left .'[e]  <empty buffer>', ''])
   endif
   call s:register(line('$')-1, 'e', 'special', 'enew', '', s:nowait_string)
 
   let b:startify.entry_number = 0
   if filereadable('Session.vim')
-    call append('$', ['   [0]  '. getcwd() . s:sep .'Session.vim', ''])
+    call append('$', [s:padding_left .'[0]  '. getcwd() . s:sep .'Session.vim', ''])
     call s:register(line('$')-1, '0', 'session',
           \ 'call startify#session_delete_buffers() | source', 'Session.vim',
           \ s:nowait)
@@ -107,11 +108,11 @@ function! startify#insane_in_the_membrane() abort
 
   let b:startify.section_header_lines = []
   let s:lists = get(g:, 'startify_list_order', [
-        \ ['   MRU'],            'files',
-        \ ['   MRU '. getcwd()], 'dir',
-        \ ['   Sessions'],       'sessions',
-        \ ['   Bookmarks'],      'bookmarks',
-        \ ['   Commands'],       'commands',
+        \ [s:padding_left .'MRU'],            'files',
+        \ [s:padding_left .'MRU '. getcwd()], 'dir',
+        \ [s:padding_left .'Sessions'],       'sessions',
+        \ [s:padding_left .'Bookmarks'],      'bookmarks',
+        \ [s:padding_left .'Commands'],       'commands',
         \ ])
 
   for item in s:lists
@@ -126,7 +127,7 @@ function! startify#insane_in_the_membrane() abort
   silent $delete _
 
   if s:show_special
-    call append('$', ['', '   [q]  <quit>'])
+    call append('$', ['', s:padding_left .'[q]  <quit>'])
     call s:register(line('$'), 'q', 'special', 'call s:close()', '', s:nowait_string)
   else
     " Don't overwrite the last regular entry, thus +1
@@ -448,7 +449,7 @@ function! s:display_by_path(path_prefix, path_format, use_env) abort
   let oldfiles = call(get(g:, 'startify_enable_unsafe') ? 's:filter_oldfiles_unsafe' : 's:filter_oldfiles',
         \ [a:path_prefix, a:path_format, a:use_env])
 
-  let entry_format = "'   ['. index .']'. repeat(' ', (3 - strlen(index)))"
+  let entry_format = "s:padding_left .'['. index .']'. repeat(' ', (3 - strlen(index)))"
   if exists('*WebDevIconsGetFileTypeSymbol')  " support for vim-devicons
     let entry_format .= ". WebDevIconsGetFileTypeSymbol(entry_path) .' '.  entry_path"
   else
@@ -593,7 +594,7 @@ function! s:show_sessions() abort
   for i in range(len(sfiles))
     let index = s:get_index_as_string(b:startify.entry_number)
     let fname = fnamemodify(sfiles[i], ':t')
-    call append('$', '   ['. index .']'. repeat(' ', (3 - strlen(index))) . fname)
+    call append('$', s:padding_left .'['. index .']'. repeat(' ', (3 - strlen(index))) . fname)
     if has('win32')
       let fname = substitute(fname, '\[', '\[[]', 'g')
     endif
@@ -629,7 +630,7 @@ function! s:show_bookmarks() abort
     if empty(entry_path)
       let entry_path = path
     endif
-    call append('$', '   ['. index .']'. repeat(' ', (3 - strlen(index))) . entry_path)
+    call append('$', s:padding_left .'['. index .']'. repeat(' ', (3 - strlen(index))) . entry_path)
 
     if has('win32')
       let path = substitute(path, '\[', '\[[]', 'g')
@@ -663,7 +664,7 @@ function! s:show_commands() abort
     " If no list is given, the description is the command itself.
     let [desc, cmd] = type(command) == type([]) ? command : [command, command]
 
-    call append('$', '   ['. index .']'. repeat(' ', (3 - strlen(index))) . desc)
+    call append('$', s:padding_left .'['. index .']'. repeat(' ', (3 - strlen(index))) . desc)
     call s:register(line('$'), index, 'special', cmd, '', s:nowait_string)
 
     unlet entry command
@@ -689,7 +690,7 @@ endfunction
 
 " Function: s:set_cursor {{{1
 function! s:set_cursor() abort
-  let b:startify.oldline = exists('b:startify.newline') ? b:startify.newline : 5
+  let b:startify.oldline = exists('b:startify.newline') ? b:startify.newline : 2 + len(s:padding_left)
   let b:startify.newline = line('.')
 
   " going up (-1) or down (1)
@@ -708,7 +709,7 @@ function! s:set_cursor() abort
   " don't go beyond first or last entry
   let b:startify.newline = max([b:startify.firstline, min([b:startify.lastline, b:startify.newline])])
 
-  call cursor(b:startify.newline, 5)
+  call cursor(b:startify.newline, 2 + len(s:padding_left))
 endfunction
 
 " Function: s:set_mappings {{{1
@@ -914,4 +915,3 @@ function s:transform(absolute_path)
   endfor
   return ''
 endfunction
-
diff --git a/syntax/startify.vim b/syntax/startify.vim
index 50586da..38a20ab 100644
--- a/syntax/startify.vim
+++ b/syntax/startify.vim
@@ -9,12 +9,13 @@ if exists("b:current_syntax")
 endif
 
 let s:sep = startify#get_separator()
+let s:padding_left = repeat(' ', get(g:, 'startify_padding_left', 3))
 
 syntax sync fromstart
 
-syntax match StartifyBracket /.*\%9c/ contains=
+execute 'syntax match StartifyBracket /.*\%'. (len(s:padding_left) + 6) .'c/ contains=
       \ StartifyNumber,
-      \ StartifySelect,
+      \ StartifySelect'
 syntax match StartifySpecial /\V<empty buffer>\|<quit>/
 syntax match StartifyNumber  /^\s*\[\zs[^BSVT]\{-}\ze\]/
 syntax match StartifySelect  /^\s*\[\zs[BSVT]\{-}\ze\]/
@@ -25,7 +26,7 @@ syntax match StartifyFile    /.*/ contains=
       \ StartifySpecial,
 
 execute 'syntax match StartifySlash /\'. s:sep .'/'
-execute 'syntax match StartifyPath /\%9c.*\'. s:sep .'/ contains=StartifySlash,StartifyVar'
+execute 'syntax match StartifyPath /\%'. (len(s:padding_left) + 6) .'c.*\'. s:sep .'/ contains=StartifySlash,StartifyVar'
 
 execute 'syntax region StartifyHeader start=/\%1l/ end=/\%'. (len(g:startify_header) + 2) .'l/'