Răsfoiți Sursa

Do not cache options

There was never a technical reason for it anyway.

Closes https://github.com/mhinz/vim-startify/issues/409
Marco Hinz 5 ani în urmă
părinte
comite
60bae7f08e
2 a modificat fișierele cu 42 adăugiri și 40 ștergeri
  1. 33 31
      autoload/startify.vim
  2. 9 9
      autoload/startify/fortune.vim

+ 33 - 31
autoload/startify.vim

@@ -97,14 +97,14 @@ function! startify#insane_in_the_membrane(on_vimenter) abort
         \ 'tick':      0,
         \ '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
   endif
   call s:register(line('$')-1, 'e', 'special', 'enew', '')
   call s:register(line('$')-1, 'e', 'special', 'enew', '')
 
 
   let b:startify.entry_number = 0
   let b:startify.entry_number = 0
   if filereadable('Session.vim')
   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 s:register(line('$')-1, '0', 'session',
           \ 'call startify#session_delete_buffers() | source', 'Session.vim')
           \ 'call startify#session_delete_buffers() | source', 'Session.vim')
     let b:startify.entry_number = 1
     let b:startify.entry_number = 1
@@ -122,8 +122,8 @@ function! startify#insane_in_the_membrane(on_vimenter) abort
 
 
   silent $delete _
   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()', '')
     call s:register(line('$'), 'q', 'special', 'call s:close()', '')
   else
   else
     " Don't overwrite the last regular entry, thus +1
     " Don't overwrite the last regular entry, thus +1
@@ -134,7 +134,7 @@ function! startify#insane_in_the_membrane(on_vimenter) abort
   let b:startify.firstline = 2
   let b:startify.firstline = 2
   let b:startify.firstline += len(g:startify_header)
   let b:startify.firstline += len(g:startify_header)
   " no special, no local Session.vim, but a section 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
     let b:startify.firstline += len(lists[0].header) + 1
   endif
   endif
 
 
@@ -431,7 +431,7 @@ endfunction
 
 
 " Function: #pad {{{1
 " Function: #pad {{{1
 function! startify#pad(lines) abort
 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
 endfunction
 
 
 " Function: #center {{{1
 " Function: #center {{{1
@@ -464,11 +464,11 @@ function! s:get_lists() abort
     return lists
     return lists
   else
   else
     return [
     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
   endif
 endfunction
 endfunction
@@ -509,7 +509,7 @@ function! s:show_lists(lists) abort
         let path = get(entry, 'path', '')
         let path = get(entry, 'path', '')
         let type = get(entry, 'type', empty(path) ? 'special' : 'file')
         let type = get(entry, 'type', empty(path) ? 'special' : 'file')
         let index = s:get_index_as_string()
         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)
         call s:register(line('$'), index, type, cmd, path)
       endfor
       endfor
       call append('$', '')
       call append('$', '')
