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