Make startify#fortune#boxe() handle funcref

References #285.
This commit is contained in:
Marco Hinz 2017-06-05 13:16:04 +02:00
parent 1940c9f9b9
commit 53c53b2444
No known key found for this signature in database
GPG key ID: 1C980A1B657B4A4F
2 changed files with 9 additions and 4 deletions

View file

@ -159,7 +159,8 @@ endfunction
" Function: #boxed {{{1 " Function: #boxed {{{1
function! startify#fortune#boxed(...) abort function! startify#fortune#boxed(...) abort
let wrapped_quote = [] let wrapped_quote = []
let quote = a:0 && type(a:1) == type([]) ? a:1 : startify#fortune#quote() let Quote = a:0 && type(a:1) == type([]) ? a:1 : startify#fortune#quote()
let quote = type(Quote) == type(function('tr')) ? Quote() : Quote
for line in quote for line in quote
let wrapped_quote += split(line, '\%50c.\{-}\zs\s', 1) let wrapped_quote += split(line, '\%50c.\{-}\zs\s', 1)
endfor endfor

View file

@ -589,11 +589,15 @@ Also have a look at |startify-faq-08|.
If you don't set |g:startify_custom_header|, the internal cowsay implementation If you don't set |g:startify_custom_header|, the internal cowsay implementation
with shipped random quotes will be used. with shipped random quotes will be used.
If you want to use your own quotes, add a list of lists, like this: To use your own quotes, set this option to a list of quotes. Each quote is
either another list or a |Funcref| (see |expr-lambda|) that returns a list.
Each element of the inner lists is put on an own line in the custom header.
> >
let g:startify_custom_header_quotes = [ let g:startify_custom_header_quotes = [
\ ['line 1', '', 'line 3'], \ ['quote #1'],
\ ['quote #2'] \ ['quote #2', 'using', 'three lines'],
\ {-> systemlist('echo quote #3')}
\ ] \ ]
< <
------------------------------------------------------------------------------ ------------------------------------------------------------------------------