Make g:startify_commands more flexible
This commit is contained in:
parent
e551be9cb0
commit
e5ce53fbef
2 changed files with 34 additions and 46 deletions
|
@ -113,7 +113,7 @@ function! startify#insane_in_the_membrane() abort
|
|||
\ [' MRU '. getcwd()], 'dir',
|
||||
\ [' Sessions'], 'sessions',
|
||||
\ [' Bookmarks'], 'bookmarks',
|
||||
\ [' Ex commands'], 'ex_commands',
|
||||
\ [' Commands'], 'commands',
|
||||
\ ])
|
||||
|
||||
for item in s:lists
|
||||
|
@ -622,9 +622,9 @@ function! s:show_bookmarks() abort
|
|||
call append('$', '')
|
||||
endfunction
|
||||
|
||||
" Function: s:show_ex_commands {{{1
|
||||
function! s:show_ex_commands() abort
|
||||
if !exists('g:startify_ex_commands') || empty(g:startify_ex_commands)
|
||||
" Function: s:show_commands {{{1
|
||||
function! s:show_commands() abort
|
||||
if !exists('g:startify_commands') || empty(g:startify_commands)
|
||||
return
|
||||
endif
|
||||
|
||||
|
@ -632,18 +632,21 @@ function! s:show_ex_commands() abort
|
|||
call s:print_section_header()
|
||||
endif
|
||||
|
||||
for ex_command_item in g:startify_ex_commands
|
||||
if type(ex_command_item) == type({})
|
||||
let [index, ex_command_str] = items(ex_command_item)[0]
|
||||
else " string
|
||||
let [index, ex_command_str] = [s:get_index_as_string(s:entry_number), ex_command_item]
|
||||
for entry in g:startify_commands
|
||||
if type(entry) == type({}) " with custom index
|
||||
let [index, command] = items(entry)[0]
|
||||
else
|
||||
let command = entry
|
||||
let index = s:get_index_as_string(s:entry_number)
|
||||
let s:entry_number += 1
|
||||
endif
|
||||
" 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))) . ex_command_str)
|
||||
call s:register(line('$'), index, 'special', ex_command_str, '', s:nowait_string)
|
||||
call append('$', ' ['. index .']'. repeat(' ', (3 - strlen(index))) . desc)
|
||||
call s:register(line('$'), index, 'special', cmd, '', s:nowait_string)
|
||||
|
||||
unlet ex_command_item " avoid type mismatch for heterogeneous lists
|
||||
unlet entry command
|
||||
endfor
|
||||
|
||||
call append('$', '')
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue