Do not trigger filetypeindent/filetypeplugin autocmds by default

This is not necessary if `filetype plugin indent on` was not used before
`plug#end()`, since then the `FileType` autocmds from there will come
after vim-plug's.

This will issue a warning, and makes handling of this conditional.

This could use `filetype plugin/indent off` to work around this (similar
to the `filetype off` being used), but `runtime/indoff.vim` and
`runtime/ftplugof.vim` will only empty the augroups, and not remove
them.

Fixing the user's config is the best solution anyway, so I think a
warning is good.
This commit is contained in:
Daniel Hahler 2017-10-11 22:25:21 +02:00
parent e6a775e0df
commit bd33a4337d

View File

@ -109,6 +109,8 @@ let s:TYPE = {
\ }
let s:loaded = get(s:, 'loaded', {})
let s:triggers = get(s:, 'triggers', {})
let s:need_filetypeplugin_au = 0
let s:need_filetypeindent_au = 0
function! plug#begin(...)
if a:0 > 0
@ -209,6 +211,21 @@ function! plug#end()
if exists('g:did_load_filetypes')
filetype off
endif
let warn = []
if exists('g:did_load_ftplugin')
let warn += ['plugin']
let s:need_filetypeindent_au = 1
endif
if exists('g:did_indent_on')
let warn += ['indent']
let s:need_filetypeplugin_au = 1
endif
if !empty(warn)
redraw
call s:warn('echom', printf('[vim-plug] "filetype %s on" should not be used manually with vim-plug, please remove it from your vimrc.', join(warn)))
endif
for name in g:plugs_order
if !has_key(g:plugs, name)
continue
@ -502,8 +519,17 @@ function! s:lod_ft(pat, names)
let syn = 'syntax/'.a:pat.'.vim'
call s:lod(a:names, ['plugin', 'after/plugin'], syn, 'after/'.syn)
execute 'autocmd! PlugLOD FileType' a:pat
" Executing this is only necessary if "filetype plugin indent on" was used
" before plug#end, and can be skipped when Vim has not entered always.
if v:vim_did_enter
if s:need_filetypeplugin_au
call s:doautocmd('filetypeplugin', 'FileType')
endif
if s:need_filetypeindent_au
call s:doautocmd('filetypeindent', 'FileType')
endif
endif
endfunction
function! s:lod_cmd(cmd, bang, l1, l2, args, names)