aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSilvio Rhatto <rhatto@riseup.net>2024-07-28 09:09:51 -0300
committerSilvio Rhatto <rhatto@riseup.net>2024-07-28 09:09:51 -0300
commitcbd12218a4f578b415d5a7da40275ad450e0ec64 (patch)
tree3db32414bf0b4b7605f99fdaa62fba8a3f327696
parent0a1fe34d365e944f68ca26ef9ddb9ae4c9e70f0c (diff)
downloadvim-cbd12218a4f578b415d5a7da40275ad450e0ec64.tar.gz
vim-cbd12218a4f578b415d5a7da40275ad450e0ec64.tar.bz2
Fix: move NERDTree workarounds to a plugin
-rw-r--r--vim.dot.link/plugin/nerdtree_workarounds.vim55
-rw-r--r--vimrc.dot.link55
2 files changed, 55 insertions, 55 deletions
diff --git a/vim.dot.link/plugin/nerdtree_workarounds.vim b/vim.dot.link/plugin/nerdtree_workarounds.vim
new file mode 100644
index 0000000..d0d682e
--- /dev/null
+++ b/vim.dot.link/plugin/nerdtree_workarounds.vim
@@ -0,0 +1,55 @@
+" nedtree_workaroungs.vim - NERDTree and session restoration workarounds
+"
+" Author: Silvio Rhatto <rhatto@riseup.net>
+"
+
+" Ensure the window has maximized height
+"
+" This helps restoring the window size after reopening sessions after
+" switching monitors (like from laptop screen to external HDMI monitor).
+"
+" https://superuser.com/questions/140419/how-to-start-gvim-maximized
+" https://vim.fandom.com/wiki/Maximize_or_set_initial_window_size
+set lines=999
+
+" Fix NERDTree width
+"
+" Useful after restoring sessions between screen size changes (such
+" as when you share sessions between different computers).
+function FixNERDTreeWidth()
+ " Make sure NERDTree is focuses
+ execute ":NERDTreeFocus"
+
+ " Set a fixed width
+ execute ":vertical resize 30"
+
+ " Move to the left pane
+ wincmd l
+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!
+ " 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
diff --git a/vimrc.dot.link b/vimrc.dot.link
index 94bb058..c2454bf 100644
--- a/vimrc.dot.link
+++ b/vimrc.dot.link
@@ -434,58 +434,3 @@ set sessionoptions-=winpos
" Autosave
" 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
-" switching monitors (like from laptop screen to external HDMI monitor).
-"
-" https://superuser.com/questions/140419/how-to-start-gvim-maximized
-" https://vim.fandom.com/wiki/Maximize_or_set_initial_window_size
-set lines=999
-
-" Fix NERDTree width
-"
-" Useful after restoring sessions between screen size changes (such
-" as when you share sessions between different computers).
-function FixNERDTreeWidth()
- " Make sure NERDTree is focuses
- execute ":NERDTreeFocus"
-
- " Set a fixed width
- execute ":vertical resize 30"
-
- " Move to the left pane
- wincmd l
-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!
- " 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