PlugSnapshot to use unexpanded plug home
/cc @andreicristianpetcu plug#begin expands its path argument and converts it to the absolute path by default. However, it makes sense to use the unexpanded form in case of PlugSnapshot as described in https://github.com/junegunn/vim-plug/issues/97#issuecomment-57421483 For example, for the following cases, - call plug#begin('~/.vim/plugged') - call plug#begin('$HOME/.vim/plugged') PlugSnapshot will use the exact arguments, `~/.vim/plugged` or `$HOME/.vim/plugged`, instead of the absolute paths such as `/home/jg/.vim/plugged`.
This commit is contained in:
parent
e1e04cabd5
commit
e7704e6cb3
2 changed files with 22 additions and 2 deletions
6
plug.vim
6
plug.vim
|
@ -84,6 +84,7 @@ let s:loaded = get(s:, 'loaded', {})
|
|||
|
||||
function! plug#begin(...)
|
||||
if a:0 > 0
|
||||
let s:plug_home_org = a:1
|
||||
let home = s:path(fnamemodify(expand(a:1), ':p'))
|
||||
elseif exists('g:plug_home')
|
||||
let home = s:path(g:plug_home)
|
||||
|
@ -1273,13 +1274,14 @@ function! s:revert()
|
|||
endfunction
|
||||
|
||||
function! s:snapshot(...) abort
|
||||
let home = get(s:, 'plug_home_org', g:plug_home)
|
||||
let [type, var, header] = s:is_win ?
|
||||
\ ['dosbatch', '%PLUG_HOME%',
|
||||
\ ['@echo off', ':: Generated by vim-plug', ':: '.strftime("%c"), '',
|
||||
\ ':: Make sure to PlugUpdate first', '', 'set PLUG_HOME='.s:esc(g:plug_home)]] :
|
||||
\ ':: Make sure to PlugUpdate first', '', 'set PLUG_HOME='.s:esc(home)]] :
|
||||
\ ['sh', '$PLUG_HOME',
|
||||
\ ['#!/bin/bash', '# Generated by vim-plug', '# '.strftime("%c"), '',
|
||||
\ 'vim +PlugUpdate +qa', '', 'PLUG_HOME='.s:esc(g:plug_home)]]
|
||||
\ 'vim +PlugUpdate +qa', '', 'PLUG_HOME='.s:esc(home)]]
|
||||
|
||||
call s:prepare()
|
||||
execute 'setf' type
|
||||
|
|
|
@ -1021,7 +1021,25 @@ Execute (PlugClean should not try to remove unmanaged plugins inside g:plug_home
|
|||
AssertExpect 'Already clean', 1
|
||||
q
|
||||
|
||||
**********************************************************************
|
||||
Execute (PlugSnapshot):
|
||||
call plug#begin('$TMPDIR/plugged')
|
||||
Plug 'junegunn/vim-emoji'
|
||||
Plug 'junegunn/seoul256.vim'
|
||||
call plug#end()
|
||||
|
||||
PlugInstall
|
||||
PlugSnapshot
|
||||
AssertEqual '#!/bin/bash', getline(1)
|
||||
AssertEqual '# Generated by vim-plug', getline(2)
|
||||
AssertEqual 'vim +PlugUpdate +qa', getline(5)
|
||||
AssertEqual 'PLUG_HOME=$TMPDIR/plugged', getline(7)
|
||||
AssertEqual 0, stridx(getline(9), 'cd $PLUG_HOME/seoul256.vim/ && git reset --hard')
|
||||
AssertEqual 0, stridx(getline(10), 'cd $PLUG_HOME/vim-emoji/ && git reset --hard')
|
||||
q
|
||||
|
||||
Execute (Cleanup):
|
||||
silent! call system('rm -rf '.temp_plugged)
|
||||
silent! call system('rm -rf '.temp_plugged)
|
||||
silent! call rename('fzf', 'fzf-staged')
|
||||
silent! unlet g:plugs
|
||||
|
|
Loading…
Reference in a new issue