mirror of
https://github.com/junegunn/vim-plug.git
synced 2024-12-19 10:35:38 -07:00
Pin first and last path in &rtp (#34)
This commit is contained in:
parent
466d1839b3
commit
46a6e8441f
18
plug.vim
18
plug.vim
@ -175,6 +175,7 @@ function! plug#end()
|
||||
\ key, string(key), string(reverse(names)))
|
||||
augroup END
|
||||
endfor
|
||||
call s:reorg_rtp()
|
||||
filetype plugin indent on
|
||||
syntax on
|
||||
endfunction
|
||||
@ -218,6 +219,17 @@ function! s:add_rtp(rtp)
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! s:reorg_rtp()
|
||||
if !empty(s:first_rtp)
|
||||
execute 'set rtp-='.s:first_rtp
|
||||
execute 'set rtp^='.s:first_rtp
|
||||
endif
|
||||
if s:last_rtp !=# s:first_rtp
|
||||
execute 'set rtp-='.s:last_rtp
|
||||
execute 'set rtp+='.s:last_rtp
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! s:lod(plug, types)
|
||||
let rtp = s:rtp(a:plug)
|
||||
call s:add_rtp(rtp)
|
||||
@ -232,6 +244,7 @@ function! s:lod_ft(pat, names)
|
||||
for name in a:names
|
||||
call s:lod(g:plugs[name], ['plugin', 'after'])
|
||||
endfor
|
||||
call s:reorg_rtp()
|
||||
execute 'autocmd! PlugLOD FileType ' . a:pat
|
||||
silent! doautocmd filetypeplugin FileType
|
||||
endfunction
|
||||
@ -239,6 +252,7 @@ endfunction
|
||||
function! s:lod_cmd(cmd, bang, l1, l2, args, name)
|
||||
execute 'delc '.a:cmd
|
||||
call s:lod(g:plugs[a:name], ['plugin', 'ftdetect', 'after'])
|
||||
call s:reorg_rtp()
|
||||
execute printf("%s%s%s %s", (a:l1 == a:l2 ? '' : (a:l1.','.a:l2)), a:cmd, a:bang, a:args)
|
||||
endfunction
|
||||
|
||||
@ -246,6 +260,7 @@ function! s:lod_map(map, name, prefix)
|
||||
execute 'unmap '.a:map
|
||||
execute 'iunmap '.a:map
|
||||
call s:lod(g:plugs[a:name], ['plugin', 'ftdetect', 'after'])
|
||||
call s:reorg_rtp()
|
||||
let extra = ''
|
||||
while 1
|
||||
let c = getchar(0)
|
||||
@ -1029,6 +1044,9 @@ function! s:diff()
|
||||
normal! gg
|
||||
endfunction
|
||||
|
||||
let s:first_rtp = s:esc(get(split(&rtp, ','), 0, ''))
|
||||
let s:last_rtp = s:esc(get(split(&rtp, ','), -1, ''))
|
||||
|
||||
let &cpo = s:cpo_save
|
||||
unlet s:cpo_save
|
||||
|
||||
|
@ -1,6 +1,9 @@
|
||||
Execute (Initialize test environment):
|
||||
Save &rtp, g:plugs, g:plug_home, $MYVIMRC
|
||||
|
||||
let first_rtp = split(&rtp, ',')[0]
|
||||
let last_rtp = split(&rtp, ',')[-1]
|
||||
|
||||
let vader = fnamemodify(globpath(&rtp, 'autoload/vader.vim'), ':h:h')
|
||||
let plug = fnamemodify(globpath(&rtp, 'autoload/plug.vim'), ':h:h')
|
||||
set rtp=$HOME/.vim,$VIM/vimfiles,$VIMRUNTIME,$VIM/vimfiles/after,$HOME/.vim/after
|
||||
@ -120,6 +123,8 @@ Execute (PlugClean before installation):
|
||||
Execute (plug#end() updates &rtp):
|
||||
call plug#end()
|
||||
Assert len(&rtp) > len(basertp)
|
||||
AssertEqual first_rtp, split(&rtp, ',')[0]
|
||||
AssertEqual last_rtp, split(&rtp, ',')[-1]
|
||||
|
||||
Execute (Yet, plugins are not available):
|
||||
Assert empty(globpath(&rtp, 'autoload/emoji.vim'))
|
||||
@ -367,6 +372,8 @@ Execute (Partial PlugInstall):
|
||||
|
||||
Execute (Check dependent plugin):
|
||||
Assert &rtp =~ 'pseudocl', &rtp
|
||||
AssertEqual first_rtp, split(&rtp, ',')[0]
|
||||
AssertEqual last_rtp, split(&rtp, ',')[-1]
|
||||
|
||||
Given (Unaligned code):
|
||||
a=1
|
||||
@ -475,6 +482,8 @@ Execute (Check &rtp after SomeCommand):
|
||||
Assert &rtp !~ 'fzf'
|
||||
silent! SomeCommand
|
||||
Assert &rtp =~ 'fzf'
|
||||
AssertEqual first_rtp, split(&rtp, ',')[0]
|
||||
AssertEqual last_rtp, split(&rtp, ',')[-1]
|
||||
|
||||
Execute (Common parent):
|
||||
call plug#begin()
|
||||
|
Loading…
Reference in New Issue
Block a user