summaryrefslogtreecommitdiff
path: root/plugin
diff options
context:
space:
mode:
authorJunegunn Choi <junegunn.c@gmail.com>2014-04-12 19:53:33 +0900
committerJunegunn Choi <junegunn.c@gmail.com>2014-04-12 19:53:39 +0900
commit16031b0d547ac6b8f929867e60d92bf19726fd45 (patch)
tree5589d8e1cda9ad2a2ad38a5a6302242806252859 /plugin
parentded184daaffa2bfa336051bea36ff070cdaff9eb (diff)
downloadfzf-16031b0d547ac6b8f929867e60d92bf19726fd45.tar.gz
[Vim] Allow vertical split of tmux window
Diffstat (limited to 'plugin')
-rw-r--r--plugin/fzf.vim28
1 files changed, 21 insertions, 7 deletions
diff --git a/plugin/fzf.vim b/plugin/fzf.vim
index 0b809318..0020b0bc 100644
--- a/plugin/fzf.vim
+++ b/plugin/fzf.vim
@@ -21,6 +21,7 @@
" OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
" WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+let s:min_tmux_width = 10
let s:min_tmux_height = 3
let s:default_tmux_height = '40%'
@@ -88,14 +89,19 @@ function! fzf#run(...) abort
endif
let command = prefix.s:exec.' '.optstr.' > '.temps.result
- if s:tmux_enabled() && has_key(dict, 'tmux') &&
- \ dict.tmux > 0 && winheight(0) >= s:min_tmux_height
+ if s:tmux_enabled() && s:tmux_splittable(dict)
return s:execute_tmux(dict, command, temps)
else
return s:execute(dict, command, temps)
endif
endfunction
+function! s:tmux_splittable(dict)
+ return
+ \ min([&columns, get(a:dict, 'tmux_width', 0)]) >= s:min_tmux_width ||
+ \ min([&lines, get(a:dict, 'tmux_height', get(a:dict, 'tmux', 0))]) >= s:min_tmux_height
+endfunction
+
function! s:pushd(dict)
if has_key(a:dict, 'dir')
let a:dict.prev_dir = getcwd()
@@ -128,17 +134,25 @@ function! s:execute_tmux(dict, command, temps)
let command = a:command
endif
- if type(a:dict.tmux) == 1 && a:dict.tmux =~ '%$'
- let height = '-p '.a:dict.tmux[0:-2]
+ let splitopt = '-v'
+ if has_key(a:dict, 'tmux_width')
+ let splitopt = '-h'
+ let size = a:dict.tmux_width
+ else
+ let size = get(a:dict, 'tmux_height', get(a:dict, 'tmux'))
+ endif
+
+ if type(size) == 1 && size =~ '%$'
+ let sizeopt = '-p '.size[0:-2]
else
- let height = '-l '.a:dict.tmux
+ let sizeopt = '-l '.size
endif
let s:pane = substitute(
\ system(
\ printf(
- \ 'tmux split-window %s -P -F "#{pane_id}" %s',
- \ height, s:shellesc(command))), '\n', '', 'g')
+ \ 'tmux split-window %s %s -P -F "#{pane_id}" %s',
+ \ splitopt, sizeopt, s:shellesc(command))), '\n', '', 'g')
let s:dict = a:dict
let s:temps = a:temps