@@ -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',
   let oldfiles = call(get(g:, 'startify_enable_unsafe') ? 's:filter_oldfiles_unsafe' : 's:filter_oldfiles',
         \ [a:path_prefix, a:path_format, a:use_env])
         \ [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')
   if exists('*StartifyEntryFormat')
     let entry_format .= StartifyEntryFormat()
     let entry_format .= StartifyEntryFormat()
   else
   else
@@ -584,7 +584,7 @@ endfunction
 " Function: s:filter_oldfiles {{{1
 " Function: s:filter_oldfiles {{{1
 function! s:filter_oldfiles(path_prefix, path_format, use_env) abort
 function! s:filter_oldfiles(path_prefix, path_format, use_env) abort
   let path_prefix = '\V'. escape(a:path_prefix, '\')
   let path_prefix = '\V'. escape(a:path_prefix, '\')
-  let counter     = s:numfiles
+  let counter     = g:startify_files_number
   let entries     = {}
   let entries     = {}
   let oldfiles    = []
   let oldfiles    = []
 
 
@@ -608,7 +608,7 @@ function! s:filter_oldfiles(path_prefix, path_format, use_env) abort
     endif
     endif
 
 
     let entry_path = ''
     let entry_path = ''
-    if s:tf
+    if !empty(g:startify_transformations)
       let entry_path = s:transform(absolute_path)
       let entry_path = s:transform(absolute_path)
     endif
     endif
     if empty(entry_path)
     if empty(entry_path)
@@ -639,7 +639,7 @@ endfunction
 " Function: s:filter_oldfiles_unsafe {{{1
 " Function: s:filter_oldfiles_unsafe {{{1
 function! s:filter_oldfiles_unsafe(path_prefix, path_format, use_env) abort
 function! s:filter_oldfiles_unsafe(path_prefix, path_format, use_env) abort
   let path_prefix = '\V'. escape(a:path_prefix, '\')
   let path_prefix = '\V'. escape(a:path_prefix, '\')
-  let counter     = s:numfiles
+  let counter     = g:startify_files_number
   let entries     = {}
   let entries     = {}
   let oldfiles    = []
   let oldfiles    = []
   let is_dir      = escape(s:sep, '\') . '$'
   let is_dir      = escape(s:sep, '\') . '$'
@@ -679,7 +679,7 @@ endfunction
 
 
 " Function: s:show_files {{{1
 " Function: s:show_files {{{1
 function! s:show_files() abort
 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
 endfunction
 
 
 " Function: s:show_sessions {{{1
 " Function: s:show_sessions {{{1
@@ -717,7 +717,7 @@ function! s:show_sessions() abort
     let index = s:get_index_as_string()
     let index = s:get_index_as_string()
     let fname = fnamemodify(sfiles[i], ':t')
     let fname = fnamemodify(sfiles[i], ':t')
     let dname = sfiles[i] ==# v:this_session ? fname.' (*)' : fname
     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')
     if has('win32')
       let fname = substitute(fname, '\[', '\[[]', 'g')
       let fname = substitute(fname, '\[', '\[[]', 'g')
     endif
     endif
@@ -748,13 +748,13 @@ function! s:show_bookmarks() abort
     endif
     endif
 
 
     let entry_path = ''
     let entry_path = ''
-    if s:tf
+    if !empty(g:startify_transformations)
       let entry_path = s:transform(fnamemodify(resolve(expand(path)), ':p'))
       let entry_path = s:transform(fnamemodify(resolve(expand(path)), ':p'))
     endif
     endif
     if empty(entry_path)
     if empty(entry_path)
       let entry_path = path
       let entry_path = path
     endif
     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')
     if has('win32')
       let path = substitute(path, '\[', '\[[]', 'g')
       let path = substitute(path, '\[', '\[[]', 'g')
@@ -787,7 +787,7 @@ function! s:show_commands() abort
     " If no list is given, the description is the command itself.
     " If no list is given, the description is the command itself.
     let [desc, cmd] = type(command) == type([]) ? command : [command, command]
     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, '')
     call s:register(line('$'), index, 'special', cmd, '')
 
 
     unlet entry command
     unlet entry command
@@ -798,7 +798,7 @@ endfunction
 
 
 " Function: s:is_in_skiplist {{{1
 " Function: s:is_in_skiplist {{{1
 function! s:is_in_skiplist(arg) abort
 function! s:is_in_skiplist(arg) abort
-  for regexp in s:skiplist
+  for regexp in g:startify_skiplist
     try
     try
       if a:arg =~# regexp
       if a:arg =~# regexp
         return 1
         return 1
@@ -811,7 +811,9 @@ endfunction
 
 
 " Function: s:set_cursor {{{1
 " Function: s:set_cursor {{{1
 function! s:set_cursor() abort
 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('.')
   let b:startify.newline = line('.')
 
 
   " going up (-1) or down (1)
   " going up (-1) or down (1)
@@ -1107,13 +1109,13 @@ endfunction
 " Init: values {{{1
 " Init: values {{{1
 let s:sep = startify#get_separator()
 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 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$',
       \ 'runtime/doc/.*\.txt$',
       \ 'bundle/.*/doc/.*\.txt$',
       \ 'bundle/.*/doc/.*\.txt$',
       \ 'plugged/.*/doc/.*\.txt$',
       \ 'plugged/.*/doc/.*\.txt$',
@@ -1122,6 +1124,6 @@ let s:skiplist = extend(get(g:, 'startify_skiplist', []), [
       \ escape(fnamemodify(resolve($VIMRUNTIME), ':p'), '\') .'doc/.*\.txt$',
       \ escape(fnamemodify(resolve($VIMRUNTIME), ':p'), '\') .'doc/.*\.txt$',
       \ ], 'keep')
       \ ], '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 = ''
 let s:batchmode = ''

+ 9 - 9
autoload/startify/fortune.vim

@@ -22,7 +22,7 @@ endfunction
 
 
 " Function: #quote {{{1
 " Function: #quote {{{1
 function! startify#fortune#quote() abort
 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
 endfunction
 
 
 " Function: #boxed {{{1
 " Function: #boxed {{{1
@@ -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 = [
 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'],
       \ ["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'],
@@ -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'],
       \ ['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
       \ ? g:startify_custom_header_quotes
       \ : startify#fortune#predefined_quotes()
       \ : startify#fortune#predefined_quotes()