From 9a833c5bc686c92f88a76dcb8983a96417c1880e Mon Sep 17 00:00:00 2001 From: Ernst Widerberg Date: Sun, 29 May 2016 11:06:29 +0200 Subject: [PATCH 1/3] Add ex command list --- autoload/startify.vim | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/autoload/startify.vim b/autoload/startify.vim index 13e46de..2f5e634 100644 --- a/autoload/startify.vim +++ b/autoload/startify.vim @@ -113,6 +113,7 @@ function! startify#insane_in_the_membrane() abort \ [' MRU '. getcwd()], 'dir', \ [' Sessions'], 'sessions', \ [' Bookmarks'], 'bookmarks', + \ [' Ex commands'], 'ex_commands', \ ]) for item in s:lists @@ -621,6 +622,33 @@ 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) + return + endif + + if exists('s:last_message') + 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] + let s:entry_number += 1 + endif + + call append('$', ' ['. index .']'. repeat(' ', (3 - strlen(index))) . ex_command_str) + call s:register(line('$'), index, 'special', ex_command_str, '', s:nowait_string) + + unlet ex_command_item " avoid type mismatch for heterogeneous lists + endfor + + call append('$', '') +endfunction + " Function: s:is_in_skiplist {{{1 function! s:is_in_skiplist(arg) abort for regexp in s:skiplist From e551be9cb008216a718ca67bc2610f2708986f7b Mon Sep 17 00:00:00 2001 From: Ernst Widerberg Date: Sun, 29 May 2016 11:06:52 +0200 Subject: [PATCH 2/3] Docs: ex command list --- doc/startify.txt | 41 ++++++++++++++++++++++++++++++++++++----- 1 file changed, 36 insertions(+), 5 deletions(-) diff --git a/doc/startify.txt b/doc/startify.txt index 1c28f85..f7ca2a2 100644 --- a/doc/startify.txt +++ b/doc/startify.txt @@ -36,8 +36,8 @@ CONTENTS *startify-contents* ============================================================================== INTRO *startify-intro* -Startify is a plugin that shows recently used files, bookmarks and -sessions that were saved to a certain directory. +Startify is a plugin that shows recently used files, bookmarks, ex commands +and sessions that were saved to a certain directory. ============================================================================== USAGE *startify-usage* @@ -48,8 +48,8 @@ Startify basically provides two things: it reads from STDIN), startify will show a small but pretty start screen that shows recently used files (using viminfo) and sessions by default. - Additionally, you can define bookmarks, thus entries for files that always - should be available on the start screen. + Additionally, you can define bookmarks (thus entries for files) and ex + commands that always should be available on the start screen. You can either navigate to a certain menu entry and hit enter or you just key in whatever is written between the square brackets on that line. You @@ -87,6 +87,7 @@ default values. Most used options:~ |g:startify_bookmarks| + |g:startify_ex_commands| |g:startify_change_to_dir| |g:startify_change_to_vcs_root| |g:startify_custom_header| @@ -128,7 +129,8 @@ The default for Windows systems is '$HOME\vimfiles\session'. ------------------------------------------------------------------------------ *g:startify_list_order* > - let g:startify_list_order = ['files', 'dir', 'bookmarks', 'sessions'] + let g:startify_list_order = ['files', 'dir', 'bookmarks', 'sessions', + \ 'ex_commands'] < At the moment startify supports these lists:~ @@ -151,6 +153,10 @@ At the moment startify supports these lists:~ This lists all the sessions saved in the directory |g:startify_session_dir|. +5) "ex_commands" + + This lists ex commands defined in |g:startify_ex_commands|. + Section headers:~ Additionally you can add lists of strings to that list. These will be shown @@ -174,6 +180,8 @@ Section headers example:~ \ 'sessions', \ [' These are my bookmarks:'], \ 'bookmarks', + \ [' These are my ex commands:'], + \ 'ex_commands', \ ] < Feel free to add some cool ASCII action! @@ -193,6 +201,22 @@ Example: < NOTE: Avoid using keys from |startify-mappings| if providing custom indices. +------------------------------------------------------------------------------ + *g:startify_ex_commands* +> + let g:startify_ex_commands = [] +< +A list of ex commands (without the colon) to display on the start screen. The +list can contain two kinds of types. Either an ex command or a dictionary +whereas the key is the custom index and the value the ex command. + +Example: +> + let g:startify_ex_commands = [ {'s': 'enew | set ft=sql'}, + \ 'colorscheme bclear' ] +< +NOTE: Avoid using keys from |startify-mappings| if providing custom indices. + ------------------------------------------------------------------------------ *g:startify_files_number* > @@ -889,6 +913,8 @@ This is my configuration.. \ 'sessions', \ [' Bookmarks:'], \ 'bookmarks', + \ [' Ex commands:'], + \ 'ex_commands', \ ] let g:startify_skiplist = [ @@ -903,6 +929,11 @@ This is my configuration.. \ '~/golfing', \ ] + let g:startify_ex_commands = [ + \ { 's': 'enew | set ft=sql' }, + \ 'colorscheme bclear', + \ ] + let g:startify_custom_footer = \ ['', " Vim is charityware. Please read ':help uganda'.", ''] From e5ce53fbef2955bb193791cdfa0044ce8cfa72ef Mon Sep 17 00:00:00 2001 From: Marco Hinz Date: Tue, 31 May 2016 23:32:51 +0200 Subject: [PATCH 3/3] Make g:startify_commands more flexible --- autoload/startify.vim | 27 ++++++++++++---------- doc/startify.txt | 53 ++++++++++++++++--------------------------- 2 files changed, 34 insertions(+), 46 deletions(-) diff --git a/autoload/startify.vim b/autoload/startify.vim index 2f5e634..93b2839 100644 --- a/autoload/startify.vim +++ b/autoload/startify.vim @@ -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('$', '') diff --git a/doc/startify.txt b/doc/startify.txt index f7ca2a2..07958b4 100644 --- a/doc/startify.txt +++ b/doc/startify.txt @@ -36,8 +36,8 @@ CONTENTS *startify-contents* ============================================================================== INTRO *startify-intro* -Startify is a plugin that shows recently used files, bookmarks, ex commands -and sessions that were saved to a certain directory. +Startify is a plugin that shows recently used files, bookmarks, commands and +sessions that were saved to a certain directory. ============================================================================== USAGE *startify-usage* @@ -48,7 +48,7 @@ Startify basically provides two things: it reads from STDIN), startify will show a small but pretty start screen that shows recently used files (using viminfo) and sessions by default. - Additionally, you can define bookmarks (thus entries for files) and ex + Additionally, you can define bookmarks (thus entries for files) and commands that always should be available on the start screen. You can either navigate to a certain menu entry and hit enter or you just @@ -87,7 +87,6 @@ default values. Most used options:~ |g:startify_bookmarks| - |g:startify_ex_commands| |g:startify_change_to_dir| |g:startify_change_to_vcs_root| |g:startify_custom_header| @@ -98,6 +97,7 @@ default values. |g:startify_update_oldfiles| Misc options:~ + |g:startify_commands| |g:startify_custom_footer| |g:startify_custom_header_quotes| |g:startify_custom_indices| @@ -130,7 +130,7 @@ The default for Windows systems is '$HOME\vimfiles\session'. *g:startify_list_order* > let g:startify_list_order = ['files', 'dir', 'bookmarks', 'sessions', - \ 'ex_commands'] + \ 'commands'] < At the moment startify supports these lists:~ @@ -153,9 +153,9 @@ At the moment startify supports these lists:~ This lists all the sessions saved in the directory |g:startify_session_dir|. -5) "ex_commands" +5) "commands" - This lists ex commands defined in |g:startify_ex_commands|. + This lists commands defined in |g:startify_commands|. Section headers:~ @@ -180,8 +180,8 @@ Section headers example:~ \ 'sessions', \ [' These are my bookmarks:'], \ 'bookmarks', - \ [' These are my ex commands:'], - \ 'ex_commands', + \ [' These are my commands:'], + \ 'commands', \ ] < Feel free to add some cool ASCII action! @@ -202,18 +202,21 @@ Example: NOTE: Avoid using keys from |startify-mappings| if providing custom indices. ------------------------------------------------------------------------------ - *g:startify_ex_commands* + *g:startify_commands* > - let g:startify_ex_commands = [] + let g:startify_commands = [] < -A list of ex commands (without the colon) to display on the start screen. The -list can contain two kinds of types. Either an ex command or a dictionary -whereas the key is the custom index and the value the ex command. +A list of commands to execute on selection. Leading colons are optional. It +supports optional custom indices and/or command descriptions. Example: > - let g:startify_ex_commands = [ {'s': 'enew | set ft=sql'}, - \ 'colorscheme bclear' ] + let g:startify_commands = [ + \ ':help reference', + \ ['Vim Reference', 'h ref'], + \ {'h': 'h ref'}, + \ {'m': ['My magical function', 'call Magic()']}, + \ ] < NOTE: Avoid using keys from |startify-mappings| if providing custom indices. @@ -904,19 +907,6 @@ This is my configuration.. let g:startify_session_persistence = 1 let g:startify_session_delete_buffers = 1 - let g:startify_list_order = [ - \ [' LRU:'], - \ 'files', - \ [' LRU within this dir:'], - \ 'dir', - \ [' Sessions:'], - \ 'sessions', - \ [' Bookmarks:'], - \ 'bookmarks', - \ [' Ex commands:'], - \ 'ex_commands', - \ ] - let g:startify_skiplist = [ \ 'COMMIT_EDITMSG', \ 'bundle/.*/doc', @@ -929,11 +919,6 @@ This is my configuration.. \ '~/golfing', \ ] - let g:startify_ex_commands = [ - \ { 's': 'enew | set ft=sql' }, - \ 'colorscheme bclear', - \ ] - let g:startify_custom_footer = \ ['', " Vim is charityware. Please read ':help uganda'.", '']