mirror of
https://github.com/Llewellynvdm/fzf.git
synced 2024-12-23 11:29:01 +00:00
[vim] Enable fzf in GVim using xterm
This commit is contained in:
parent
f8e357fa19
commit
0b43f988c7
@ -287,7 +287,7 @@ TODO :smiley:
|
|||||||
Usage as Vim plugin
|
Usage as Vim plugin
|
||||||
-------------------
|
-------------------
|
||||||
|
|
||||||
(fzf is a command-line utility, naturally it is only accessible in terminal Vim)
|
Note: To use fzf in GVim, bash and xterm are required.
|
||||||
|
|
||||||
### `:FZF[!]`
|
### `:FZF[!]`
|
||||||
|
|
||||||
|
@ -24,6 +24,7 @@
|
|||||||
let s:min_tmux_width = 10
|
let s:min_tmux_width = 10
|
||||||
let s:min_tmux_height = 3
|
let s:min_tmux_height = 3
|
||||||
let s:default_tmux_height = '40%'
|
let s:default_tmux_height = '40%'
|
||||||
|
let s:gui_supported = executable('bash') && executable('xterm')
|
||||||
|
|
||||||
let s:cpo_save = &cpo
|
let s:cpo_save = &cpo
|
||||||
set cpo&vim
|
set cpo&vim
|
||||||
@ -42,6 +43,10 @@ else
|
|||||||
endif
|
endif
|
||||||
|
|
||||||
function! s:tmux_enabled()
|
function! s:tmux_enabled()
|
||||||
|
if has('gui_running')
|
||||||
|
return 0
|
||||||
|
endif
|
||||||
|
|
||||||
if exists('s:tmux')
|
if exists('s:tmux')
|
||||||
return s:tmux
|
return s:tmux
|
||||||
endif
|
endif
|
||||||
@ -63,11 +68,12 @@ function! s:escape(path)
|
|||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! fzf#run(...) abort
|
function! fzf#run(...) abort
|
||||||
if has('gui_running')
|
if has('gui_running') && !s:gui_supported
|
||||||
echohl Error
|
echohl Error
|
||||||
echo 'GVim is not supported'
|
echo 'bash and xterm required to run fzf in GVim'
|
||||||
return []
|
return []
|
||||||
endif
|
endif
|
||||||
|
|
||||||
let dict = exists('a:1') ? a:1 : {}
|
let dict = exists('a:1') ? a:1 : {}
|
||||||
let temps = { 'result': tempname() }
|
let temps = { 'result': tempname() }
|
||||||
let optstr = get(dict, 'options', '')
|
let optstr = get(dict, 'options', '')
|
||||||
@ -118,7 +124,11 @@ endfunction
|
|||||||
function! s:execute(dict, command, temps)
|
function! s:execute(dict, command, temps)
|
||||||
call s:pushd(a:dict)
|
call s:pushd(a:dict)
|
||||||
silent !clear
|
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!
|
redraw!
|
||||||
if v:shell_error
|
if v:shell_error
|
||||||
return []
|
return []
|
||||||
|
Loading…
Reference in New Issue
Block a user