From 66626ad415f4423c9d1e6bc57ae485a5685cf849 Mon Sep 17 00:00:00 2001 From: Ivan Tishchenko Date: Sat, 10 Jan 2015 00:23:21 +0300 Subject: [PATCH 1/3] 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. --- autoload/vimwiki/base.vim | 38 +------------------------------------- plugin/vimwiki.vim | 35 ++++++++++++++++++++++++++++++++++- 2 files changed, 35 insertions(+), 38 deletions(-) diff --git a/autoload/vimwiki/base.vim b/autoload/vimwiki/base.vim index dceb57d..49db2bd 100644 --- a/autoload/vimwiki/base.vim +++ b/autoload/vimwiki/base.vim @@ -8,42 +8,6 @@ if exists("g:loaded_vimwiki_auto") || &cp endif 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 function! vimwiki#base#apply_wiki_options(options) " {{{ Update the current " wiki using the options dictionary @@ -1941,7 +1905,7 @@ endfunction " }}} " ------------------------------------------------------------------------- " 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' endfor " ------------------------------------------------------------------------- diff --git a/plugin/vimwiki.vim b/plugin/vimwiki.vim index 8d3a577..ae6ac75 100644 --- a/plugin/vimwiki.vim +++ b/plugin/vimwiki.vim @@ -357,6 +357,39 @@ function! VimwikiClear(option, ...) "{{{ 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 "{{{ @@ -486,7 +519,7 @@ augroup end augroup vimwiki 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 BufWinEnter *'.s:ext.' call s:setup_buffer_enter()' exe 'autocmd BufLeave,BufHidden *'.s:ext.' call s:setup_buffer_leave()' From f5e1cbe72134bba611dc7ba8b71d03d0025d5d0b Mon Sep 17 00:00:00 2001 From: Ivan Tishchenko Date: Fri, 23 Jan 2015 22:41:36 +0300 Subject: [PATCH 2/3] Move get-known-sytaxes back into base.vim --- autoload/vimwiki/base.vim | 19 ++++++++++++++++++- plugin/vimwiki.vim | 16 ---------------- 2 files changed, 18 insertions(+), 17 deletions(-) diff --git a/autoload/vimwiki/base.vim b/autoload/vimwiki/base.vim index 49db2bd..752efb2 100644 --- a/autoload/vimwiki/base.vim +++ b/autoload/vimwiki/base.vim @@ -8,6 +8,23 @@ if exists("g:loaded_vimwiki_auto") || &cp endif let g:loaded_vimwiki_auto = 1 +" s:vimwiki_get_known_syntaxes +function! s:vimwiki_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 function! vimwiki#base#apply_wiki_options(options) " {{{ Update the current " wiki using the options dictionary @@ -1905,7 +1922,7 @@ endfunction " }}} " ------------------------------------------------------------------------- " Load syntax-specific Wiki functionality -for s:syn in VimwikiGetKnownSyntaxes() +for s:syn in s:vimwiki_get_known_syntaxes() execute 'runtime! autoload/vimwiki/'.s:syn.'_base.vim' endfor " ------------------------------------------------------------------------- diff --git a/plugin/vimwiki.vim b/plugin/vimwiki.vim index ae6ac75..aebf796 100644 --- a/plugin/vimwiki.vim +++ b/plugin/vimwiki.vim @@ -374,22 +374,6 @@ function! VimwikiGetKnownExtensions() " {{{ 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 "{{{ From 556f686431d990166ff993f87779b36d6c71a5f8 Mon Sep 17 00:00:00 2001 From: Ivan Tishchenko Date: Mon, 2 Feb 2015 22:07:17 +0300 Subject: [PATCH 3/3] Make VimwikiGetKnownExtensions into script-local function s:vimwiki_get_known_extensions --- plugin/vimwiki.vim | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugin/vimwiki.vim b/plugin/vimwiki.vim index aebf796..00e26df 100644 --- a/plugin/vimwiki.vim +++ b/plugin/vimwiki.vim @@ -357,7 +357,7 @@ function! VimwikiClear(option, ...) "{{{ endfunction "}}} " }}} -function! VimwikiGetKnownExtensions() " {{{ +function! s:vimwiki_get_known_extensions() " {{{ " Getting all extensions that different wikis could have let extensions = {} for wiki in g:vimwiki_list @@ -503,7 +503,7 @@ augroup end augroup vimwiki autocmd! - for s:ext in VimwikiGetKnownExtensions() + for s:ext in s:vimwiki_get_known_extensions() exe 'autocmd BufEnter *'.s:ext.' call s:setup_buffer_reenter()' exe 'autocmd BufWinEnter *'.s:ext.' call s:setup_buffer_enter()' exe 'autocmd BufLeave,BufHidden *'.s:ext.' call s:setup_buffer_leave()'