Skip to content
Myr

[vim] Use cmd.exe in Windows (#785)

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Jan Edmund Lazo · committed by Junegunn Choi · parent 45faad7 · Browse files · 1 file+30 added−6 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+30 added−6 removed

  • other:+30 added−6 removed

1 file+30 added−6 removed

modified:plugin/fzf.vim+30 added-6 removed
78 unmodified lines
79 return '"'.substitute(a:arg, '"', '\\"', 'g').'"'80endfunction8182function! s:escape(path)83 let escaped_chars = '$%#''"'8485 if has('unix')86 let escaped_chars .= ' \'87 endif8883 return escape(a:path, ' $%#''"\')89 return escape(a:path, escaped_chars)90endfunction9192" Upgrade legacy options93function! s:upgrade(dict)
145 unmodified lines
239240function! fzf#run(...) abort241try242 let oshell = &shell243 let useshellslash = &shellslash244245 if has('win32') || has('win64')246 set shell=cmd.exe247 set shellslash248 else237 set shell=sh249 set shell=sh250 endif251252 if has('nvim') && len(filter(range(1, bufnr('$')), 'bufname(v:val) =~# ";#FZF"'))253 call s:warn('FZF is already running!')254 return []255 endif
8 unmodified lines
264265 if !has_key(dict, 'source') && !empty($FZF_DEFAULT_COMMAND)266 let temps.source = tempname()267 call writefile(split($FZF_DEFAULT_COMMAND, "\n"), temps.source)254 let dict.source = (empty($SHELL) ? 'sh' : $SHELL) . ' ' . s:shellesc(temps.source)268 let dict.source = (empty($SHELL) ? &shell : $SHELL) . ' ' . s:shellesc(temps.source)269 endif270271 if has_key(dict, 'source')272 let source = dict.source
21 unmodified lines
294 call s:callback(dict, lines)295 return lines296finally297 let &shell = oshell298 let &shellslash = useshellslash299endtry300endfunction301302function! s:present(dict, ...)
64 unmodified lines
367 \ synIDattr(hlID("Normal"), "bg"), synIDattr(hlID("Normal"), "fg"),368 \ &columns, &lines/2, getwinposx(), getwinposy())369endfunction370unlet! s:launcher371if has('win32') || has('win64')372 let s:launcher = 'cmd.exe /C %s'373else356let s:launcher = function('s:xterm_launcher')374 let s:launcher = function('s:xterm_launcher')375endif376377function! s:exit_handler(code, command, ...)378 if a:code == 130379 return 0
8 unmodified lines
388endfunction389390function! s:execute(dict, command, temps) abort391 call s:pushd(a:dict)392 if has('unix')373 silent! !clear 2> /dev/null393 silent! !clear 2> /dev/null394 endif395 let escaped = escape(substitute(a:command, '\n', '\\n', 'g'), '%#')396 if has('gui_running')397 let Launcher = get(a:dict, 'launcher', get(g:, 'Fzf_launcher', get(g:, 'fzf_launcher', s:launcher)))398 let fmt = type(Launcher) == 2 ? call(Launcher, []) : Launcher378 let command = printf(fmt, "'".substitute(escaped, "'", "'\"'\"'", 'g')."'")399 if has('unix')400 let escaped = "'".substitute(escaped, "'", "'\"'\"'", 'g')."'"401 endif402 let command = printf(fmt, escaped)403 else404 let command = escaped405 endif406 execute 'silent !'.command
224 unmodified lines