mirror of
https://github.com/junegunn/vim-plug.git
synced 2024-12-19 10:35:38 -07:00
parent
a8b09617f9
commit
7c7ef8cf2f
22
plug.vim
22
plug.vim
@ -397,7 +397,9 @@ function! s:reorg_rtp()
|
|||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:doautocmd(...)
|
function! s:doautocmd(...)
|
||||||
execute 'doautocmd' ((v:version > 703 || has('patch442')) ? '<nomodeline>' : '') join(a:000)
|
if exists('#'.join(a:000, '#'))
|
||||||
|
execute 'doautocmd' ((v:version > 703 || has('patch442')) ? '<nomodeline>' : '') join(a:000)
|
||||||
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! plug#load(...)
|
function! plug#load(...)
|
||||||
@ -415,9 +417,7 @@ function! plug#load(...)
|
|||||||
for name in a:000
|
for name in a:000
|
||||||
call s:lod([name], ['ftdetect', 'after/ftdetect', 'plugin', 'after/plugin'])
|
call s:lod([name], ['ftdetect', 'after/ftdetect', 'plugin', 'after/plugin'])
|
||||||
endfor
|
endfor
|
||||||
if exists('#BufRead')
|
call s:doautocmd('BufRead')
|
||||||
doautocmd BufRead
|
|
||||||
endif
|
|
||||||
return 1
|
return 1
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
@ -453,9 +453,7 @@ function! s:lod(names, types, ...)
|
|||||||
endif
|
endif
|
||||||
call s:source(rtp, a:2)
|
call s:source(rtp, a:2)
|
||||||
endif
|
endif
|
||||||
if exists('#User#'.name)
|
call s:doautocmd('User', name)
|
||||||
call s:doautocmd('User', name)
|
|
||||||
endif
|
|
||||||
endfor
|
endfor
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
@ -463,21 +461,19 @@ function! s:lod_ft(pat, names)
|
|||||||
let syn = 'syntax/'.a:pat.'.vim'
|
let syn = 'syntax/'.a:pat.'.vim'
|
||||||
call s:lod(a:names, ['plugin', 'after/plugin'], syn, 'after/'.syn)
|
call s:lod(a:names, ['plugin', 'after/plugin'], syn, 'after/'.syn)
|
||||||
execute 'autocmd! PlugLOD FileType' a:pat
|
execute 'autocmd! PlugLOD FileType' a:pat
|
||||||
if exists('#filetypeplugin#FileType')
|
call s:doautocmd('filetypeplugin', 'FileType')
|
||||||
doautocmd filetypeplugin FileType
|
call s:doautocmd('filetypeindent', 'FileType')
|
||||||
endif
|
|
||||||
if exists('#filetypeindent#FileType')
|
|
||||||
doautocmd filetypeindent FileType
|
|
||||||
endif
|
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:lod_cmd(cmd, bang, l1, l2, args, names)
|
function! s:lod_cmd(cmd, bang, l1, l2, args, names)
|
||||||
call s:lod(a:names, ['ftdetect', 'after/ftdetect', 'plugin', 'after/plugin'])
|
call s:lod(a:names, ['ftdetect', 'after/ftdetect', 'plugin', 'after/plugin'])
|
||||||
|
call s:doautocmd('BufRead')
|
||||||
execute printf('%s%s%s %s', (a:l1 == a:l2 ? '' : (a:l1.','.a:l2)), a:cmd, a:bang, a:args)
|
execute printf('%s%s%s %s', (a:l1 == a:l2 ? '' : (a:l1.','.a:l2)), a:cmd, a:bang, a:args)
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:lod_map(map, names, prefix)
|
function! s:lod_map(map, names, prefix)
|
||||||
call s:lod(a:names, ['ftdetect', 'after/ftdetect', 'plugin', 'after/plugin'])
|
call s:lod(a:names, ['ftdetect', 'after/ftdetect', 'plugin', 'after/plugin'])
|
||||||
|
call s:doautocmd('BufRead')
|
||||||
let extra = ''
|
let extra = ''
|
||||||
while 1
|
while 1
|
||||||
let c = getchar(0)
|
let c = getchar(0)
|
||||||
|
@ -7,13 +7,13 @@ Execute (#112 On-demand loading should not suppress messages from ftplugin):
|
|||||||
redir => out
|
redir => out
|
||||||
tabnew a.c
|
tabnew a.c
|
||||||
redir END
|
redir END
|
||||||
Assert stridx(out, 'ftplugin') >= 0
|
Assert stridx(out, 'ftplugin-c') >= 0
|
||||||
|
|
||||||
* The same applies to plug#load())
|
* The same applies to plug#load())
|
||||||
redir => out
|
redir => out
|
||||||
call plug#load('ftplugin-msg')
|
call plug#load('ftplugin-msg')
|
||||||
redir END
|
redir END
|
||||||
Assert stridx(out, 'ftplugin') >= 0
|
Assert stridx(out, 'ftplugin-c') >= 0
|
||||||
q
|
q
|
||||||
|
|
||||||
|
|
||||||
@ -302,3 +302,16 @@ Execute (#474: Load ftdetect files in filetypedetect augroup):
|
|||||||
AssertEqual 'rust', &filetype
|
AssertEqual 'rust', &filetype
|
||||||
Log &filetype
|
Log &filetype
|
||||||
bd
|
bd
|
||||||
|
|
||||||
|
**********************************************************************
|
||||||
|
Execute (#489 On-demand loading with 'on' option should trigger BufRead autocmd):
|
||||||
|
call plug#begin('$PLUG_FIXTURES')
|
||||||
|
Plug 'ftplugin-msg', { 'on': 'XXX' }
|
||||||
|
call plug#end()
|
||||||
|
|
||||||
|
tabnew a.java
|
||||||
|
redir => out
|
||||||
|
silent! XXX
|
||||||
|
redir END
|
||||||
|
Assert stridx(out, 'ftplugin-java') >= 0
|
||||||
|
q
|
||||||
|
4
test/run
4
test/run
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
cd $(dirname "${BASH_SOURCE[0]}")
|
cd $(dirname "${BASH_SOURCE[0]}")
|
||||||
|
|
||||||
|
export HOME=/tmp
|
||||||
export BASE="$PWD"
|
export BASE="$PWD"
|
||||||
export PLUG_SRC="$PWD/../plug.vim"
|
export PLUG_SRC="$PWD/../plug.vim"
|
||||||
export PLUG_FIXTURES="$PWD/fixtures"
|
export PLUG_FIXTURES="$PWD/fixtures"
|
||||||
@ -77,7 +78,8 @@ DOC
|
|||||||
|
|
||||||
rm -rf "$PLUG_FIXTURES/ftplugin-msg"
|
rm -rf "$PLUG_FIXTURES/ftplugin-msg"
|
||||||
mkdir -p "$PLUG_FIXTURES/ftplugin-msg/ftplugin"
|
mkdir -p "$PLUG_FIXTURES/ftplugin-msg/ftplugin"
|
||||||
echo "echomsg 'ftplugin'" > "$PLUG_FIXTURES/ftplugin-msg/ftplugin/c.vim"
|
echo "echomsg 'ftplugin-c'" > "$PLUG_FIXTURES/ftplugin-msg/ftplugin/c.vim"
|
||||||
|
echo "echomsg 'ftplugin-java'" > "$PLUG_FIXTURES/ftplugin-msg/ftplugin/java.vim"
|
||||||
|
|
||||||
rm -rf /tmp/new-branch
|
rm -rf /tmp/new-branch
|
||||||
cd /tmp
|
cd /tmp
|
||||||
|
Loading…
Reference in New Issue
Block a user