From cfcdcb63bd75fd4d896cb251daad697930dcf1c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sindre=20T=2E=20Str=C3=B8m?= Date: Sun, 30 May 2021 19:15:26 +0200 Subject: [PATCH] fix: Gitignore rules not being applied on new nodes. Reload git roots before refreshing nodes so that the gitignore map is updated, and ignore rules are applied correctly on refresh_entries. --- lua/nvim-tree/config.lua | 6 ++++++ lua/nvim-tree/lib.lua | 8 +++----- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/lua/nvim-tree/config.lua b/lua/nvim-tree/config.lua index 553754e50ba..195db4ed632 100644 --- a/lua/nvim-tree/config.lua +++ b/lua/nvim-tree/config.lua @@ -64,6 +64,12 @@ function M.get_icon_state() } end +function M.use_git() + return M.get_icon_state().show_git_icon + or vim.g.nvim_tree_git_hl == 1 + or vim.g.nvim_tree_gitignore == 1 +end + function M.nvim_tree_callback(callback_name) return string.format(":lua require'nvim-tree'.on_keypress('%s')", callback_name) end diff --git a/lua/nvim-tree/lib.lua b/lua/nvim-tree/lib.lua index c88cf035f00..c3d584a8ad5 100644 --- a/lua/nvim-tree/lib.lua +++ b/lua/nvim-tree/lib.lua @@ -152,12 +152,10 @@ end function M.refresh_tree() if vim.v.exiting ~= vim.NIL then return end + local use_git = config.use_git() + if use_git then git.reload_roots() end refresh_nodes(M.Tree) - - if config.get_icon_state().show_git_icon or vim.g.nvim_tree_git_hl == 1 then - git.reload_roots() - refresh_git(M.Tree) - end + if use_git then refresh_git(M.Tree) end if vim.g.nvim_tree_lsp_diagnostics == 1 then diagnostics.update()