comparison autoload/lawrencium/status.vim @ 145:78176bdfe0be

Add `lawrencium_status_win_maxheight` setting.
author Ludovic Chabant <ludovic@chabant.com>
date Sat, 03 Nov 2018 19:01:22 -0700
parents c9169233d45a
children
comparison
equal deleted inserted replaced
144:62af332fbf4a 145:78176bdfe0be
46 call lawrencium#throwerr("Invalid status type: " . string(a:status_type)) 46 call lawrencium#throwerr("Invalid status type: " . string(a:status_type))
47 endif 47 endif
48 48
49 " Open the Lawrencium buffer in a new split window of the right size. 49 " Open the Lawrencium buffer in a new split window of the right size.
50 if g:lawrencium_status_win_split_above 50 if g:lawrencium_status_win_split_above
51 execute "keepalt leftabove split " . fnameescape(l:status_path) 51 execute "keepalt leftabove split " . fnameescape(l:status_path)
52 else 52 else
53 execute "keepalt rightbelow split " . fnameescape(l:status_path) 53 execute "keepalt rightbelow split " . fnameescape(l:status_path)
54 endif 54 endif
55 55
56 if (line('$') == 1 && getline(1) == '') 56 if (line('$') == 1 && getline(1) == '')
57 " Buffer is empty, which means there are not changes... 57 " Buffer is empty, which means there are not changes...
58 " Quit and display a message. 58 " Quit and display a message.
59 " TODO: figure out why the first `echom` doesn't show when alone. 59 " TODO: figure out why the first `echom` doesn't show when alone.
60 bdelete 60 bdelete
63 return 63 return
64 endif 64 endif
65 65
66 execute "setlocal winfixheight" 66 execute "setlocal winfixheight"
67 if !g:lawrencium_status_win_split_even 67 if !g:lawrencium_status_win_split_even
68 execute "setlocal winheight=" . (line('$') + 1) 68 let l:status_win_height = (line('$') + 1)
69 execute "resize " . (line('$') + 1) 69 if g:lawrencium_status_win_maxheight > 0
70 let l:status_win_height = min([
71 \l:status_win_height,
72 \&lines * g:lawrencium_status_win_maxheight / 100
73 \])
74 endif
75 execute "resize " . l:status_win_height
70 endif 76 endif
71 77
72 let b:lawrencium_status_type = a:status_type 78 let b:lawrencium_status_type = a:status_type
73 let b:lawrencium_status_param = a:status_param 79 let b:lawrencium_status_param = a:status_param
74 80
135 endif 141 endif
136 142
137 " Just re-edit the buffer, it will reload the contents by calling 143 " Just re-edit the buffer, it will reload the contents by calling
138 " the matching Mercurial command. 144 " the matching Mercurial command.
139 edit 145 edit
146
147 " The window might have been resize if something happened (like, say, we
148 " opened a commit message window, and closed it).
149 if g:lawrencium_status_win_split_even
150 execute "resize " . (&lines / 2)
151 else
152 let l:status_win_height = (line('$') + 1)
153 if g:lawrencium_status_win_maxheight > 0
154 let l:status_win_height = min([
155 \l:status_win_height,
156 \&lines * g:lawrencium_status_win_maxheight / 100
157 \])
158 endif
159 execute "resize " . l:status_win_height
160 endif
140 endfunction 161 endfunction
141 162
142 function! s:HgStatus_Refresh() abort 163 function! s:HgStatus_Refresh() abort
143 call lawrencium#status#HgStatusRefresh() 164 call lawrencium#status#HgStatusRefresh()
144 endfunction 165 endfunction