From d77f88995f3b4485bbf79ea9056c79541751baf5 Mon Sep 17 00:00:00 2001 From: Silvio Rhatto Date: Sun, 28 Jul 2024 10:30:49 -0300 Subject: Fix: run FixAllNERDTreeWidths() only once --- vim.dot.link/filetype.vim | 2 +- vim.dot.link/plugin/nerdtree_workarounds.vim | 16 ++++++++++++---- 2 files changed, 13 insertions(+), 5 deletions(-) (limited to 'vim.dot.link') diff --git a/vim.dot.link/filetype.vim b/vim.dot.link/filetype.vim index 6679641..9204987 100644 --- a/vim.dot.link/filetype.vim +++ b/vim.dot.link/filetype.vim @@ -1,7 +1,7 @@ " Vim support file to detect file types if exists("did_load_filetypes") - finish + finish endif " Markdown diff --git a/vim.dot.link/plugin/nerdtree_workarounds.vim b/vim.dot.link/plugin/nerdtree_workarounds.vim index d0d682e..a78ed0c 100644 --- a/vim.dot.link/plugin/nerdtree_workarounds.vim +++ b/vim.dot.link/plugin/nerdtree_workarounds.vim @@ -32,6 +32,11 @@ command! -bang FixNERDTreeWidth :call FixNERDTreeWidth() " Fix NERDTree width on all tabs function FixAllNERDTreeWidths() + " Make sure to run this only once + if exists("did_fixed_nerdtree_widths") + return + endif + " Save the last active window let l:current_win = win_getid() @@ -42,14 +47,17 @@ function FixAllNERDTreeWidths() " An additional, last move to the left pane wincmd l + + let dir_fixed_nerdtree_widths=1 endfunction " Fix all NERDTree widths afert session load augroup workaround autocmd! - " This tends to fire for every buffers - "autocmd workaround SessionLoadPost * call FixAllNERDTreeWidths() + " This tends to fire for every buffer + autocmd workaround SessionLoadPost * call FixAllNERDTreeWidths() - " This seems to fire only once - autocmd workaround VimEnter * call FixAllNERDTreeWidths() + " This seems to fire only once, but even when there's no session to be + " restored. + "autocmd workaround VimEnter * call FixAllNERDTreeWidths() augroup END -- cgit v1.2.3