From e18fa54e6477c8523540762c289cf4ab55eece48 Mon Sep 17 00:00:00 2001 From: Marco Hinz Date: Wed, 7 Oct 2020 01:15:47 +0200 Subject: [PATCH] Fix pad spacing --- autoload/startify.vim | 37 ++++++++++++++++++------------------- 1 file changed, 18 insertions(+), 19 deletions(-) diff --git a/autoload/startify.vim b/autoload/startify.vim index 6bf8098..af52db2 100644 --- a/autoload/startify.vim +++ b/autoload/startify.vim @@ -100,13 +100,13 @@ function! startify#insane_in_the_membrane(on_vimenter) abort \ } if g:startify_enable_special - call append('$', [g:startify_padding_left .'[e] ', '']) + call append('$', [s:leftpad .'[e] ', '']) endif call s:register(line('$')-1, 'e', 'special', 'enew', '') let b:startify.entry_number = 0 if filereadable('Session.vim') - call append('$', [g:startify_padding_left .'[0] '. getcwd() . s:sep .'Session.vim', '']) + call append('$', [s:leftpad .'[0] '. getcwd() . s:sep .'Session.vim', '']) call s:register(line('$')-1, '0', 'session', \ 'call startify#session_delete_buffers() | source', 'Session.vim') let b:startify.entry_number = 1 @@ -125,7 +125,7 @@ function! startify#insane_in_the_membrane(on_vimenter) abort silent $delete _ if g:startify_enable_special - call append('$', ['', g:startify_padding_left .'[q] ']) + call append('$', ['', s:leftpad .'[q] ']) call s:register(line('$'), 'q', 'special', 'call s:close()', '') else " Don't overwrite the last regular entry, thus +1 @@ -433,7 +433,7 @@ endfunction " Function: #pad {{{1 function! startify#pad(lines) abort - return map(copy(a:lines), 'g:startify_padding_left . v:val') + return map(copy(a:lines), 's:leftpad . v:val') endfunction " Function: #center {{{1 @@ -466,11 +466,11 @@ function! s:get_lists() abort return lists else return [ - \ { 'header': [g:startify_padding_left .'MRU'], 'type': 'files' }, - \ { 'header': [g:startify_padding_left .'MRU '. getcwd()], 'type': 'dir' }, - \ { 'header': [g:startify_padding_left .'Sessions'], 'type': 'sessions' }, - \ { 'header': [g:startify_padding_left .'Bookmarks'], 'type': 'bookmarks' }, - \ { 'header': [g:startify_padding_left .'Commands'], 'type': 'commands' }, + \ { 'header': [s:leftpad .'MRU'], 'type': 'files' }, + \ { 'header': [s:leftpad .'MRU '. getcwd()], 'type': 'dir' }, + \ { 'header': [s:leftpad .'Sessions'], 'type': 'sessions' }, + \ { 'header': [s:leftpad .'Bookmarks'], 'type': 'bookmarks' }, + \ { 'header': [s:leftpad .'Commands'], 'type': 'commands' }, \ ] endif endfunction @@ -511,7 +511,7 @@ function! s:show_lists(lists) abort let path = get(entry, 'path', '') let type = get(entry, 'type', empty(path) ? 'special' : 'file') let index = s:get_index_as_string() - call append('$', g:startify_padding_left .'['. index .']'. repeat(' ', (3 - strlen(index))) . entry.line) + call append('$', s:leftpad .'['. index .']'. repeat(' ', (3 - strlen(index))) . entry.line) call s:register(line('$'), index, type, cmd, path) endfor call append('$', '') @@ -558,7 +558,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 = "g:startify_padding_left .'['. index .']'. repeat(' ', (3 - strlen(index))) ." + let entry_format = "s:leftpad .'['. index .']'. repeat(' ', (3 - strlen(index))) ." if exists('*StartifyEntryFormat') let entry_format .= StartifyEntryFormat() else @@ -719,7 +719,7 @@ function! s:show_sessions() abort let index = s:get_index_as_string() let fname = fnamemodify(sfiles[i], ':t') let dname = sfiles[i] ==# v:this_session ? fname.' (*)' : fname - call append('$', g:startify_padding_left .'['. index .']'. repeat(' ', (3 - strlen(index))) . dname) + call append('$', s:leftpad .'['. index .']'. repeat(' ', (3 - strlen(index))) . dname) if has('win32') let fname = substitute(fname, '\[', '\[[]', 'g') endif @@ -756,7 +756,7 @@ function! s:show_bookmarks() abort if empty(entry_path) let entry_path = path endif - call append('$', g:startify_padding_left .'['. index .']'. repeat(' ', (3 - strlen(index))) . entry_path) + call append('$', s:leftpad .'['. index .']'. repeat(' ', (3 - strlen(index))) . entry_path) if has('win32') let path = substitute(path, '\[', '\[[]', 'g') @@ -789,7 +789,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('$', g:startify_padding_left .'['. index .']'. repeat(' ', (3 - strlen(index))) . desc) + call append('$', s:leftpad .'['. index .']'. repeat(' ', (3 - strlen(index))) . desc) call s:register(line('$'), index, 'special', cmd, '') unlet entry command @@ -813,9 +813,7 @@ endfunction " Function: s:set_cursor {{{1 function! s:set_cursor() abort - let b:startify.oldline = exists('b:startify.newline') - \ ? b:startify.newline - \ : 2 + len(g:startify_padding_left) + let b:startify.oldline = exists('b:startify.newline') ? b:startify.newline : s:fixed_column let b:startify.newline = line('.') " going up (-1) or down (1) @@ -1126,6 +1124,7 @@ let g:startify_skiplist = extend(get(g:, 'startify_skiplist', []), [ \ escape(fnamemodify(resolve($VIMRUNTIME), ':p'), '\') .'doc/.*\.txt$', \ ], 'keep') -let g:startify_padding_left = repeat(' ', get(g:, 'startify_padding_left', 3)) -let s:fixed_column = len(g:startify_padding_left) + 2 +let g:startify_padding_left = get(g:, 'startify_padding_left', 3) +let s:leftpad = repeat(' ', g:startify_padding_left) +let s:fixed_column = g:startify_padding_left + 2 let s:batchmode = ''