mirror of
https://github.com/Llewellynvdm/fzf.git
synced 2024-11-29 08:13:54 +00:00
Add MSYS2 support as a vim plugin (#1677)
* Add MSYS2 support as a vim plugin Add &shellcmdflag and TERM environment variable treatment. - Make &shellcmdflag `/C` when &shell turns into `cmd.exe` - Delete %TERM% environment variable before fzf execution * Change shellescape default value depending on s:is_win flag * Make TERM environment empty only when gui is running * Stop checking &shell in fzf#shellescape function This funcion's behavior is controlled by only if it is Windows or not. So there is no need to check &shell. * Take neovim into consideration when to set shellcmdflag * Add &shellxquote control
This commit is contained in:
parent
9fefe08b3f
commit
a9906c7c29
@ -54,6 +54,7 @@ if s:is_win
|
|||||||
return map([
|
return map([
|
||||||
\ '@echo off',
|
\ '@echo off',
|
||||||
\ 'setlocal enabledelayedexpansion']
|
\ 'setlocal enabledelayedexpansion']
|
||||||
|
\ + (has('gui_running') ? ['set TERM= > nul'] : [])
|
||||||
\ + (type(a:cmds) == type([]) ? a:cmds : [a:cmds])
|
\ + (type(a:cmds) == type([]) ? a:cmds : [a:cmds])
|
||||||
\ + ['endlocal'],
|
\ + ['endlocal'],
|
||||||
\ printf('iconv(v:val."\r", "%s", "cp%d")', &encoding, s:codepage))
|
\ printf('iconv(v:val."\r", "%s", "cp%d")', &encoding, s:codepage))
|
||||||
@ -79,7 +80,7 @@ function! s:shellesc_cmd(arg)
|
|||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! fzf#shellescape(arg, ...)
|
function! fzf#shellescape(arg, ...)
|
||||||
let shell = get(a:000, 0, &shell)
|
let shell = get(a:000, 0, s:is_win ? 'cmd.exe' : 'sh')
|
||||||
if shell =~# 'cmd.exe$'
|
if shell =~# 'cmd.exe$'
|
||||||
return s:shellesc_cmd(a:arg)
|
return s:shellesc_cmd(a:arg)
|
||||||
endif
|
endif
|
||||||
@ -338,19 +339,21 @@ function! fzf#wrap(...)
|
|||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:use_sh()
|
function! s:use_sh()
|
||||||
let [shell, shellslash] = [&shell, &shellslash]
|
let [shell, shellslash, shellcmdflag, shellxquote] = [&shell, &shellslash, &shellcmdflag, &shellxquote]
|
||||||
if s:is_win
|
if s:is_win
|
||||||
set shell=cmd.exe
|
set shell=cmd.exe
|
||||||
set noshellslash
|
set noshellslash
|
||||||
|
let &shellcmdflag = has('nvim') ? '/s /c' : '/c'
|
||||||
|
let &shellxquote = has('nvim') ? '"' : '('
|
||||||
else
|
else
|
||||||
set shell=sh
|
set shell=sh
|
||||||
endif
|
endif
|
||||||
return [shell, shellslash]
|
return [shell, shellslash, shellcmdflag, shellxquote]
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! fzf#run(...) abort
|
function! fzf#run(...) abort
|
||||||
try
|
try
|
||||||
let [shell, shellslash] = s:use_sh()
|
let [shell, shellslash, shellcmdflag, shellxquote] = s:use_sh()
|
||||||
|
|
||||||
let dict = exists('a:1') ? s:upgrade(a:1) : {}
|
let dict = exists('a:1') ? s:upgrade(a:1) : {}
|
||||||
let temps = { 'result': s:fzf_tempname() }
|
let temps = { 'result': s:fzf_tempname() }
|
||||||
@ -420,7 +423,7 @@ try
|
|||||||
call s:callback(dict, lines)
|
call s:callback(dict, lines)
|
||||||
return lines
|
return lines
|
||||||
finally
|
finally
|
||||||
let [&shell, &shellslash] = [shell, shellslash]
|
let [&shell, &shellslash, &shellcmdflag, &shellxquote] = [shell, shellslash, shellcmdflag, shellxquote]
|
||||||
endtry
|
endtry
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user