# HG changeset patch # User Ludovic Chabant # Date 1541296882 25200 # Sat Nov 03 19:01:22 2018 -0700 # Node ID 78176bdfe0be433eb71f60598825dbfb122c958c # Parent 62af332fbf4a75804bda5831768fd11d49dce924 Add `lawrencium_status_win_maxheight` setting. diff --git a/autoload/lawrencium/status.vim b/autoload/lawrencium/status.vim --- a/autoload/lawrencium/status.vim +++ b/autoload/lawrencium/status.vim @@ -48,11 +48,11 @@ " Open the Lawrencium buffer in a new split window of the right size. if g:lawrencium_status_win_split_above - execute "keepalt leftabove split " . fnameescape(l:status_path) + execute "keepalt leftabove split " . fnameescape(l:status_path) else - execute "keepalt rightbelow split " . fnameescape(l:status_path) + execute "keepalt rightbelow split " . fnameescape(l:status_path) endif - + if (line('$') == 1 && getline(1) == '') " Buffer is empty, which means there are not changes... " Quit and display a message. @@ -65,8 +65,14 @@ execute "setlocal winfixheight" if !g:lawrencium_status_win_split_even - execute "setlocal winheight=" . (line('$') + 1) - execute "resize " . (line('$') + 1) + let l:status_win_height = (line('$') + 1) + if g:lawrencium_status_win_maxheight > 0 + let l:status_win_height = min([ + \l:status_win_height, + \&lines * g:lawrencium_status_win_maxheight / 100 + \]) + endif + execute "resize " . l:status_win_height endif let b:lawrencium_status_type = a:status_type @@ -137,6 +143,21 @@ " Just re-edit the buffer, it will reload the contents by calling " the matching Mercurial command. edit + + " The window might have been resize if something happened (like, say, we + " opened a commit message window, and closed it). + if g:lawrencium_status_win_split_even + execute "resize " . (&lines / 2) + else + let l:status_win_height = (line('$') + 1) + if g:lawrencium_status_win_maxheight > 0 + let l:status_win_height = min([ + \l:status_win_height, + \&lines * g:lawrencium_status_win_maxheight / 100 + \]) + endif + execute "resize " . l:status_win_height + endif endfunction function! s:HgStatus_Refresh() abort diff --git a/doc/lawrencium.txt b/doc/lawrencium.txt --- a/doc/lawrencium.txt +++ b/doc/lawrencium.txt @@ -573,6 +573,14 @@ show all modified files. Defaults to `0`. + *lawrencium_status_win_maxheight* +g:lawrencium_status_win_maxheight + The maxiumum height, in percentage of the Vim window + height, that the |Hgstatus| window is allowed to take. + It will take as much room as needed to show its + contents, up to this limit. + Defaults to `50`. + *lawrencium_record_start_in_working_buffer* g:lawrencium_record_start_in_working_buffer If set to 1, |Hgrecord| will leave focus in the diff --git a/plugin/lawrencium.vim b/plugin/lawrencium.vim --- a/plugin/lawrencium.vim +++ b/plugin/lawrencium.vim @@ -49,6 +49,10 @@ let g:lawrencium_status_win_split_even = 0 endif +if !exists('g:lawrencium_status_win_maxheight') + let g:lawrencium_status_win_maxheight = 50 +endif + if !exists('g:lawrencium_record_start_in_working_buffer') let g:lawrencium_record_start_in_working_buffer = 0 endif