aboutsummaryrefslogtreecommitdiff
path: root/vimrc.dot.link
diff options
context:
space:
mode:
authorSilvio Rhatto <rhatto@riseup.net>2024-07-28 01:52:07 -0300
committerSilvio Rhatto <rhatto@riseup.net>2024-07-28 01:52:07 -0300
commit0a1fe34d365e944f68ca26ef9ddb9ae4c9e70f0c (patch)
tree135e611b2e79af257c3e1c1171eee391cff422b3 /vimrc.dot.link
parente9f116c6bcf8683a5aacb419b8283c7c95584f6a (diff)
downloadvim-0a1fe34d365e944f68ca26ef9ddb9ae4c9e70f0c.tar.gz
vim-0a1fe34d365e944f68ca26ef9ddb9ae4c9e70f0c.tar.bz2
Fix: NERDTree and session restoration workarounds: use VimEnter instead of SessionLoadPost
Diffstat (limited to 'vimrc.dot.link')
-rw-r--r--vimrc.dot.link24
1 files changed, 23 insertions, 1 deletions
diff --git a/vimrc.dot.link b/vimrc.dot.link
index d7389dc..94bb058 100644
--- a/vimrc.dot.link
+++ b/vimrc.dot.link
@@ -435,6 +435,10 @@ set sessionoptions-=winpos
" See https://github.com/vim-scripts/vim-auto-save
"let g:auto_save = 1
+"
+" NERDTree and session restoration workarounds
+"
+
" Ensure the window has maximized height
"
" This helps restoring the window size after reopening sessions after
@@ -462,8 +466,26 @@ endfunction
" In case you want to invoke FixNERDTreeWidth explicitly
command! -bang FixNERDTreeWidth :call FixNERDTreeWidth()
+" Fix NERDTree width on all tabs
+function FixAllNERDTreeWidths()
+ " Save the last active window
+ let l:current_win = win_getid()
+
+ tabdo :call FixNERDTreeWidth()
+
+ " Restore the active window
+ call win_gotoid(l:current_win)
+
+ " An additional, last move to the left pane
+ wincmd l
+endfunction
+
" Fix all NERDTree widths afert session load
augroup workaround
autocmd!
- autocmd workaround SessionLoadPost * tabdo call FixNERDTreeWidth()
+ " This tends to fire for every buffers
+ "autocmd workaround SessionLoadPost * call FixAllNERDTreeWidths()
+
+ " This seems to fire only once
+ autocmd workaround VimEnter * call FixAllNERDTreeWidths()
augroup END