summaryrefslogtreecommitdiffstats
path: root/plugin
diff options
context:
space:
mode:
authorJunegunn Choi <junegunn.c@gmail.com>2014-06-15 03:04:15 +0900
committerJunegunn Choi <junegunn.c@gmail.com>2014-06-15 03:06:26 +0900
commit0b43f988c7ffd587835875bf12e8d312ab52d002 (patch)
tree82d79b3f5d2d8b338c32ecaad687e8a0206ca994 /plugin
parentf8e357fa19a35e664c684c7ed54095b3f6c76880 (diff)
[vim] Enable fzf in GVim using xterm
Diffstat (limited to 'plugin')
-rw-r--r--plugin/fzf.vim16
1 files changed, 13 insertions, 3 deletions
diff --git a/plugin/fzf.vim b/plugin/fzf.vim
index 0020b0bc..bf0e2b93 100644
--- a/plugin/fzf.vim
+++ b/plugin/fzf.vim
@@ -24,6 +24,7 @@
let s:min_tmux_width = 10
let s:min_tmux_height = 3
let s:default_tmux_height = '40%'
+let s:gui_supported = executable('bash') && executable('xterm')
let s:cpo_save = &cpo
set cpo&vim
@@ -42,6 +43,10 @@ else
endif
function! s:tmux_enabled()
+ if has('gui_running')
+ return 0
+ endif
+
if exists('s:tmux')
return s:tmux
endif
@@ -63,11 +68,12 @@ function! s:escape(path)
endfunction
function! fzf#run(...) abort
- if has('gui_running')
+ if has('gui_running') && !s:gui_supported
echohl Error
- echo 'GVim is not supported'
+ echo 'bash and xterm required to run fzf in GVim'
return []
endif
+
let dict = exists('a:1') ? a:1 : {}
let temps = { 'result': tempname() }
let optstr = get(dict, 'options', '')
@@ -118,7 +124,11 @@ endfunction
function! s:execute(dict, command, temps)
call s:pushd(a:dict)
silent !clear
- execute 'silent !'.a:command
+ if has('gui_running')
+ execute "silent !xterm -e bash -ic '".substitute(a:command, "'", "'\"'\"'", 'g')."'"
+ else
+ execute 'silent !'.a:command
+ endif
redraw!
if v:shell_error
return []