Permalink
Browse files

Allow {'exec': '...'} when loading plugins lazily.

If a plugin has ftdetect/* or plugin/*.vim files setting ft on
BufRead,BufNewFile the au command gets set but doesn't get executed,
beacuse such au command execution was triggering the activation.

So you can add 'set ft=..' and everything should be fine.
  • Loading branch information...
1 parent 20f75ea commit 2434225ae48e608c2b6ac86c8da1c62209da746f @MarcWeber committed May 7, 2017
Showing with 12 additions and 1 deletion.
  1. +3 −1 README.md
  2. +9 −0 autoload/vam.vim
View
@@ -120,7 +120,9 @@ Also: Of course VAM allows using subdirectories of repositories as runtimepath.
Eg See vim-pi-patching.
## lazily loading plugins / tag plugins by topic / pass dictionaries for adding arbitrary options
-You can tag plugins and load them lazily
+You can tag plugins and load them lazily. If a plugin provides a 'au
+BufRead,BufNewFile set ft..' like code fource buftype by adding a key such as
+{'exec':'set ft=tss'} for instance
```vim
let scripts = []
View
@@ -241,6 +241,9 @@ fun! vam#ActivateRecursively(list_of_scripts, ...)
endif
call add(opts.new_runtime_paths, rtp)
+ if (has_key(script_, 'exec'))
+ call add(opts.execs, script_.exec)
+ endif
if s:c.debug_activation
" activation takes place later (-> new_runtime_paths), but messages will be in order
@@ -369,10 +372,12 @@ fun! vam#ActivateAddons(...) abort
" add new_runtime_paths state if not present in opts yet
let new_runtime_paths = get(opts, 'new_runtime_paths', [])
let to_be_activated = get(opts, 'to_be_activated', {})
+ let execs = get(opts, 'execs', [])
let opts.new_runtime_paths = new_runtime_paths
let opts.to_be_activated = to_be_activated
+ let opts.execs = execs
for a in args[0]
let to_be_activated[has_key(a, 'name') ? a.name : 'rtp:'.a.activate_this_rtp] = a
@@ -447,6 +452,10 @@ fun! vam#ActivateAddons(...) abort
endfor
endfor
+ for e in execs
+ exec e
+ endfor
+
if !empty(new_runtime_paths)
" The purpose of this line is to "refresh" buffer local vars and syntax.
" (eg when loading a python plugin when opening a .py file)

0 comments on commit 2434225

Please sign in to comment.