]> gitweb.fluxo.info Git - rhatto/dotfiles/vim.git/commitdiff
Fix: session_workarounds: improvements; alacritty support master
authorSilvio Rhatto <rhatto@riseup.net>
Thu, 25 Dec 2025 00:52:20 +0000 (21:52 -0300)
committerSilvio Rhatto <rhatto@riseup.net>
Thu, 25 Dec 2025 00:52:20 +0000 (21:52 -0300)
vim.dot.link/plugin/session_workarounds.vim

index 75d59cbce66bf56c70e15db9a84b312bf8a55821..af329255bfab7a3c78b1d4080ef1c0dd1ab57717 100644 (file)
@@ -25,8 +25,10 @@ command! -bang FixWindowWidths :call FixWindowWidths()
 " Fix window widths on all tabs {{{
 function FixAllWindowWidths()
   " Make sure to run this only once
 " 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
     return
+  else
+    let g:did_fix_window_widths=1
   endif
 
   " Save the last active window
   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
   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
 " }}}
 
 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()
 " 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.
   "
 
   " 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
   " 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
 " }}}
 
 endfunction
 " }}}
 
@@ -86,6 +112,10 @@ endfunction
 function RestoreWindowSizes()
   call FixWindowHeights()
   call FixAllWindowWidths()
 function RestoreWindowSizes()
   call FixWindowHeights()
   call FixAllWindowWidths()
+
+  " An additional, last move to the left pane
+  execute ":NERDTreeFocus"
+  wincmd l
 endfunction
 " }}}
 
 endfunction
 " }}}