" Vimball Archiver by Charles E. Campbell, Jr., Ph.D. UseVimball finish doc/tplugin.txt [[[1 440 *tplugin.txt* A simple plugin loader/runtimepath manager Author: Tom Link, micathom at gmail com tplugin is a plugin management tool similar to pathogen. Other than pathogen tplugin expands the 'runtimepath' as needed (e.g. when calling a command or function that is defined in a bundle) in order to have minimal impact on startup time. This plugin helps users to deal with plugins that are distributed via source code repositories. Usually, you would make those plugins available to vim by adding the local copies of those repositories to |runtimepath|. The disadvantage of this approach is that the value of |runtimepath| becomes unnecessarily complex. If this is done at startup (e.g. when using the pathogen plugin), all plugins are loaded on each startup, which takes time. tplugin scans the local copies of those repositories for commands and functions. It then amends the |runtimepath| only if a respective command/function/map is called (similar to the AsNeeded plugin). This helps to keep your |runtimepath| simple and improve startup time. In order to achieve this goal, plugins are installed in an alternative directory structure where each plugin (consequently referred to as "repo" or "bundle") is installed in a subdirectory. tplugin takes care of "modifying 'runtimepath' and of loading the vim script files as necessary. For "compatibility with pathogen, all "bundle" subdirectories in the 'runtimepath' "are considered as roots -- unless tplugin seems to be installed as repo itself. alternative directory layout: ROOT/ repo1/ after/ autoload/ doc/ plugin/ repo2/ after/ autoload/ doc/ plugin/ ... Repos can be enabled (i.e. added to 'runtimepath') either explicitly with the |:TPlugin| command or automatically by calling a command, function, or by requesting a filetype plugin/syntax/indent file defined in a repo -- i.e. tplugin also provides an autoload facility similar to the AsNeeded plugin (vimscript #915). See below for details. The main purpose of this plugin was to facilitate the use of plugins that are downloaded from a VCS like git, svn etc. But it can also be used to handle plugins distributed as zip or tgz archives. For vimballs, you'll might have to use a non-standard vimball unpacker---like the one that can be found in the vimtlib repository. You can have more than one root directory although it currently (as of version 0.2) could cause problems and is deprecated. Usage~ By default, tplugin has autoload enabled. With autoload, you can use tplugin by (1) loading the macro in your |vimrc| file > " Put this close to the top of your vimrc file runtime macros/tplugin.vim (2) (optional step) setting non-standard root directories. The standard root-directory is where tplugin was installed in (see |:TPluginRoot|). > " Only necessary if you use a non-standard root directory TPluginRoot /home/x/src/bundle It might still be necessary to load certain plugins right on startup for them to work properly. (3) Start vim and collect the autoload information by running the |:TPluginScan| command. (4) Restart vim. The plugins will be loaded as soon as one of its functions or commands is called for the first time. Full example as it could be found in a |vimrc| file: > runtime macros/tplugin.vim TPluginRoot F:\vim-addons TPlugin vim-surround let g:snippets_dir = 'X:\vimfiles\snippets,F:\vim-addons\snipmate.vim\snippets' TPlugin snipmate.vim TPlugin! tlib_vim 02tlib *tplugin-dependencies* *tplugin-metadata* When enabling a repository (ROOT/REPO), e.g., by calling |:TPlugin|, the files ROOT/_tplugin_REPO.vim and ROOT/REPO/_tplugin.vim are loaded. These files allows users (or plugin developers) to, e.g., define dependencies (see |:TPluginBefore| and |:TPluginAfter|). CAVEAT: If you have a file after/plugin/foo.vim in you user vimfiles directory, this file will be loaded before any "managed" plugin "foo". You thus have to check in your after/plugin/foo.vim file if the plugin was already loaded. Contrary to the default plugin behaviour, those managed plugins are loaded when the |VimEnter| event is triggered, i.e. after all plugins (incl. the after directory) and |gvimrc| was loaded. This approach provides for a better control of which plugins should be loaded. You can load a managed plugin immediately by adding a bang '!' to the |:TPlugin| command. *tplugin-asneeded* AsNeeded Users~ tplugin can serve as a drop-in replacement for the AsNeeded plugin. Add the following command to you |vimrc| file: > TPluginRoot ~/vimfiles/AsNeeded/* Alternatively, move the files the AsNeeded subdirectory to REPOS/AsNeeded/plugin/. Run |:TPluginScan| in order to create autoload definitions for commands and functions. Contrary to the AsNeeded plugin, tplugin only supports autoload for || type of maps. Other autoload maps have to be defined by the user using the |TPluginMap()| function. Related work~ - Marc Weber's vim-addon-manager (my main source of inspiration for this script), which also provides downloading plugins and automatic dependency management: http://github.com/MarcWeber/vim-addon-manager (vimscript #2905) - Tim Pope's pathogen (vimscript #2332). - Charles E. Campbell's AsNeeded (vimscript #915) - A comprehensive list of plugin managers (download and update local copies of vim plugins): http://vim-scripts.org/tools.html - The ruby script I personally use to update local copies of source code repositories: http://github.com/tomtom/vcsdo If your VIM has compiled-in ruby support, you can use the :TPluginUpdate command to run vcsdo from within VIM. ----------------------------------------------------------------------- Install~ Edit the vba file and type: > :so % See :help vimball for details. If you have difficulties or use vim 7.0, please make sure, you have the current version of vimball (vimscript #1502) installed or update your runtime. Optional: If tlib (vimscript #1863) is available, its progressbar will be used to visualize the scan progress. Also available via git: http://github.com/tomtom/tplugin_vim/ ======================================================================== Contents~ g:tplugin_autoload ................. |g:tplugin_autoload| g:tplugin_menu_prefix .............. |g:tplugin_menu_prefix| g:tplugin_file ..................... |g:tplugin_file| g:tplugin_load_plugin .............. |g:tplugin_load_plugin| :TPlugin ........................... |:TPlugin| :TPluginRoot ....................... |:TPluginRoot| :TPluginScan ....................... |:TPluginScan| :TPluginBefore ..................... |:TPluginBefore| :TPluginAfter ...................... |:TPluginAfter| :TPluginUpdate ..................... |:TPluginUpdate| TPluginMap ......................... |TPluginMap()| TPluginFunction .................... |TPluginFunction()| TPluginCommand ..................... |TPluginCommand()| TPluginAddRoots .................... |TPluginAddRoots()| TPluginDependencies ................ |TPluginDependencies()| g:tplugin#autoload_exclude ......... |g:tplugin#autoload_exclude| g:tplugin#scan ..................... |g:tplugin#scan| g:tplugin#shallow_scan ............. |g:tplugin#shallow_scan| tplugin#ScanRoots .................. |tplugin#ScanRoots()| g:tplugin#vcsdo#script ............. |g:tplugin#vcsdo#script| g:tplugin#vcsdo#log_buffer ......... |g:tplugin#vcsdo#log_buffer| g:tplugin#vcsdo#exclude_roots_rx ... |g:tplugin#vcsdo#exclude_roots_rx| ======================================================================== macros/tplugin.vim~ *g:tplugin_autoload* g:tplugin_autoload (default: 1) Enable autoloading. See |:TPluginScan|, |:TPluginCommand|, and |:TPluginFunction|. Values: 1 ... Enable autoload (default) 2 ... Enable autoload and automatically run |:TPluginScan| after updating tplugin. *g:tplugin_menu_prefix* g:tplugin_menu_prefix (default: '') If autoload is enabled and this variable is non-empty, build a menu with available plugins. Menus are disabled by default because they are less useful than one might think with autoload enabled. A good choice for this variable would be, e.g., 'Plugin.T&Plugin.'. NOTE: You have to re-run |:TPluginScan| after setting this value. *g:tplugin_file* g:tplugin_file (default: '_tplugin') The prefix for tplugin control files. *g:tplugin_load_plugin* g:tplugin_load_plugin (default: []) A list of pairs [REGEXP, VALUE] that determine how tplugin handles autoload function calls and filetype plugins. When an autoload function or filetype plugin is loaded, the respective plugin is added to 'runtimepath'. This variable decides whether the corresponding plugin should be loaded too. Possible values are: . :: Don't load any plugins * :: Load all plugins (default if no REGEXP pattern matches the full repo directory name) *:TPlugin* :TPlugin[!] REPOSITORY [PLUGINS ...] IF REPOSITORY contains a slash or a backslash, it is considered the path relative from the current root directory to the plugin directory. This allows you to deal with repositories with a non-standard directory layout. Otherwise it is assumed that the source files are located in the "plugin" subdirectory. IF PLUGIN is "-", the REPOSITORY will be enabled but no plugin will be loaded. *:TPluginRoot* :TPluginRoot[!] DIRECTORY Define the root directory for the following |:TPlugin| commands. Read autoload information if available (see |g:tplugin_autoload| and |:TPluginScan|). With the optional , don't register commands, functions etc. when scanning the root with |:TPluginScan|. If DIRECTORY ends with "*", it doesn't refer to a directory hierarchy à la vimfiles but to a single "flat" directory. If tplugin was installed a directory called .vim or vimfiles, the default root directory is the "bundle" subdirectory of the first element in 'runtimepath'. Otherwise, the default root directory is the directory where tplugin_vim was installed in, i.e. this assumes that tplugin was loaded from ROOT/tplugin_vim/macros/tplugin.vim Example: > " A collection of git repositories TPluginRoot ~/src/git_repos " A directory with experimental plugins TPluginRoot ~/vimfiles/experimental_plugins/* < *:TPluginScan* :TPluginScan[!] [WHAT] [ROOT] Scan the current root directory for commands and functions. Save autoload information in "ROOT/_tplugin.vim". Where WHAT is a set of letters determining the information being collected. See |g:tplugin#scan| for details. With the optional '!', the autocommands are immediatly usable. Other than the AsNeeded plugin, tplugin doesn't support the creation of autoload information for maps. If you collect repositories in one than more directory, I'd suggest to create a special script. The source file may contain special markers that make :TPluginScan include text in the _tplugin.vim file: *@TPluginInclude* Blocks of non-empty lines are introduced with an @TPluginInclude tag: > " @TPluginInclude augroup Foo autocmd! autocmd Filetype foo call foo#Init() augroup END < Special lines are prefixed with @TPluginInclude: > " @TPluginInclude if !exists('g:foo') | let g:foo = 1 | endif < Example: > TPluginRoot dir1 TPluginScan TPluginRoot dir2 TPluginScan < *:TPluginBefore* :TPluginBefore FILE_RX COMMAND |:execute| COMMAND after loading a file matching the |regexp| pattern FILE_RX. The COMMAND is executed after the repo's path is added to the 'runtimepath'. This command should be best put into ROOT/tplugin_REPO.vim files, which are loaded when enabling a source repository. Example: > " Load master.vim before loading any plugin in a repo TPluginBefore plugin/.\{-}\.vim runtime! macros/master.vim < It can also be included in the comments of source files (you have to prepend it with a "@"): > "@TPluginBefore my_repo/autoload DoThis let loaded_yup = 1 < *:TPluginAfter* :TPluginAfter FILE_RX COMMAND |:execute| COMMAND after loading a file matching the |regexp| pattern FILE_RX. See also |:TPluginBefore|. *:TPluginUpdate* TPluginUpdate[!] Update all repos (VCS types only). Requires compiled-in ruby support and http://github.com/tomtom/vcsdo to be installed. You also have to set |g:tplugin#vcsdo#script|. With the optional !, show which commands would be issued but don't do anything. *TPluginMap()* TPluginMap(map, repo, plugin, ?remap="") MAP is a map command and the map. REPO and PLUGIN are the same as for the |:TPlugin| command. Examples: > " Map for Foo: call TPluginMap('map Foo', 'mylib', 'myplugin') " Load the plugin when pressing and remap the key to an appropriate " command from the autoloaded plugin: call TPluginMap('map ', 'mylib', 'myplugin', ':Foo') < *TPluginFunction()* TPluginFunction(FUNCTION, REPOSITORY, [PLUGIN]) Load a certain plugin on demand (aka autoload) when FUNCTION is called for the first time. *TPluginCommand()* TPluginCommand(COMMAND, REPOSITORY, [PLUGIN]) Load a certain plugin on demand (aka autoload) when COMMAND is called for the first time. Then call the original command. For most plugins, |:TPluginScan| will generate the appropriate TPluginCommand commands for you. For some plugins, you'll have to define autocommands yourself in the |vimrc| file. Example: > TPluginCommand TSelectBuffer vimtlib tselectbuffer < *TPluginAddRoots()* TPluginAddRoots(?subdir="bundle") Add all directories named SUBDIR as roots. *TPluginDependencies()* TPluginDependencies(repo, deps) ======================================================================== autoload/tplugin.vim~ *g:tplugin#autoload_exclude* g:tplugin#autoload_exclude (default: ['tplugin']) A list of repositories for which autoload is disabled when running |:TPluginScan|. *g:tplugin#scan* g:tplugin#scan (default: 'cfptham_') The default value for |:TPluginScan|. A set of identifiers determining the information being collected: c ... commands f ... functions p ... maps t ... filetypes h ... helptags if not available a ... autoload m ... parse vim-addon-manager metadata _ ... include _tplugin.vim files all ... all of the above *g:tplugin#shallow_scan* g:tplugin#shallow_scan (default: 'hm') *tplugin#ScanRoots()* tplugin#ScanRoots(immediate, roots, shallow_roots, args) Write autoload information for each root directory to "ROOT/_tplugin.vim". Search in autoload/tplugin/autoload/*.vim for prefabricated autoload definitions. The file's basenames are repo names. ======================================================================== autoload/tplugin/vcsdo.vim~ *g:tplugin#vcsdo#script* g:tplugin#vcsdo#script (default: '') The filename of the vcsdo executable. *g:tplugin#vcsdo#log_buffer* g:tplugin#vcsdo#log_buffer (default: '__TPluginUpdateLog__') Name of the log buffer. If empty, print log lines as messages. *g:tplugin#vcsdo#exclude_roots_rx* g:tplugin#vcsdo#exclude_roots_rx (default: '') Don't update root directories matching this |regexp|. vim:tw=78:fo=tcq2:isk=!-~,^*,^|,^":ts=8:ft=help:norl: macros/tplugin.vim [[[1 1011 " tplugin.vim " @Author: Tom Link (mailto:micathom AT gmail com?subject=[vim]) " @Website: http://www.vim.org/account/profile.php?user_id=4037 " @GIT: http://github.com/tomtom/tplugin_vim/ " @License: GPL (see http://www.gnu.org/licenses/gpl.txt) " @Created: 2010-01-04. " @Last Change: 2011-12-25. " @Revision: 1937 " GetLatestVimScripts: 2917 1 :AutoInstall: tplugin.vim if &cp || exists("loaded_tplugin") finish endif let loaded_tplugin = 14 let s:save_cpo = &cpo set cpo&vim if !exists('g:tplugin_autoload') " Enable autoloading. See |:TPluginScan|, |:TPluginCommand|, and " |:TPluginFunction|. " Values: " 1 ... Enable autoload (default) " 2 ... Enable autoload and automatically run |:TPluginScan| " after updating tplugin. let g:tplugin_autoload = 1 "{{{2 endif if !exists('g:tplugin_menu_prefix') " If autoload is enabled and this variable is non-empty, build a " menu with available plugins. " Menus are disabled by default because they are less useful " than one might think with autoload enabled. " A good choice for this variable would be, e.g., " 'Plugin.T&Plugin.'. " NOTE: You have to re-run |:TPluginScan| after setting this " value. let g:tplugin_menu_prefix = '' "{{{2 " let g:tplugin_menu_prefix = 'Plugin.T&Plugin.' "{{{2 endif if !exists('g:tplugin_file') " The prefix for tplugin control files. let g:tplugin_file = '_tplugin' "{{{2 endif if !exists('g:tplugin_load_plugin') " A list of pairs [REGEXP, VALUE] that determine how tplugin handles " autoload function calls and filetype plugins. " " When an autoload function or filetype plugin is loaded, the " respective plugin is added to 'runtimepath'. This variable decides " whether the corresponding plugin should be loaded too. Possible " values are: " " . :: Don't load any plugins " * :: Load all plugins (default if no REGEXP pattern matches the " full repo directory name) let g:tplugin_load_plugin = [] "{{{2 endif " :display: :TPlugin[!] REPOSITORY [PLUGINS ...] " Register certain plugins for being sourced at |VimEnter| time. " See |tplugin.txt| for details. " " With the optional '!', the plugin will be loaded immediately. " In interactive use, i.e. once vim was loaded, plugins will be loaded " immediately anyway. " IF REPOSITORY contains a slash or a backslash, it is considered the " path relative from the current root directory to the plugin directory. " This allows you to deal with repositories with a non-standard " directory layout. Otherwise it is assumed that the source files are " located in the "plugin" subdirectory. " " IF PLUGIN is "-", the REPOSITORY will be enabled but no plugin will be " loaded. command! -bang -nargs=+ -complete=customlist,s:TPluginComplete TPlugin \ call TPluginRequire(!empty(""), '', ) " :display: :TPluginRoot[!] DIRECTORY " Define the root directory for the following |:TPlugin| commands. " Read autoload information if available (see |g:tplugin_autoload| and " |:TPluginScan|). " " With the optional , don't register commands, functions etc. when " scanning the root with |:TPluginScan|. " " If DIRECTORY ends with "*", it doesn't refer to a directory hierarchy " à la vimfiles but to a single "flat" directory. " " If tplugin was installed a directory called .vim or vimfiles, the " default root directory is the "bundle" subdirectory of the first " element in 'runtimepath'. Otherwise, the default root directory is the " directory where tplugin_vim was installed in, i.e. this assumes that " tplugin was loaded from ROOT/tplugin_vim/macros/tplugin.vim " " Example: > " " A collection of git repositories " TPluginRoot ~/src/git_repos " " A directory with experimental plugins " TPluginRoot ~/vimfiles/experimental_plugins/* command! -bang -nargs=+ -complete=dir TPluginRoot \ call s:SetRoot(, !empty("")) " :display: :TPluginScan[!] [WHAT] [ROOT] " Scan the current root directory for commands and functions. Save " autoload information in "ROOT/_tplugin.vim". " " Where WHAT is a set of letters determining the information being " collected. See |g:tplugin#scan| for details. " " With the optional '!', the autocommands are immediatly usable. " " Other than the AsNeeded plugin, tplugin doesn't support the creation " of autoload information for maps. " " If you collect repositories in one than more directory, I'd suggest to " create a special script. " " The source file may contain special markers that make :TPluginScan " include text in the _tplugin.vim file: " *@TPluginInclude* " Blocks of non-empty lines are introduced with an @TPluginInclude tag: > " " " @TPluginInclude " augroup Foo " autocmd! " autocmd Filetype foo call foo#Init() " augroup END " " Special lines are prefixed with @TPluginInclude: > " " " @TPluginInclude if !exists('g:foo') | let g:foo = 1 | endif " " Example: > " TPluginRoot dir1 " TPluginScan " TPluginRoot dir2 " TPluginScan command! -bang -nargs=* TPluginScan \ call tplugin#ScanRoots(!empty(""), s:roots, s:shallow_roots, []) " :display: :TPluginBefore FILE_RX COMMAND " |:execute| COMMAND after loading a file matching the |regexp| pattern " FILE_RX. The COMMAND is executed after the repo's path is added to the " 'runtimepath'. " " This command should be best put into ROOT/tplugin_REPO.vim files, " which are loaded when enabling a source repository. " " Example: > " " Load master.vim before loading any plugin in a repo " TPluginBefore plugin/.\{-}\.vim runtime! macros/master.vim " " It can also be included in the comments of source files (you have " to prepend it with a "@"): > " "@TPluginBefore my_repo/autoload DoThis " let loaded_yup = 1 command! -nargs=+ TPluginBefore \ call s:AddHook(s:before, [][0], join([][1:-1])) " :display: :TPluginAfter FILE_RX COMMAND " |:execute| COMMAND after loading a file matching the |regexp| pattern " FILE_RX. " See also |:TPluginBefore|. command! -nargs=+ TPluginAfter \ call s:AddHook(s:after, [][0], join([][1:-1])) " :display: TPluginUpdate[!] " Update all repos (VCS types only). " Requires compiled-in ruby support and http://github.com/tomtom/vcsdo " to be installed. You also have to set |g:tplugin#vcsdo#script|. " " With the optional !, show which commands would be issued but don't do " anything. command! -bang TPluginUpdate call tplugin#vcsdo#Update(!empty(''), s:roots) let &rtp .= ','. escape(expand(':p:h:h'), ',') let s:roots = [] let s:shallow_roots = [] let s:rtp = split(&rtp, ',') let s:reg = {} let s:repos = {} let s:plugins = {} let s:done = {'-': {}} let s:before = {} let s:after = {} let s:dependencies = {} let s:ftypes = {} let s:functions = {} let s:autoloads = {} let s:maps = {} let s:command_nobang = {} " :nodoc: function! TPluginFileJoin(...) "{{{3 let parts = map(copy(a:000), 'substitute(v:val, ''[\/]\+$'', "", "")') return join(parts, '/') endf if exists('*fnameescape') " :nodoc: function! TPluginFnameEscape(filename) "{{{3 return fnameescape(a:filename) endf else " :nodoc: function! TPluginFnameEscape(filename) "{{{3 let cs = " \t\n*?[{`$\\%#'\"|!<" return escape(a:filename, cs) endf endif " :nodoc: function! TPluginStrip(string) "{{{3 let string = substitute(a:string, '^\s\+', '', '') let string = substitute(string, '\s\+$', '', '') return string endf function! s:CommandKey(pluginfile) "{{{3 return substitute(a:pluginfile, '\\', '/', 'g') endf function! s:DefineCommand(def1) "{{{3 let [cmd0; file] = a:def1 let string = TPluginStrip(cmd0) if match(string, '\s') == -1 return 'command! -bang -range -nargs=* '. string else " let cmd = matchstr(a:string, '\s\zs\u\w*$') if string =~ '^com\%[mand]\zs\s' let pluginfile = s:GetPluginFile(s:GetRoot(), file[0], file[1]) let pluginkey = s:CommandKey(pluginfile) if !has_key(s:command_nobang, pluginkey) let s:command_nobang[pluginkey] = {} endif let cmd = s:ExtractCommand(cmd0) if !has_key(s:command_nobang[pluginkey], cmd) let s:command_nobang[pluginkey][cmd] = 1 endif let string = substitute(string, '^com\%[mand]\zs\s', '! ', '') endif return string endif endf function! s:ExtractCommand(cmd0) "{{{3 return matchstr(a:cmd0, '\s\zs\u\w*$') endf " args: A string if type == 1, a list if type == 2 function! s:Autoload(type, def, bang, range, args) "{{{3 let [root, cmd0; file] = a:def let cmd0 = TPluginStrip(cmd0) if match(cmd0, '\s') != -1 let cmd = s:ExtractCommand(cmd0) else let cmd = cmd0 endif if a:type == 1 " Command let pluginfile = s:GetPluginFile(root, file[0], file[1]) call s:RemoveAutoloads(pluginfile, [cmd]) endif " echom "DBG s:Autoload" string(file) if len(file) >= 1 && len(file) <= 2 call call('TPluginRequire', [1, root] + file) else echoerr 'Malformed autocommand definition: '. join(a:def) endif if a:type == 1 " Command let range = join(filter(copy(a:range), '!empty(v:val)'), ',') try exec range . cmd . a:bang .' '. a:args catch /^Vim\%((\a\+)\)\=:E481/ exec cmd . a:bang .' '. a:args catch echohl Error echom v:errmsg echohl NONE endtry elseif a:type == 2 " Function elseif a:type == 3 " Map else echoerr 'Unsupported type: '. a:type endif endf " :nodoc: function! TPluginFiletype(filetype, repos) "{{{3 if !has_key(s:ftypes, a:filetype) let s:ftypes[a:filetype] = [] endif let rootrepos = map(copy(a:repos), 's:GetRoot() ."/". v:val') call extend(s:ftypes[a:filetype], rootrepos) endf function! s:LoadFiletype(filetype) "{{{3 let rootrepos = remove(s:ftypes, a:filetype) for rootrepo in rootrepos call TPluginRequire(1, rootrepo, '.', s:GetPluginPattern(rootrepo)) endfor exec 'setfiletype '. a:filetype endf function! s:AutoloadFunction(fn) "{{{3 " echom "DBG AutoloadFunction" a:fn has_key(s:functions, a:fn) if stridx(a:fn, '#') != -1 let prefix = substitute(a:fn, '#[^#]\{-}$', '', '') " echom "DBG AutoloadFunction prefix" prefix has_key(s:autoloads, prefix) if has_key(s:autoloads, prefix) let def = remove(s:autoloads, prefix) let root = def[0] let repo = def[1] let [root, rootrepo, plugindir] = s:GetRootPluginDir(root, repo) call TPluginRequire(1, root, repo, s:GetPluginPattern(rootrepo)) call s:RunHooks(s:before, rootrepo, rootrepo .'/autoload/') let autoload_file = 'autoload/'. substitute(prefix, '#', '/', 'g') .'.vim' " echom "DBG AutoloadFunction autoload_file" rootrepo autoload_file exec printf('autocmd TPlugin SourceCmd */%s call s:SourceAutoloadFunction(%s, %s)', \ escape(autoload_file, '\ '), string(rootrepo), string(autoload_file)) endif endif if has_key(s:functions, a:fn) let def = s:functions[a:fn] call s:Autoload(2, def, '', [], []) endif endf function! s:GetPluginPattern(rootrepo) "{{{3 " TLogVAR a:rootrepo for [rx, val] in g:tplugin_load_plugin if a:rootrepo =~ rx return val endif endfor return '*' endf function! s:SourceAutoloadFunction(rootrepo, autoload_file) "{{{3 let afile = expand('') " echom "DBG SourceAutoloadFunction" afile let afile = TPluginGetCanonicalFilename(strpart(afile, len(afile) - len(a:autoload_file))) if afile == a:autoload_file let autoload_file_e = TPluginFnameEscape(a:autoload_file) exec printf('autocmd! TPlugin SourceCmd %s', escape(a:autoload_file, '\ ')) exec 'runtime! '. autoload_file_e exec 'runtime! after/'. autoload_file_e call s:RunHooks(s:after, a:rootrepo, a:rootrepo .'/autoload/') endif endf " :display: TPluginMap(map, repo, plugin, ?remap="") " MAP is a map command and the map. REPO and PLUGIN are the same as for " the |:TPlugin| command. " " Examples: > " " Map for Foo: " call TPluginMap('map Foo', 'mylib', 'myplugin') " " " Load the plugin when pressing and remap the key to an appropriate " " command from the autoloaded plugin: " call TPluginMap('map ', 'mylib', 'myplugin', ':Foo') function! TPluginMap(map, repo, plugin, ...) "{{{3 if g:tplugin_autoload let remap = a:0 >= 1 ? a:1 : '' if has_key(s:plugins, a:plugin) let repo = s:plugins[a:plugin] if repo == a:repo let root = s:repos[repo] else let root = s:GetRoot() endif else let root = s:GetRoot() endif let def = [root, a:repo, a:plugin] let keys = s:MapKeys(a:map) if empty(keys) let keys = matchstr(a:map, '\S\+$') endif if !empty(keys) let pluginfile = s:GetPluginFile(s:GetRoot(), a:repo, a:plugin) if !has_key(s:maps, pluginfile) let s:maps[pluginfile] = {} endif let s:maps[pluginfile][keys] = a:map let mode = s:MapMode(a:map) try let maparg = maparg(keys, mode) catch let maparg = "" endtry if empty(maparg) let map = substitute(a:map, '