mirror of
https://github.com/junegunn/vim-plug.git
synced 2025-12-10 02:41:50 +08:00
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:
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
|
||||
|
||||
Reference in New Issue
Block a user