mirror of
https://github.com/junegunn/vim-plug.git
synced 2024-12-23 20:45:31 -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)))
|
\ key, string(key), string(reverse(names)))
|
||||||
augroup END
|
augroup END
|
||||||
endfor
|
endfor
|
||||||
|
call s:reorg_rtp()
|
||||||
filetype plugin indent on
|
filetype plugin indent on
|
||||||
syntax on
|
syntax on
|
||||||
endfunction
|
endfunction
|
||||||
@ -218,6 +219,17 @@ function! s:add_rtp(rtp)
|
|||||||
endif
|
endif
|
||||||
endfunction
|
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)
|
function! s:lod(plug, types)
|
||||||
let rtp = s:rtp(a:plug)
|
let rtp = s:rtp(a:plug)
|
||||||
call s:add_rtp(rtp)
|
call s:add_rtp(rtp)
|
||||||
@ -232,6 +244,7 @@ function! s:lod_ft(pat, names)
|
|||||||
for name in a:names
|
for name in a:names
|
||||||
call s:lod(g:plugs[name], ['plugin', 'after'])
|
call s:lod(g:plugs[name], ['plugin', 'after'])
|
||||||
endfor
|
endfor
|
||||||
|
call s:reorg_rtp()
|
||||||
execute 'autocmd! PlugLOD FileType ' . a:pat
|
execute 'autocmd! PlugLOD FileType ' . a:pat
|
||||||
silent! doautocmd filetypeplugin FileType
|
silent! doautocmd filetypeplugin FileType
|
||||||
endfunction
|
endfunction
|
||||||
@ -239,6 +252,7 @@ endfunction
|
|||||||
function! s:lod_cmd(cmd, bang, l1, l2, args, name)
|
function! s:lod_cmd(cmd, bang, l1, l2, args, name)
|
||||||
execute 'delc '.a:cmd
|
execute 'delc '.a:cmd
|
||||||
call s:lod(g:plugs[a:name], ['plugin', 'ftdetect', 'after'])
|
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)
|
execute printf("%s%s%s %s", (a:l1 == a:l2 ? '' : (a:l1.','.a:l2)), a:cmd, a:bang, a:args)
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
@ -246,6 +260,7 @@ function! s:lod_map(map, name, prefix)
|
|||||||
execute 'unmap '.a:map
|
execute 'unmap '.a:map
|
||||||
execute 'iunmap '.a:map
|
execute 'iunmap '.a:map
|
||||||
call s:lod(g:plugs[a:name], ['plugin', 'ftdetect', 'after'])
|
call s:lod(g:plugs[a:name], ['plugin', 'ftdetect', 'after'])
|
||||||
|
call s:reorg_rtp()
|
||||||
let extra = ''
|
let extra = ''
|
||||||
while 1
|
while 1
|
||||||
let c = getchar(0)
|
let c = getchar(0)
|
||||||
@ -1029,6 +1044,9 @@ function! s:diff()
|
|||||||
normal! gg
|
normal! gg
|
||||||
endfunction
|
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
|
let &cpo = s:cpo_save
|
||||||
unlet s:cpo_save
|
unlet s:cpo_save
|
||||||
|
|
||||||
|
@ -1,6 +1,9 @@
|
|||||||
Execute (Initialize test environment):
|
Execute (Initialize test environment):
|
||||||
Save &rtp, g:plugs, g:plug_home, $MYVIMRC
|
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 vader = fnamemodify(globpath(&rtp, 'autoload/vader.vim'), ':h:h')
|
||||||
let plug = fnamemodify(globpath(&rtp, 'autoload/plug.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
|
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):
|
Execute (plug#end() updates &rtp):
|
||||||
call plug#end()
|
call plug#end()
|
||||||
Assert len(&rtp) > len(basertp)
|
Assert len(&rtp) > len(basertp)
|
||||||
|
AssertEqual first_rtp, split(&rtp, ',')[0]
|
||||||
|
AssertEqual last_rtp, split(&rtp, ',')[-1]
|
||||||
|
|
||||||
Execute (Yet, plugins are not available):
|
Execute (Yet, plugins are not available):
|
||||||
Assert empty(globpath(&rtp, 'autoload/emoji.vim'))
|
Assert empty(globpath(&rtp, 'autoload/emoji.vim'))
|
||||||
@ -367,6 +372,8 @@ Execute (Partial PlugInstall):
|
|||||||
|
|
||||||
Execute (Check dependent plugin):
|
Execute (Check dependent plugin):
|
||||||
Assert &rtp =~ 'pseudocl', &rtp
|
Assert &rtp =~ 'pseudocl', &rtp
|
||||||
|
AssertEqual first_rtp, split(&rtp, ',')[0]
|
||||||
|
AssertEqual last_rtp, split(&rtp, ',')[-1]
|
||||||
|
|
||||||
Given (Unaligned code):
|
Given (Unaligned code):
|
||||||
a=1
|
a=1
|
||||||
@ -475,6 +482,8 @@ Execute (Check &rtp after SomeCommand):
|
|||||||
Assert &rtp !~ 'fzf'
|
Assert &rtp !~ 'fzf'
|
||||||
silent! SomeCommand
|
silent! SomeCommand
|
||||||
Assert &rtp =~ 'fzf'
|
Assert &rtp =~ 'fzf'
|
||||||
|
AssertEqual first_rtp, split(&rtp, ',')[0]
|
||||||
|
AssertEqual last_rtp, split(&rtp, ',')[-1]
|
||||||
|
|
||||||
Execute (Common parent):
|
Execute (Common parent):
|
||||||
call plug#begin()
|
call plug#begin()
|
||||||
|
Loading…
Reference in New Issue
Block a user