Skip to content
Myr

[Vim] Allow vertical split of tmux window

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 ded184d · Browse files · 2 files+34 added−19 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+34 added−19 removed

  • other:+34 added−19 removed

2 files+34 added−19 removed

modified:plugin/fzf.vim+21 added-7 removed
19 unmodified lines
20" LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION21" OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION22" WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.2324let s:min_tmux_width = 1025let s:min_tmux_height = 326let s:default_tmux_height = '40%'2728let s:cpo_save = &cpo
59 unmodified lines
88 let prefix = ''89 endif90 let command = prefix.s:exec.' '.optstr.' > '.temps.result9191 if s:tmux_enabled() && has_key(dict, 'tmux') &&92 \ dict.tmux > 0 && winheight(0) >= s:min_tmux_height92 if s:tmux_enabled() && s:tmux_splittable(dict)93 return s:execute_tmux(dict, command, temps)94 else95 return s:execute(dict, command, temps)96 endif97endfunction9899function! s:tmux_splittable(dict)100 return101 \ min([&columns, get(a:dict, 'tmux_width', 0)]) >= s:min_tmux_width ||102 \ min([&lines, get(a:dict, 'tmux_height', get(a:dict, 'tmux', 0))]) >= s:min_tmux_height103endfunction104105function! s:pushd(dict)106 if has_key(a:dict, 'dir')107 let a:dict.prev_dir = getcwd()108 execute 'chdir '.s:escape(a:dict.dir)
24 unmodified lines
133 else134 let command = a:command135 endif136131 if type(a:dict.tmux) == 1 && a:dict.tmux =~ '%$'132 let height = '-p '.a:dict.tmux[0:-2]137 let splitopt = '-v'138 if has_key(a:dict, 'tmux_width')139 let splitopt = '-h'140 let size = a:dict.tmux_width141 else134 let height = '-l '.a:dict.tmux142 let size = get(a:dict, 'tmux_height', get(a:dict, 'tmux'))143 endif144145 if type(size) == 1 && size =~ '%$'146 let sizeopt = '-p '.size[0:-2]147 else148 let sizeopt = '-l '.size149 endif150151 let s:pane = substitute(152 \ system(153 \ printf(140 \ 'tmux split-window %s -P -F "#{pane_id}" %s',141 \ height, s:shellesc(command))), '\n', '', 'g')154 \ 'tmux split-window %s %s -P -F "#{pane_id}" %s',155 \ splitopt, sizeopt, s:shellesc(command))), '\n', '', 'g')156 let s:dict = a:dict157 let s:temps = a:temps158159 augroup fzf_tmux
62 unmodified lines
modified:README.md+13 added-12 removed
330 unmodified lines
331of the selected items.332333`fzf#run()` may take an options-dictionary:334335| Option name | Type | Description |336| ----------- | ------------- | ------------------------------------------------------------------- |337| `source` | string | External command to generate input to fzf (e.g. `find .`) |338| `source` | list | Vim list as input to fzf |339| `sink` | string | Vim command to handle the selected item (e.g. `e`, `tabe`) |340| `sink` | funcref | Reference to function to process each selected item |341| `options` | string | Options to fzf |342| `dir` | string | Working directory |343| `tmux` | number/string | Use tmux split if possible with the given height (e.g. `20`, `50%`) |335| Option name | Type | Description |336| ------------- | ------------- | ------------------------------------------------------------------ |337| `source` | string | External command to generate input to fzf (e.g. `find .`) |338| `source` | list | Vim list as input to fzf |339| `sink` | string | Vim command to handle the selected item (e.g. `e`, `tabe`) |340| `sink` | funcref | Reference to function to process each selected item |341| `options` | string | Options to fzf |342| `dir` | string | Working directory |343| `tmux_width` | number/string | Use tmux vertical split with the given height (e.g. `20`, `50%`) |344| `tmux_height` | number/string | Use tmux horizontal split with the given height (e.g. `20`, `50%`) |345346#### Examples347348If `sink` option is not given, `fzf#run` will simply return the list.
17 unmodified lines
366nnoremap <silent> <Leader>C :call fzf#run({367\ 'source':368\ map(split(globpath(&rtp, "colors/*.vim"), "\n"),369\ "substitute(fnamemodify(v:val, ':t'), '\\..\\{-}$', '', '')"),369\ 'sink': 'colo',370\ 'options': '+m',371\ 'tmux': 15370\ 'sink': 'colo',371\ 'options': '+m',372\ 'tmux_width': 20373\ })<CR>374```375376`sink` option can be a function reference. The following example creates a
89 unmodified lines