Skip to content

Commit

Permalink
Open vim-plug window in a new tab (#1274)
Browse files Browse the repository at this point in the history
* Open vim-plug window in a new tab not to disrupt the current window layout
* Open preview window on the right to better show the diff

If you prefer the old layout, use the following configuration:

    let g:plug_window = 'vertical topleft new'
    let g:plug_pwindow = 'above 12new'
  • Loading branch information
junegunn authored Mar 6, 2024
1 parent 3049761 commit 854b081
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 8 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -250,8 +250,8 @@ More examples can be found in:
| `g:plug_timeout` | 60 | Time limit of each task in seconds (*Ruby & Python*) |
| `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_window` | `-tabnew` | Command to open plug window |
| `g:plug_pwindow` | `vertical rightbelow new` | 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) |


Expand Down
6 changes: 3 additions & 3 deletions doc/plug.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
plug.txt plug Last change: February 23 2024
plug.txt plug Last change: March 7 2024
PLUG - TABLE OF CONTENTS *plug* *plug-toc*
==============================================================================

Expand Down Expand Up @@ -230,8 +230,8 @@ Reload .vimrc and `:PlugInstall` to install plugins.
`g:plug_timeout` | 60 | Time limit of each task in seconds (Ruby & Python)
`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_window` | `-tabnew` | Command to open plug window
`g:plug_pwindow` | `vertical rightbelow new` | 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)
--------------------+-----------------------------------+-----------------------------------------------------------------------------------

Expand Down
6 changes: 3 additions & 3 deletions plug.vim
Original file line number Diff line number Diff line change
Expand Up @@ -878,7 +878,7 @@ function! s:lastline(msg)
endfunction

function! s:new_window()
execute get(g:, 'plug_window', 'vertical topleft new')
execute get(g:, 'plug_window', '-tabnew')
endfunction

function! s:plug_window_exists()
Expand Down Expand Up @@ -2684,8 +2684,8 @@ function! s:preview_commit()
return
endif

if exists('g:plug_pwindow') && !s:is_preview_window_open()
execute g:plug_pwindow
if !s:is_preview_window_open()
execute get(g:, 'plug_pwindow', 'vertical rightbelow new')
execute 'e' title
else
execute 'pedit' title
Expand Down
9 changes: 9 additions & 0 deletions test/workflow.vader
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,9 @@ Execute (PlugDiff - 'No updates.'):
q

Execute (New commits on remote, PlugUpdate, then PlugDiff):
let g:plug_window = 'vertical topleft new'
let g:plug_pwindow = 'above 12new'

for repo in ['seoul256.vim', 'vim-emoji']
for _ in range(2)
call system(printf('cd /tmp/vim-plug-test/junegunn/%s && git commit --allow-empty -m "update"', repo))
Expand Down Expand Up @@ -458,6 +461,8 @@ Execute (New commits on remote, PlugUpdate, then PlugDiff):
AssertEqual 1, &previewwindow
pclose

unlet g:plug_window g:plug_pwindow

Execute (Test g:plug_pwindow):
let g:plug_pwindow = 'below 5new'
PlugDiff
Expand Down Expand Up @@ -1709,6 +1714,8 @@ Execute (#530 - Comparison of incompatible git URIs):
Assert !CompareURI('https://github.com/junegunn/vim-plug.git', 'https://github.com:12345/junegunn/vim-plug.git')

Execute (#532 - Reuse plug window):
let g:plug_window = 'vertical topleft new'
let g:plug_pwindow = 'above 12new'
call plug#begin()
Plug 'junegunn/goyo.vim'
call plug#end()
Expand All @@ -1735,6 +1742,8 @@ Execute (#532 - Reuse plug window):
AssertEqual 2, winnr('$'), 'Three windows after PlugStatus (but got '.winnr('$').')'
q

unlet g:plug_window g:plug_pwindow

Execute (#766 - Allow cloning into an empty directory):
let d = '/tmp/vim-plug-test/goyo-already'
call system('rm -rf ' . d)
Expand Down

0 comments on commit 854b081

Please sign in to comment.