PlugSnapshot output in Vim script format (#360)

- The output file is no longer executable but a source-able vim script
- PlugSnapshot FILENAME to prompt the user if the file already exists
- Add PlugSnapshot! FILENAME variant to force overwrite existing file
- Apply -complete=file option to PlugSnapshot command
This commit is contained in:
Junegunn Choi
2015-12-16 00:36:37 +09:00
parent 52d7da3925
commit 0cfa683cd0
3 changed files with 52 additions and 46 deletions

View File

@@ -1140,17 +1140,22 @@ Execute (PlugSnapshot / #154 issues with paths containing spaces):
PlugInstall
call plug#load('vim-easy-align') " Should properly handle paths with spaces
PlugSnapshot
AssertEqual '#!/bin/sh', getline(1)
AssertEqual '# Generated by vim-plug', getline(2)
AssertEqual 'vim -c ''let g:plug_shallow = 0 | PlugUpdate | qa''', getline(5)
AssertEqual 'PLUG_HOME=$TMPDIR/plug\ with\ spaces', getline(7)
AssertEqual 0, stridx(getline(9), 'cd $PLUG_HOME/seoul256.vim/ && git reset --hard')
AssertEqual 0, stridx(getline(10), 'cd $PLUG_HOME/vim-easy-align/ && git reset --hard')
AssertEqual 'sh', &filetype
AssertEqual '" Generated by vim-plug', getline(1)
AssertEqual 0, stridx(getline(6), "silent! let g:plugs['seoul256.vim'].commit = '")
AssertEqual 0, stridx(getline(7), "silent! let g:plugs['vim-easy-align'].commit = '")
AssertEqual 'vim', &filetype
execute 'PlugSnapshot' g:plug_home.'/snapshot.sh'
AssertEqual 'sh', &filetype
AssertEqual 'snapshot.sh', fnamemodify(expand('%'), ':t')
call delete(g:plug_home.'/snapshot.vim')
execute 'PlugSnapshot' escape(g:plug_home.'/snapshot.vim', ' ')
AssertEqual 'vim', &filetype
AssertEqual 'snapshot.vim', fnamemodify(expand('%'), ':t')
q
Execute(PlugSnapshot! to overwrite existing file):
call writefile(['foobar'], g:plug_home.'/snapshot.vim')
AssertEqual 'foobar', readfile(g:plug_home.'/snapshot.vim')[0]
execute 'PlugSnapshot!' escape(g:plug_home.'/snapshot.vim', ' ')
AssertEqual '" Generated by vim-plug', readfile(g:plug_home.'/snapshot.vim')[0]
q
**********************************************************************
@@ -1241,7 +1246,8 @@ Execute (Commit hash support):
" Nor in PlugSnapshot output
PlugSnapshot
AssertEqual 9, line('$')
Log getline(1, '$')
AssertEqual 8, line('$')
q
Execute (Commit hash support - cleared):