Refactoring: fortune.vim
This commit is contained in:
parent
6509329585
commit
994a85ac22
|
@ -70,7 +70,7 @@ function! startify#insane_in_the_membrane() abort
|
||||||
" Must be global so that it can be read by syntax/startify.vim.
|
" Must be global so that it can be read by syntax/startify.vim.
|
||||||
let g:startify_header = exists('g:startify_custom_header')
|
let g:startify_header = exists('g:startify_custom_header')
|
||||||
\ ? copy(g:startify_custom_header)
|
\ ? copy(g:startify_custom_header)
|
||||||
\ : startify#fortune#get_random_quote()
|
\ : startify#fortune#cowsay()
|
||||||
let g:startify_header += [''] " add blank line
|
let g:startify_header += [''] " add blank line
|
||||||
call append('$', g:startify_header)
|
call append('$', g:startify_header)
|
||||||
|
|
||||||
|
|
|
@ -11,6 +11,7 @@ let s:cow = [
|
||||||
let s:quotes = exists('g:startify_custom_header_quotes')
|
let s:quotes = exists('g:startify_custom_header_quotes')
|
||||||
\ ? g:startify_custom_header_quotes
|
\ ? g:startify_custom_header_quotes
|
||||||
\ : [
|
\ : [
|
||||||
|
\ ["If you don't fail at least 90% of the time, you're not aiming high enough.", '', '- Alan Kay'],
|
||||||
\ ['I think a lot of new programmers like to use advanced data structures and advanced language features as a way of demonstrating their ability. I call it the lion-tamer syndrome. Such demonstrations are impressive, but unless they actually translate into real wins for the project, avoid them.', '', '- Glyn Williams'],
|
\ ['I think a lot of new programmers like to use advanced data structures and advanced language features as a way of demonstrating their ability. I call it the lion-tamer syndrome. Such demonstrations are impressive, but unless they actually translate into real wins for the project, avoid them.', '', '- Glyn Williams'],
|
||||||
\ ['I would rather die of passion than of boredom.', '', '- Vincent Van Gogh'],
|
\ ['I would rather die of passion than of boredom.', '', '- Vincent Van Gogh'],
|
||||||
\ ['If a system is to serve the creative spirit, it must be entirely comprehensible to a single individual.'],
|
\ ['If a system is to serve the creative spirit, it must be entirely comprehensible to a single individual.'],
|
||||||
|
@ -128,14 +129,25 @@ function! s:draw_box(lines) abort
|
||||||
return lines
|
return lines
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
" Function: #get_random_quote {{{1
|
" Function: #quote {{{1
|
||||||
function! startify#fortune#get_random_quote() abort
|
function! startify#fortune#quote() abort
|
||||||
let quote = s:quotes[s:get_random_offset(len(s:quotes))]
|
return s:quotes[s:get_random_offset(len(s:quotes))]
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
" Function: #boxed {{{1
|
||||||
|
function! startify#fortune#boxed() abort
|
||||||
let wrapped_quote = []
|
let wrapped_quote = []
|
||||||
|
let quote = startify#fortune#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
|
||||||
let wrapped_quote = s:draw_box(wrapped_quote)
|
let wrapped_quote = s:draw_box(wrapped_quote)
|
||||||
let wrapped_quote += s:cow
|
return wrapped_quote
|
||||||
return map(wrapped_quote, '" ". v:val')
|
endfunction
|
||||||
|
|
||||||
|
" Function: #cowsay {{{1
|
||||||
|
function! startify#fortune#cowsay() abort
|
||||||
|
let boxed_quote = startify#fortune#boxed()
|
||||||
|
let boxed_quote += s:cow
|
||||||
|
return map(boxed_quote, '" ". v:val')
|
||||||
endfunction
|
endfunction
|
||||||
|
|
Loading…
Reference in a new issue