Ensure ftplugin files are loaded (#24)
This commit is contained in:
parent
8cf5fca9ca
commit
6ddee62977
1 changed files with 20 additions and 11 deletions
31
plug.vim
31
plug.vim
|
@ -58,7 +58,6 @@ set cpo&vim
|
||||||
let s:plug_source = 'https://raw.github.com/junegunn/vim-plug/master/plug.vim'
|
let s:plug_source = 'https://raw.github.com/junegunn/vim-plug/master/plug.vim'
|
||||||
let s:plug_file = 'Plugfile'
|
let s:plug_file = 'Plugfile'
|
||||||
let s:plug_buf = -1
|
let s:plug_buf = -1
|
||||||
let s:loaded = {}
|
|
||||||
let s:is_win = has('win32') || has('win64')
|
let s:is_win = has('win32') || has('win64')
|
||||||
let s:me = expand('<sfile>:p')
|
let s:me = expand('<sfile>:p')
|
||||||
|
|
||||||
|
@ -123,6 +122,7 @@ function! plug#end()
|
||||||
augroup END
|
augroup END
|
||||||
augroup! PlugLOD
|
augroup! PlugLOD
|
||||||
endif
|
endif
|
||||||
|
let lod = {}
|
||||||
|
|
||||||
filetype off
|
filetype off
|
||||||
" we want to make sure the plugin directories are added to rtp in the same
|
" we want to make sure the plugin directories are added to rtp in the same
|
||||||
|
@ -159,12 +159,21 @@ function! plug#end()
|
||||||
for vim in split(globpath(s:rtp(plug), 'ftdetect/**/*.vim'), '\n')
|
for vim in split(globpath(s:rtp(plug), 'ftdetect/**/*.vim'), '\n')
|
||||||
execute 'source '.vim
|
execute 'source '.vim
|
||||||
endfor
|
endfor
|
||||||
augroup PlugLOD
|
for key in s:to_a(plug.for)
|
||||||
execute printf('autocmd FileType %s call <SID>lod_ft(%s, %s)',
|
if !has_key(lod, key)
|
||||||
\ join(s:to_a(plug.for), ','), string(name), string(plug))
|
let lod[key] = []
|
||||||
augroup END
|
endif
|
||||||
|
call add(lod[key], name)
|
||||||
|
endfor
|
||||||
endif
|
endif
|
||||||
endfor
|
endfor
|
||||||
|
|
||||||
|
for [key, names] in items(lod)
|
||||||
|
augroup PlugLOD
|
||||||
|
execute printf('autocmd FileType %s call <SID>lod_ft(%s, %s)',
|
||||||
|
\ key, string(key), string(reverse(names)))
|
||||||
|
augroup END
|
||||||
|
endfor
|
||||||
filetype plugin indent on
|
filetype plugin indent on
|
||||||
syntax on
|
syntax on
|
||||||
endfunction
|
endfunction
|
||||||
|
@ -198,12 +207,12 @@ function! s:lod(plug, types)
|
||||||
endfor
|
endfor
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:lod_ft(name, plug)
|
function! s:lod_ft(pat, names)
|
||||||
if has_key(s:loaded, a:name)
|
for name in a:names
|
||||||
return
|
call s:lod(g:plugs[name], ['plugin', 'after'])
|
||||||
endif
|
endfor
|
||||||
call s:lod(a:plug, ['plugin', 'after'])
|
execute 'autocmd! PlugLOD FileType ' . a:pat
|
||||||
let s:loaded[a:name] = 1
|
let &l:filetype = &l:filetype
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:lod_cmd(cmd, bang, l1, l2, args, plug)
|
function! s:lod_cmd(cmd, bang, l1, l2, args, plug)
|
||||||
|
|
Loading…
Reference in a new issue