mirror of
https://github.com/airblade/vim-gitgutter.git
synced 2025-11-08 11:33:48 -05:00
@@ -299,6 +299,7 @@ You can customise:
|
||||
* Whether to clobber or preserve non-gitgutter signs
|
||||
* The priority of gitgutter's signs.
|
||||
* Whether to use a floating/popup window for hunk previews
|
||||
* The appearance of a floating/popup window for hunk previews
|
||||
* Whether to populate the quickfix list or a location list with all hunks
|
||||
|
||||
Please note that vim-gitgutter won't override any colours or highlights you've set in your colorscheme.
|
||||
@@ -519,6 +520,11 @@ let g:gitgutter_async = 0
|
||||
Add `let g:gitgutter_preview_win_floating = 1` to your `~/.vimrc`. Note that on Vim this prevents you staging (partial) hunks via the preview window.
|
||||
|
||||
|
||||
#### The appearance of a floating/popup window for hunk previews
|
||||
|
||||
Set `g:gitgutter_floating_window_options` to a dictionary of the options you want. This dictionary is passed directly to `popup_create()` (Vim) / `nvim_open_win()` (Neovim).
|
||||
|
||||
|
||||
#### To load all hunks into the current window's location list instead of the quickfix list
|
||||
|
||||
Add `let g:gitgutter_use_location_list = 1` to your `~/.vimrc`.
|
||||
|
||||
@@ -431,14 +431,7 @@ function! s:open_hunk_preview_window()
|
||||
|
||||
let buf = nvim_create_buf(v:false, v:false)
|
||||
" Set default width and height for now.
|
||||
let s:winid = nvim_open_win(buf, v:false, {
|
||||
\ 'relative': 'cursor',
|
||||
\ 'row': 1,
|
||||
\ 'col': 0,
|
||||
\ 'width': 42,
|
||||
\ 'height': &previewheight,
|
||||
\ 'style': 'minimal'
|
||||
\ })
|
||||
let s:winid = nvim_open_win(buf, v:false, g:gitgutter_floating_window_options)
|
||||
call nvim_buf_set_option(buf, 'filetype', 'diff')
|
||||
call nvim_buf_set_option(buf, 'buftype', 'acwrite')
|
||||
call nvim_buf_set_option(buf, 'bufhidden', 'delete')
|
||||
@@ -461,16 +454,11 @@ function! s:open_hunk_preview_window()
|
||||
endif
|
||||
|
||||
if exists('*popup_create')
|
||||
let opts = {
|
||||
\ 'line': 'cursor+1',
|
||||
\ 'col': 'cursor',
|
||||
\ 'moved': 'any',
|
||||
\ }
|
||||
if g:gitgutter_close_preview_on_escape
|
||||
let opts.filter = function('s:close_popup_on_escape')
|
||||
let g:gitgutter_floating_window_options.filter = function('s:close_popup_on_escape')
|
||||
endif
|
||||
|
||||
let s:winid = popup_create('', opts)
|
||||
let s:winid = popup_create('', g:gitgutter_floating_window_options)
|
||||
|
||||
call setbufvar(winbufnr(s:winid), '&filetype', 'diff')
|
||||
|
||||
@@ -515,7 +503,7 @@ function! s:populate_hunk_preview_window(header, body)
|
||||
|
||||
if g:gitgutter_preview_win_floating
|
||||
if exists('*nvim_open_win')
|
||||
let height = min([body_length, &previewheight])
|
||||
let height = min([body_length, g:gitgutter_floating_window_options.height])
|
||||
|
||||
" Assumes cursor is not in previewing window.
|
||||
call nvim_buf_set_var(winbufnr(s:winid), 'hunk_header', a:header)
|
||||
|
||||
@@ -348,6 +348,7 @@ Hunk jumping:~
|
||||
Hunk previews:~
|
||||
|
||||
|g:gitgutter_preview_win_floating|
|
||||
|g:gitgutter_floating_window_options|
|
||||
|g:gitgutter_close_preview_on_escape|
|
||||
|
||||
Terminal:~
|
||||
@@ -508,6 +509,29 @@ Whether to use floating/popup windows for hunk previews. Note that if you use
|
||||
popup windows on Vim you will not be able to stage partial hunks via the
|
||||
preview window.
|
||||
|
||||
*g:gitgutter_floating_window_options*
|
||||
Default:
|
||||
>
|
||||
" Vim
|
||||
{
|
||||
\ 'line': 'cursor+1',
|
||||
\ 'col': 'cursor',
|
||||
\ 'moved': 'any'
|
||||
}
|
||||
|
||||
" Neovim
|
||||
{
|
||||
\ 'relative': 'cursor',
|
||||
\ 'row': 1,
|
||||
\ 'col': 0,
|
||||
\ 'width': 42,
|
||||
\ 'height': &previewheight,
|
||||
\ 'style': 'minimal'
|
||||
}
|
||||
<
|
||||
This dictionary is passed directly to |popup_create()| (Vim) or
|
||||
|nvim_open_win()| (Neovim).
|
||||
|
||||
*g:gitgutter_close_preview_on_escape*
|
||||
Default: 0
|
||||
|
||||
|
||||
@@ -24,9 +24,22 @@ endfunction
|
||||
let g:gitgutter_preview_win_location = get(g:, 'gitgutter_preview_win_location', 'bo')
|
||||
if exists('*nvim_open_win')
|
||||
let g:gitgutter_preview_win_floating = get(g:, 'gitgutter_preview_win_floating', 1)
|
||||
let g:gitgutter_floating_window_options = get(g:, 'gitgutter_floating_window_options', {
|
||||
\ 'relative': 'cursor',
|
||||
\ 'row': 1,
|
||||
\ 'col': 0,
|
||||
\ 'width': 42,
|
||||
\ 'height': &previewheight,
|
||||
\ 'style': 'minimal'
|
||||
\ })
|
||||
else
|
||||
let default = exists('&previewpopup') ? !empty(&previewpopup) : 0
|
||||
let g:gitgutter_preview_win_floating = get(g:, 'gitgutter_preview_win_floating', default)
|
||||
let g:gitgutter_floating_window_options = get(g:, 'gitgutter_floating_window_options', {
|
||||
\ 'line': 'cursor+1',
|
||||
\ 'col': 'cursor',
|
||||
\ 'moved': 'any'
|
||||
\ })
|
||||
endif
|
||||
let g:gitgutter_enabled = get(g:, 'gitgutter_enabled', 1)
|
||||
if exists('*sign_unplace')
|
||||
|
||||
Reference in New Issue
Block a user