Skip to content
Snippets Groups Projects
Commit 6a66b2f8 authored by Jerome Reybert's avatar Jerome Reybert
Browse files

Set scrolloff in magit buffer

By default, scrolloff is set to 3. Can be overwritten with
g:magit_scrolloff.
Until recent vim patch 8.1.0864, scrolloff is a global only option. Must
play with autocommand BufEnter/BufExit to mimic a local scrolloff
behavior.

ref #172
parent 91b947cc
No related branches found
No related tags found
No related merge requests found
......@@ -475,6 +475,14 @@ This option automatically opens the fold of the hunk cursor has jump to.
Default value is 1.
let g:magit_auto_foldopen=[01]
*vimagit-g:magit_scrolloff*
Set *'scrolloff'* value in magit buffer.
Minimal number of screen lines to keep above and below the cursor.
Default value is 3.
Set to -1 if you do not want to set scrolloff, 0 to disable scrolloff in magit
buffer.
let g:magit_scrolloff=3
*vimagit-g:magit_default_sections*
With this variable, the user is able to choose which sections are displayed in
magit buffer, and in which order.
......
......@@ -37,6 +37,8 @@ let g:magit_refresh_gitgutter = get(g:, 'magit_refresh_gitgutter',
let g:magit_commit_title_limit = get(g:, 'magit_commit_title_limit', 50)
let g:magit_scrolloff = get(g:, 'magit_scrolloff', 3)
let g:magit_warning_max_lines = get(g:, 'magit_warning_max_lines', 10000)
let g:magit_git_cmd = get(g:, 'magit_git_cmd' , "git")
......@@ -808,6 +810,17 @@ function! magit#show_magit(display, ...)
setlocal nomodeline
let &l:foldlevel = b:magit_default_fold_level
setlocal filetype=magit
if ( g:magit_scrolloff != -1 )
if ( has("patch-8.1.0864") )
let &l:scrolloff = g:magit_scrolloff
else
let s:default_scrolloff=&scrolloff
" ugly hack, scrolloff is a global only option before patch 8.1.0864
execute "autocmd BufLeave " . buffer_name . " :set scrolloff=" . s:default_scrolloff
execute "autocmd BufEnter " . buffer_name . " :set scrolloff=" . g:magit_scrolloff
let &scrolloff = g:magit_scrolloff
endif
endif
augroup vimagit_buffer
autocmd!
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment