Move two helper functions to plugin file out of autoload. Plugin would have called them at startup anyway, defeating the whole purpose of autoload file.

This commit is contained in:
Ivan Tishchenko 2015-01-10 00:23:21 +03:00
parent 6b0be58392
commit 66626ad415
2 changed files with 35 additions and 38 deletions

View File

@ -8,42 +8,6 @@ if exists("g:loaded_vimwiki_auto") || &cp
endif endif
let g:loaded_vimwiki_auto = 1 let g:loaded_vimwiki_auto = 1
" MISC helper functions {{{
function! vimwiki#base#get_known_extensions() " {{{
" Getting all extensions that different wikis could have
let extensions = {}
for wiki in g:vimwiki_list
if has_key(wiki, 'ext')
let extensions[wiki.ext] = 1
else
let extensions['.wiki'] = 1
endif
endfor
" append map g:vimwiki_ext2syntax
for ext in keys(g:vimwiki_ext2syntax)
let extensions[ext] = 1
endfor
return keys(extensions)
endfunction " }}}
function! vimwiki#base#get_known_syntaxes() " {{{
" Getting all syntaxes that different wikis could have
let syntaxes = {}
let syntaxes['default'] = 1
for wiki in g:vimwiki_list
if has_key(wiki, 'syntax')
let syntaxes[wiki.syntax] = 1
endif
endfor
" append map g:vimwiki_ext2syntax
for syn in values(g:vimwiki_ext2syntax)
let syntaxes[syn] = 1
endfor
return keys(syntaxes)
endfunction " }}}
" }}}
" vimwiki#base#apply_wiki_options " vimwiki#base#apply_wiki_options
function! vimwiki#base#apply_wiki_options(options) " {{{ Update the current function! vimwiki#base#apply_wiki_options(options) " {{{ Update the current
" wiki using the options dictionary " wiki using the options dictionary
@ -1941,7 +1905,7 @@ endfunction " }}}
" ------------------------------------------------------------------------- " -------------------------------------------------------------------------
" Load syntax-specific Wiki functionality " Load syntax-specific Wiki functionality
for s:syn in vimwiki#base#get_known_syntaxes() for s:syn in VimwikiGetKnownSyntaxes()
execute 'runtime! autoload/vimwiki/'.s:syn.'_base.vim' execute 'runtime! autoload/vimwiki/'.s:syn.'_base.vim'
endfor endfor
" ------------------------------------------------------------------------- " -------------------------------------------------------------------------

View File

@ -357,6 +357,39 @@ function! VimwikiClear(option, ...) "{{{
endfunction "}}} endfunction "}}}
" }}} " }}}
function! VimwikiGetKnownExtensions() " {{{
" Getting all extensions that different wikis could have
let extensions = {}
for wiki in g:vimwiki_list
if has_key(wiki, 'ext')
let extensions[wiki.ext] = 1
else
let extensions['.wiki'] = 1
endif
endfor
" append map g:vimwiki_ext2syntax
for ext in keys(g:vimwiki_ext2syntax)
let extensions[ext] = 1
endfor
return keys(extensions)
endfunction " }}}
function! VimwikiGetKnownSyntaxes() " {{{
" Getting all syntaxes that different wikis could have
let syntaxes = {}
let syntaxes['default'] = 1
for wiki in g:vimwiki_list
if has_key(wiki, 'syntax')
let syntaxes[wiki.syntax] = 1
endif
endfor
" append map g:vimwiki_ext2syntax
for syn in values(g:vimwiki_ext2syntax)
let syntaxes[syn] = 1
endfor
return keys(syntaxes)
endfunction " }}}
" }}} " }}}
" CALLBACK functions "{{{ " CALLBACK functions "{{{
@ -486,7 +519,7 @@ augroup end
augroup vimwiki augroup vimwiki
autocmd! autocmd!
for s:ext in vimwiki#base#get_known_extensions() for s:ext in VimwikiGetKnownExtensions()
exe 'autocmd BufEnter *'.s:ext.' call s:setup_buffer_reenter()' exe 'autocmd BufEnter *'.s:ext.' call s:setup_buffer_reenter()'
exe 'autocmd BufWinEnter *'.s:ext.' call s:setup_buffer_enter()' exe 'autocmd BufWinEnter *'.s:ext.' call s:setup_buffer_enter()'
exe 'autocmd BufLeave,BufHidden *'.s:ext.' call s:setup_buffer_leave()' exe 'autocmd BufLeave,BufHidden *'.s:ext.' call s:setup_buffer_leave()'