Strip trailing slash from g:plug_home
This commit is contained in:
parent
3e65d146ad
commit
23748f115f
5
plug.vim
5
plug.vim
|
@ -58,8 +58,9 @@ let s:is_win = has('win32') || has('win64')
|
||||||
let s:me = expand('<sfile>:p')
|
let s:me = expand('<sfile>:p')
|
||||||
|
|
||||||
function! plug#begin(...)
|
function! plug#begin(...)
|
||||||
let home = a:0 > 0 ? fnamemodify(a:1, ':p') :
|
let home = s:path(
|
||||||
\ get(g:, 'plug_home', split(&rtp, ',')[0].'/plugged')
|
\ a:0 > 0 ? fnamemodify(a:1, ':p') :
|
||||||
|
\ get(g:, 'plug_home', split(&rtp, ',')[0].'/plugged'))
|
||||||
if !isdirectory(home)
|
if !isdirectory(home)
|
||||||
try
|
try
|
||||||
call mkdir(home, 'p')
|
call mkdir(home, 'p')
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
Execute (initialize):
|
Execute (Initialize test environment):
|
||||||
Save '&rtp', 'g:plug_home', '$MYVIMRC'
|
Save &rtp, g:plug_home, $MYVIMRC
|
||||||
|
|
||||||
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')
|
||||||
|
@ -7,7 +7,6 @@ Execute (initialize):
|
||||||
execute 'set rtp^='.vader
|
execute 'set rtp^='.vader
|
||||||
execute 'set rtp^='.plug
|
execute 'set rtp^='.plug
|
||||||
let basertp = &rtp
|
let basertp = &rtp
|
||||||
echom &rtp
|
|
||||||
|
|
||||||
silent! unlet g:plugs
|
silent! unlet g:plugs
|
||||||
silent! unlet g:plug_home
|
silent! unlet g:plug_home
|
||||||
|
@ -20,15 +19,25 @@ Execute (initialize):
|
||||||
call writefile(['let g:vimrc_reloaded += 1'], vimrc)
|
call writefile(['let g:vimrc_reloaded += 1'], vimrc)
|
||||||
let $MYVIMRC = vimrc
|
let $MYVIMRC = vimrc
|
||||||
|
|
||||||
Execute (plug#begin()):
|
Execute (plug#begin() without path argument):
|
||||||
|
call plug#begin()
|
||||||
|
AssertEqual split(&rtp, ',')[0].'/plugged', g:plug_home
|
||||||
|
unlet g:plug_home
|
||||||
|
|
||||||
|
Execute (plug#begin(path)):
|
||||||
let temp_plugged = tempname()
|
let temp_plugged = tempname()
|
||||||
call plug#begin(temp_plugged)
|
call plug#begin(temp_plugged.'/')
|
||||||
|
Assert g:plug_home !~ '[/\\]$', 'Trailing / should be stripped from g:plug_home'
|
||||||
|
|
||||||
AssertEqual 0, len(g:plugs)
|
AssertEqual 0, len(g:plugs)
|
||||||
AssertEqual temp_plugged, g:plug_home
|
AssertEqual temp_plugged, g:plug_home
|
||||||
AssertEqual basertp, &rtp
|
AssertEqual basertp, &rtp
|
||||||
|
|
||||||
Execute (Plug command):
|
Execute (Subsequent plug#begin() calls will reuse g:plug_home):
|
||||||
|
call plug#begin()
|
||||||
|
AssertEqual temp_plugged, g:plug_home
|
||||||
|
|
||||||
|
Execute (Test Plug command):
|
||||||
" Git repo with branch
|
" Git repo with branch
|
||||||
Plug 'junegunn/seoul256.vim', 'no-t_co'
|
Plug 'junegunn/seoul256.vim', 'no-t_co'
|
||||||
AssertEqual 'https://git:@github.com/junegunn/seoul256.vim.git', g:plugs['seoul256.vim'].uri
|
AssertEqual 'https://git:@github.com/junegunn/seoul256.vim.git', g:plugs['seoul256.vim'].uri
|
||||||
|
@ -119,6 +128,8 @@ Expect:
|
||||||
Execute (PlugClean! to remove seoul256.vim):
|
Execute (PlugClean! to remove seoul256.vim):
|
||||||
PlugClean!
|
PlugClean!
|
||||||
AssertEqual 1, len(filter(getline(1, line('$')), 'v:val =~ "Removed"'))
|
AssertEqual 1, len(filter(getline(1, line('$')), 'v:val =~ "Removed"'))
|
||||||
|
Assert empty(globpath(&rtp, 'colors/seoul256.vim'))
|
||||||
|
Assert !empty(globpath(&rtp, 'autoload/emoji.vim'))
|
||||||
q
|
q
|
||||||
|
|
||||||
Execute (Change GIT URI of vim-emoji):
|
Execute (Change GIT URI of vim-emoji):
|
||||||
|
@ -143,12 +154,16 @@ Expect:
|
||||||
Execute (PlugClean! to remove vim-emoji):
|
Execute (PlugClean! to remove vim-emoji):
|
||||||
PlugClean!
|
PlugClean!
|
||||||
AssertEqual 1, len(filter(getline(1, line('$')), 'v:val =~ "Removed"'))
|
AssertEqual 1, len(filter(getline(1, line('$')), 'v:val =~ "Removed"'))
|
||||||
|
Assert empty(globpath(&rtp, 'colors/seoul256.vim'))
|
||||||
|
Assert empty(globpath(&rtp, 'autoload/emoji.vim'))
|
||||||
q
|
q
|
||||||
|
|
||||||
Execute (PlugUpdate to install both again):
|
Execute (PlugUpdate to install both again):
|
||||||
PlugUpdate
|
PlugUpdate
|
||||||
AssertEqual 2, len(filter(getline(1, line('$')), 'v:val =~ "Cloning into"'))
|
AssertEqual 2, len(filter(getline(1, line('$')), 'v:val =~ "Cloning into"'))
|
||||||
AssertEqual 2, g:vimrc_reloaded
|
AssertEqual 2, g:vimrc_reloaded
|
||||||
|
Assert !empty(globpath(&rtp, 'colors/seoul256.vim')), 'seoul256.vim should be found'
|
||||||
|
Assert !empty(globpath(&rtp, 'autoload/emoji.vim')), 'vim-emoji should be found'
|
||||||
q
|
q
|
||||||
|
|
||||||
Execute (PlugUpdate only to find out plugins are up-to-date):
|
Execute (PlugUpdate only to find out plugins are up-to-date):
|
||||||
|
@ -157,13 +172,13 @@ Execute (PlugUpdate only to find out plugins are up-to-date):
|
||||||
AssertEqual 3, g:vimrc_reloaded
|
AssertEqual 3, g:vimrc_reloaded
|
||||||
q
|
q
|
||||||
|
|
||||||
Execute (Rollback):
|
Execute (Cleanup):
|
||||||
call system('rm -rf '.temp_plugged)
|
call system('rm -rf '.temp_plugged)
|
||||||
|
|
||||||
unlet g:plugs
|
unlet g:plugs
|
||||||
unlet g:plug_home
|
unlet g:plug_home
|
||||||
unlet temp_plugged
|
|
||||||
unlet g:vimrc_reloaded
|
unlet g:vimrc_reloaded
|
||||||
|
unlet temp_plugged vader plug basertp
|
||||||
|
|
||||||
Restore
|
Restore
|
||||||
source $MYVIMRC
|
source $MYVIMRC
|
||||||
|
|
Loading…
Reference in New Issue
Block a user