diff options
| author | Jan Edmund Lazo <janlazo@users.noreply.github.com> | 2017-05-30 20:56:01 -0400 |
|---|---|---|
| committer | Junegunn Choi <junegunn.c@gmail.com> | 2017-05-31 09:56:01 +0900 |
| commit | 669a6fee40a2d946ab35561c47e76d6a2216948c (patch) | |
| tree | ad0f2388e507784988127ca47a875c6f46fc8499 /plugin/fzf.vim | |
| parent | 8aab0fc1894facf9ac51132ff8a832b18bc115ac (diff) | |
| download | fzf-669a6fee40a2d946ab35561c47e76d6a2216948c.tar.gz | |
[vim] Use utf-8 for cmd.exe (#929)
Diffstat (limited to 'plugin/fzf.vim')
| -rw-r--r-- | plugin/fzf.vim | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/plugin/fzf.vim b/plugin/fzf.vim index fbfcd1dd..81aff374 100644 --- a/plugin/fzf.vim +++ b/plugin/fzf.vim @@ -44,10 +44,22 @@ if s:is_win let &shellslash = shellslash endtry endfunction + + " Use utf-8 for fzf.vim commands + " Return array of shell commands for cmd.exe + function! s:wrap_cmds(cmds) + return ['@echo off', 'for /f "tokens=4" %%a in (''chcp'') do set origchcp=%%a', 'chcp 65001 > nul'] + + \ (type(a:cmds) == type([]) ? a:cmds : [a:cmds]) + + \ ['chcp %origchcp% > nul'] + endfunction else function! s:fzf_call(fn, ...) return call(a:fn, a:000) endfunction + + function! s:wrap_cmds(cmds) + return a:cmds + endfunction endif function! s:shellesc_cmd(arg) @@ -352,7 +364,7 @@ try if !has_key(dict, 'source') && !empty($FZF_DEFAULT_COMMAND) let temps.source = s:fzf_tempname().(s:is_win ? '.bat' : '') - call writefile((s:is_win ? ['@echo off'] : []) + split($FZF_DEFAULT_COMMAND, "\n"), temps.source) + call writefile(s:wrap_cmds(split($FZF_DEFAULT_COMMAND, "\n")), temps.source) let dict.source = (empty($SHELL) ? &shell : $SHELL) . (s:is_win ? ' /c ' : ' ') . fzf#shellescape(temps.source) endif @@ -510,7 +522,7 @@ function! s:execute(dict, command, use_height, temps) abort endif if s:is_win let batchfile = s:fzf_tempname().'.bat' - call writefile(['@echo off', command], batchfile) + call writefile(s:wrap_cmds(command), batchfile) let command = batchfile if has('nvim') let s:dict = a:dict |
