Skip to content

Commit

Permalink
Do not cache options
Browse files Browse the repository at this point in the history
There was never a technical reason for it anyway.

Closes mhinz#409
  • Loading branch information
mhinz committed Oct 6, 2020
1 parent 04ad724 commit 60bae7f
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 40 deletions.
64 changes: 33 additions & 31 deletions autoload/startify.vim
Original file line number Diff line number Diff line change
Expand Up @@ -97,14 +97,14 @@ function! startify#insane_in_the_membrane(on_vimenter) abort
\ 'tick': 0,
\ }

if s:show_special
call append('$', [s:padding_left .'[e] <empty buffer>', ''])
if g:startify_enable_special
call append('$', [g:startify_padding_left .'[e] <empty buffer>', ''])
endif
call s:register(line('$')-1, 'e', 'special', 'enew', '')

let b:startify.entry_number = 0
if filereadable('Session.vim')
call append('$', [s:padding_left .'[0] '. getcwd() . s:sep .'Session.vim', ''])
call append('$', [g:startify_padding_left .'[0] '. getcwd() . s:sep .'Session.vim', ''])
call s:register(line('$')-1, '0', 'session',
\ 'call startify#session_delete_buffers() | source', 'Session.vim')
let b:startify.entry_number = 1
Expand All @@ -122,8 +122,8 @@ function! startify#insane_in_the_membrane(on_vimenter) abort

silent $delete _

if s:show_special
call append('$', ['', s:padding_left .'[q] <quit>'])
if g:startify_enable_special
call append('$', ['', g:startify_padding_left .'[q] <quit>'])
call s:register(line('$'), 'q', 'special', 'call s:close()', '')
else
" Don't overwrite the last regular entry, thus +1
Expand All @@ -134,7 +134,7 @@ function! startify#insane_in_the_membrane(on_vimenter) abort
let b:startify.firstline = 2
let b:startify.firstline += len(g:startify_header)
" no special, no local Session.vim, but a section header
if !s:show_special && !exists('l:show_session') && has_key(lists[0], 'header')
if !g:startify_enable_special && !exists('l:show_session') && has_key(lists[0], 'header')
let b:startify.firstline += len(lists[0].header) + 1
endif

Expand Down Expand Up @@ -431,7 +431,7 @@ endfunction

" Function: #pad {{{1
function! startify#pad(lines) abort
return map(copy(a:lines), 's:padding_left . v:val')
return map(copy(a:lines), 'g:startify_padding_left . v:val')
endfunction

" Function: #center {{{1
Expand Down Expand Up @@ -464,11 +464,11 @@ function! s:get_lists() abort
return lists
else
return [
\ { 'header': [s:padding_left .'MRU'], 'type': 'files' },
\ { 'header': [s:padding_left .'MRU '. getcwd()], 'type': 'dir' },
\ { 'header': [s:padding_left .'Sessions'], 'type': 'sessions' },
\ { 'header': [s:padding_left .'Bookmarks'], 'type': 'bookmarks' },
\ { 'header': [s:padding_left .'Commands'], 'type': 'commands' },
\ { 'header': [g:startify_padding_left .'MRU'], 'type': 'files' },
\ { 'header': [g:startify_padding_left .'MRU '. getcwd()], 'type': 'dir' },
\ { 'header': [g:startify_padding_left .'Sessions'], 'type': 'sessions' },
\ { 'header': [g:startify_padding_left .'Bookmarks'], 'type': 'bookmarks' },
\ { 'header': [g:startify_padding_left .'Commands'], 'type': 'commands' },
\ ]
endif
endfunction
Expand Down Expand Up @@ -509,7 +509,7 @@ function! s:show_lists(lists) abort
let path = get(entry, 'path', '')
let type = get(entry, 'type', empty(path) ? 'special' : 'file')
let index = s:get_index_as_string()
call append('$', s:padding_left .'['. index .']'. repeat(' ', (3 - strlen(index))) . entry.line)
call append('$', g:startify_padding_left .'['. index .']'. repeat(' ', (3 - strlen(index))) . entry.line)
call s:register(line('$'), index, type, cmd, path)
endfor
call append('$', '')
Expand Down Expand Up @@ -556,7 +556,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',
\ [a:path_prefix, a:path_format, a:use_env])

