diff options
| -rw-r--r-- | vim.dot.link/plugin/session_workarounds.vim | 66 |
1 files changed, 48 insertions, 18 deletions
diff --git a/vim.dot.link/plugin/session_workarounds.vim b/vim.dot.link/plugin/session_workarounds.vim index 75d59cb..af32925 100644 --- a/vim.dot.link/plugin/session_workarounds.vim +++ b/vim.dot.link/plugin/session_workarounds.vim @@ -25,8 +25,10 @@ command! -bang FixWindowWidths :call FixWindowWidths() " Fix window widths on all tabs {{{ function FixAllWindowWidths() " Make sure to run this only once - if exists("did_fixed_window_widths") + if exists("g:did_fix_window_widths") return + else + let g:did_fix_window_widths=1 endif " Save the last active window @@ -38,9 +40,8 @@ function FixAllWindowWidths() call win_gotoid(l:current_win) " An additional, last move to the left pane - wincmd l - - let did_fixed_window_widths=1 + "execute ":NERDTreeFocus" + "wincmd l endfunction " }}} @@ -60,25 +61,50 @@ endfunction " https://vi.stackexchange.com/questions/8926/is-it-possible-to-obtain-the-displayable-area-width-and-height-of-current-buffe "let lines_initial=&l:lines function FixWindowHeights() - " Set the maximum available height - set lines=999 + " Make sure to run this only once + if exists("g:did_fix_window_heights") && g:did_fix_window_heights == 1 + return + else + let g:did_fix_window_heights=1 + endif + + " Save the last active window + let l:current_win = win_getid() + + " Set the maximum available height in all tabs + "set lines=999 + tabdo set lines=999 + + " Reset the terminal, so VIM gets a chance to reset it's height + " This works with both with rxvt-unicode and alacritty. + "tabdo silent !reset + silent !reset " Set the lines depending on the LINES environment variable " or through tput. " - " This is not always inherited by vim: + " This works with rxvt-unicode, but does not with alacritty. + " + " LINES is not always inherited by vim: " https://github.com/vim/vim/issues/12160 - if $LINES != "" - execute ':set lines=' . $LINES - else - let available_lines = system('tput lines') - execute ':set lines=' . available_lines - " Old, and not working approach that tries to reuse the initial height - "else - " execute ':set lines=' . lines_initial - " set lines=999 - " execute ':set lines=' . winheight(0) - 3 - endif + "if $LINES != "" + " execute ':set lines=' . $LINES + "else + " let available_lines = system('tput lines') + " execute ':set lines=' . available_lines + " " Old, and not working approach that tries to reuse the initial height + " "else + " " execute ':set lines=' . lines_initial + " " set lines=999 + " " execute ':set lines=' . winheight(0) - 3 + "endif + + " Restore the active window + call win_gotoid(l:current_win) + + " An additional, last move to the left pane + "execute ":NERDTreeFocus" + "wincmd l endfunction " }}} @@ -86,6 +112,10 @@ endfunction function RestoreWindowSizes() call FixWindowHeights() call FixAllWindowWidths() + + " An additional, last move to the left pane + execute ":NERDTreeFocus" + wincmd l endfunction " }}} |
