@@ -164,6 +164,22 @@ func s:feedkeys(timer)
164164 call feedkeys (' x' , ' nt' )
165165endfunc
166166
167+ " Get the command to run Vim, with -u NONE and --not-a-term arguments.
168+ " Returns an empty string on error.
169+ func GetVimCommand ()
170+ if ! filereadable (' vimcmd' )
171+ return ' '
172+ endif
173+ let cmd = readfile (' vimcmd' )[0 ]
174+ let cmd = substitute (cmd, ' -u \f\+' , ' -u NONE' , ' ' )
175+ if cmd !~ ' -u NONE'
176+ let cmd = cmd . ' -u NONE'
177+ endif
178+ let cmd .= ' --not-a-term'
179+ let cmd = substitute (cmd, ' VIMRUNTIME=.*VIMRUNTIME;' , ' ' , ' ' )
180+ return cmd
181+ endfunc
182+
167183" Run Vim, using the "vimcmd" file and "-u NORC".
168184" "before" is a list of Vim commands to be executed before loading plugins.
169185" "after" is a list of Vim commands to be executed after loading plugins.
@@ -174,7 +190,8 @@ func RunVim(before, after, arguments)
174190endfunc
175191
176192func RunVimPiped (before, after, arguments, pipecmd)
177- if ! filereadable (' vimcmd' )
193+ let cmd = GetVimCommand ()
194+ if cmd == ' '
178195 return 0
179196 endif
180197 let args = ' '
@@ -187,18 +204,6 @@ func RunVimPiped(before, after, arguments, pipecmd)
187204 let args .= ' -S Xafter.vim'
188205 endif
189206
190- let cmd = readfile (' vimcmd' )[0 ]
191- let cmd = substitute (cmd, ' -u \f\+' , ' -u NONE' , ' ' )
192- if cmd !~ ' -u NONE'
193- let cmd = cmd . ' -u NONE'
194- endif
195- let cmd .= ' --not-a-term'
196-
197- " With pipecmd we can't set VIMRUNTIME.
198- if a: pipecmd != ' '
199- let cmd = substitute (cmd, ' VIMRUNTIME=.*VIMRUNTIME;' , ' ' , ' ' )
200- endif
201-
202207 exe " silent !" . a: pipecmd . cmd . args . ' ' . a: arguments
203208
204209 if len (a: before ) > 0
0 commit comments