let entry_format = "s:padding_left .'['. index .']'. repeat(' ', (3 - strlen(index))) ."
let entry_format = "g:startify_padding_left .'['. index .']'. repeat(' ', (3 - strlen(index))) ."
if exists('*StartifyEntryFormat')
let entry_format .= StartifyEntryFormat()
else
Expand Down Expand Up @@ -584,7 +584,7 @@ endfunction
" Function: s:filter_oldfiles {{{1
function! s:filter_oldfiles(path_prefix, path_format, use_env) abort
let path_prefix = '\V'. escape(a:path_prefix, '\')
let counter = s:numfiles
let counter = g:startify_files_number
let entries = {}
let oldfiles = []

Expand All @@ -608,7 +608,7 @@ function! s:filter_oldfiles(path_prefix, path_format, use_env) abort
endif

let entry_path = ''
if s:tf
if !empty(g:startify_transformations)
let entry_path = s:transform(absolute_path)
endif
if empty(entry_path)
Expand Down Expand Up @@ -639,7 +639,7 @@ endfunction
" Function: s:filter_oldfiles_unsafe {{{1
function! s:filter_oldfiles_unsafe(path_prefix, path_format, use_env) abort
let path_prefix = '\V'. escape(a:path_prefix, '\')
let counter = s:numfiles
let counter = g:startify_files_number
let entries = {}
let oldfiles = []
let is_dir = escape(s:sep, '\') . '$'
Expand Down Expand Up @@ -679,7 +679,7 @@ endfunction

" Function: s:show_files {{{1
function! s:show_files() abort
return s:display_by_path('', s:relative_path, get(g:, 'startify_use_env'))
return s:display_by_path('', g:startify_relative_path, get(g:, 'startify_use_env'))
endfunction

" Function: s:show_sessions {{{1
Expand Down Expand Up @@ -717,7 +717,7 @@ function! s:show_sessions() abort
let index = s:get_index_as_string()
let fname = fnamemodify(sfiles[i], ':t')
let dname = sfiles[i] ==# v:this_session ? fname.' (*)' : fname
call append('$', s:padding_left .'['. index .']'. repeat(' ', (3 - strlen(index))) . dname)
call append('$', g:startify_padding_left .'['. index .']'. repeat(' ', (3 - strlen(index))) . dname)
if has('win32')
let fname = substitute(fname, '\[', '\[[]', 'g')
endif
Expand Down Expand Up @@ -748,13 +748,13 @@ function! s:show_bookmarks() abort
endif

let entry_path = ''
if s:tf
if !empty(g:startify_transformations)
let entry_path = s:transform(fnamemodify(resolve(expand(path)), ':p'))
endif
if empty(entry_path)
let entry_path = path
endif
call append('$', s:padding_left .'['. index .']'. repeat(' ', (3 - strlen(index))) . entry_path)
call append('$', g:startify_padding_left .'['. index .']'. repeat(' ', (3 - strlen(index))) . entry_path)

if has('win32')
let path = substitute(path, '\[', '\[[]', 'g')
Expand Down Expand Up @@ -787,7 +787,7 @@ function! s:show_commands() abort
" If no list is given, the description is the command itself.
let [desc, cmd] = type(command) == type([]) ? command : [command, command]

call append('$', s:padding_left .'['. index .']'. repeat(' ', (3 - strlen(index))) . desc)
call append('$', g:startify_padding_left .'['. index .']'. repeat(' ', (3 - strlen(index))) . desc)
call s:register(line('$'), index, 'special', cmd, '')

unlet entry command
Expand All @@ -798,7 +798,7 @@ endfunction

" Function: s:is_in_skiplist {{{1
function! s:is_in_skiplist(arg) abort
for regexp in s:skiplist
for regexp in g:startify_skiplist
try
if a:arg =~# regexp
return 1
Expand All @@ -811,7 +811,9 @@ endfunction

" Function: s:set_cursor {{{1
function! s:set_cursor() abort
let b:startify.oldline = exists('b:startify.newline') ? b:startify.newline : 2 + len(s:padding_left)
let b:startify.oldline = exists('b:startify.newline')
\ ? b:startify.newline
\ : 2 + len(g:startify_padding_left)
let b:startify.newline = line('.')

" going up (-1) or down (1)
Expand Down Expand Up @@ -1107,13 +1109,13 @@ endfunction
" Init: values {{{1
let s:sep = startify#get_separator()

let s:numfiles = get(g:, 'startify_files_number', 10)
let s:show_special = get(g:, 'startify_enable_special', 1)
let s:relative_path = get(g:, 'startify_relative_path') ? ':~:.' : ':p:~'
let s:tf = exists('g:startify_transformations')
let g:startify_files_number = get(g:, 'startify_files_number', 10)
let g:startify_enable_special = get(g:, 'startify_enable_special', 1)
let g:startify_relative_path = get(g:, 'startify_relative_path') ? ':~:.' : ':p:~'
let s:session_dir = startify#get_session_path()
let g:startify_transformations = get(g:, 'startify_transformations', [])

let s:skiplist = extend(get(g:, 'startify_skiplist', []), [
let g:startify_skiplist = extend(get(g:, 'startify_skiplist', []), [
\ 'runtime/doc/.*\.txt$',
\ 'bundle/.*/doc/.*\.txt$',
\ 'plugged/.*/doc/.*\.txt$',
Expand All @@ -1122,6 +1124,6 @@ let s:skiplist = extend(get(g:, 'startify_skiplist', []), [
\ escape(fnamemodify(resolve($VIMRUNTIME), ':p'), '\') .'doc/.*\.txt$',
\ ], 'keep')

let s:padding_left = repeat(' ', get(g:, 'startify_padding_left', 3))
let s:fixed_column = len(s:padding_left) + 2
let g:startify_padding_left = repeat(' ', get(g:, 'startify_padding_left', 3))
let s:fixed_column = len(g:startify_padding_left) + 2
let s:batchmode = ''
18 changes: 9 additions & 9 deletions autoload/startify/fortune.vim
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ endfunction

" Function: #quote {{{1
function! startify#fortune#quote() abort
return s:quotes[s:get_random_offset(len(s:quotes))]
return g:startify_custom_header_quotes[s:get_random_offset(len(g:startify_custom_header_quotes))]
endfunction

" Function: #boxed {{{1
Expand Down Expand Up @@ -73,14 +73,14 @@ let s:cow = [
\ ' || ||',
\ ]

let s:unicode = &encoding == 'utf-8' && get(g:, 'startify_fortune_use_unicode')
let g:startify_fortune_use_unicode = &encoding == 'utf-8' && get(g:, 'startify_fortune_use_unicode')

let s:char_top_bottom = ['-', ''][s:unicode]
let s:char_sides = ['|', ''][s:unicode]
let s:char_top_left = ['*', ''][s:unicode]
let s:char_top_right = ['*', ''][s:unicode]
let s:char_bottom_right = ['*', ''][s:unicode]
let s:char_bottom_left = ['*', ''][s:unicode]
let s:char_top_bottom = ['-', ''][g:startify_fortune_use_unicode]
let s:char_sides = ['|', ''][g:startify_fortune_use_unicode]
let s:char_top_left = ['*', ''][g:startify_fortune_use_unicode]
let s:char_top_right = ['*', ''][g:startify_fortune_use_unicode]
let s:char_bottom_right = ['*', ''][g:startify_fortune_use_unicode]
let s:char_bottom_left = ['*', ''][g:startify_fortune_use_unicode]

let s:predefined_quotes = [
\ ["Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.", '', '- Brian Kernighan'],
Expand Down Expand Up @@ -238,6 +238,6 @@ let s:predefined_quotes = [
\ ['What one programmer can do in one month, two programmers can do in two months.', '', '- Frederick P. Brooks'],
\ ]

let s:quotes = exists('g:startify_custom_header_quotes')
let g:startify_custom_header_quotes = exists('g:startify_custom_header_quotes')
\ ? g:startify_custom_header_quotes
\ : startify#fortune#predefined_quotes()

0 comments on commit 60bae7f

Please sign in to comment.