[vim] External terminal emulator for GVim
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by Junegunn Choi · committed by Junegunn Choi · parent f58a53a · Browse files · 2 files·+20 added−20 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
2 files+20 added−20 removed
- other:+20 added−20 removed
Provenance
- Commit
4a3a5ee- Tree
fceb695- Author
Junegunn Choi <junegunn.c@gmail.com>- Committer
Junegunn Choi <junegunn.c@gmail.com>- Parent
f58a53a
2 files changed+20 added−20 removed
modified:plugin/fzf.vim+7 added-11 removed
22 unmodified lines23 24 let s:min_tmux_width = 1025 let s:min_tmux_height = 326 let s:default_tmux_height = '40%'27-let s:gui_supported = executable('bash') && executable('xterm')27+let s:launcher = 'xterm -e bash -ic %s'28 29 let s:cpo_save = &cpo30 set cpo&vim31 35 unmodified lines67 return substitute(a:path, ' ', '\\ ', 'g')68 endfunction69 70 function! fzf#run(...) abort71- if has('gui_running') && !s:gui_supported72- echohl Error73- echo 'bash and xterm required to run fzf in GVim'74- return []75- endif76-71 let dict = exists('a:1') ? a:1 : {}72 let temps = { 'result': tempname() }73 let optstr = get(dict, 'options', '')74 43 unmodified lines118 function! s:execute(dict, command, temps)119 call s:pushd(a:dict)120 silent !clear121 if has('gui_running')128- let xterm_options = get(a:dict, 'xterm_options', get(g:, 'fzf_xterm_options', ''))129- execute "silent !xterm ".xterm_options.130- \ " -e bash -ic '".substitute(a:command, "'", "'\"'\"'", 'g')."'"122+ let launcher = get(a:dict, 'launcher', get(g:, 'fzf_launcher', s:launcher))123+ let command = printf(launcher, "'".substitute(a:command, "'", "'\"'\"'", 'g')."'")124 else132- execute 'silent !'.a:command125+ let command = a:command126 endif127+ execute 'silent !'.command128 redraw!129 if v:shell_error130+ echohl Error131+ echo 'Error running ' . command132 return []133 else134 return s:callback(a:dict, a:temps, 0)135 endif94 unmodified linesmodified:README.md+13 added-9 removed
285 unmodified lines286 287 Usage as Vim plugin288 -------------------289 290-(Note: To use fzf in GVim, bash and xterm are required.)290+(Note: To use fzf in GVim, an external terminal emulator is required.)291 292 ### `:FZF[!]`293 294 If you have set up fzf for Vim, `:FZF` command will be added.15 unmodified lines310 If you're on a tmux session, `:FZF` will launch fzf in a new split-window whose311 height can be adjusted with `g:fzf_tmux_height` (default: '40%'). However, the312 bang version (`:FZF!`) will always start in fullscreen.313 314-In GVim, `xterm` command will be used to launch fzf. You can set options to315-`xterm` command with `g:fzf_xterm_options`. For example,314+In GVim, you need an external terminal emulator to start fzf with. `xterm`315+command is used by default, but you can customize it with `g:fzf_launcher`.316 317 ```vim318-let g:fzf_xterm_options = '-geometry 120x30'318+" This is the default. %s is replaced with fzf command319+let g:fzf_launcher = 'xterm -e bash -ic %s'320+321+" Use urxvt instead322+let g:fzf_launcher = 'urxvt -geometry 120x30 -e sh -c %s'323 ```324 325 ### `fzf#run([options])`326 11 unmodified lines338 | `options` | string | Options to fzf |339 | `dir` | string | Working directory |340 | `tmux_width` | number/string | Use tmux vertical split with the given height (e.g. `20`, `50%`) |341 | `tmux_height` | number/string | Use tmux horizontal split with the given height (e.g. `20`, `50%`) |338-| `xterm_options` | string | Options to `xterm` command (Only used in GVim) |342+| `launcher` | string | External terminal emulator to start fzf with (Only used in GVim) |343 344 #### Examples345 346 If `sink` option is not given, `fzf#run` will simply return the list.17 unmodified lines364 nnoremap <silent> <Leader>C :call fzf#run({365 \ 'source':366 \ map(split(globpath(&rtp, "colors/*.vim"), "\n"),367 \ "substitute(fnamemodify(v:val, ':t'), '\\..\\{-}$', '', '')"),364-\ 'sink': 'colo',365-\ 'options': '+m',366-\ 'tmux_width': 20,367-\ 'xterm_options': '-geometry 20x30'368+\ 'sink': 'colo',369+\ 'options': '+m',370+\ 'tmux_width': 20,371+\ 'launcher': 'xterm -geometry 20x30 -e bash -ic %s'372 \ })<CR>373 ```374 375 `sink` option can be a function reference. The following example creates a176 unmodified lines