From e15598fe4567e4cdbcbc4aea2d8b0d0f75a7254f Mon Sep 17 00:00:00 2001 From: Junegunn Choi Date: Sat, 23 Jul 2016 18:36:30 +0900 Subject: [PATCH] Add g:plug_pwindow for customizing preview window layout Close #504 --- README.md | 1 + plug.vim | 14 +++++++++----- test/workflow.vader | 16 ++++++++++++++++ 3 files changed, 26 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 551c458..46f843d 100644 --- a/README.md +++ b/README.md @@ -141,6 +141,7 @@ Reload .vimrc and `:PlugInstall` to install plugins. | `g:plug_retries` | 2 | Number of retries in case of timeout (*Ruby & Python*) | | `g:plug_shallow` | 1 | Use shallow clone | | `g:plug_window` | `vertical topleft new` | Command to open plug window | +| `g:plug_pwindow` | `above 12new` | Command to open preview window in `PlugDiff` | | `g:plug_url_format` | `https://git::@github.com/%s.git` | `printf` format to build repo URL (Only applies to the subsequent `Plug` commands) | diff --git a/plug.vim b/plug.vim index ed064c3..0543aec 100644 --- a/plug.vim +++ b/plug.vim @@ -2181,11 +2181,15 @@ function! s:preview_commit() return endif - execute 'pedit' sha - wincmd P - setlocal filetype=git buftype=nofile nobuflisted modifiable - execute 'silent read !cd' s:shellesc(g:plugs[name].dir) '&& git show --no-color --pretty=medium' sha - normal! gg"_dd + if exists('g:plug_pwindow') && !s:is_preview_window_open() + execute g:plug_pwindow + execute 'e' sha + else + execute 'pedit' sha + wincmd P + endif + setlocal previewwindow filetype=git buftype=nofile nobuflisted modifiable + execute 'silent %!cd' s:shellesc(g:plugs[name].dir) '&& git show --no-color --pretty=medium' sha setlocal nomodifiable nnoremap q :q wincmd p diff --git a/test/workflow.vader b/test/workflow.vader index 329ed25..02d01a2 100644 --- a/test/workflow.vader +++ b/test/workflow.vader @@ -365,6 +365,22 @@ Execute (New commits on remote, PlugUpdate, then PlugDiff): AssertEqual 1, &previewwindow pclose +Execute (Test g:plug_pwindow): + let g:plug_pwindow = 'below 5new' + PlugDiff + AssertExpect '^- ', 1 + execute "normal ]]jo" + + AssertEqual 0, &previewwindow + AssertEqual 1, winnr() + wincmd P + AssertEqual 1, &previewwindow + AssertEqual 2, winnr() + AssertEqual 5, winheight('.') + wincmd p + normal q + unlet g:plug_pwindow + Execute (Reuse Plug window in another tab): let tabnr = tabpagenr() PlugDiff