From 9aed1acb475dbebafa5e82949ee94787737e3a43 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sindre=20T=2E=20Str=C3=B8m?= Date: Mon, 31 May 2021 09:12:59 +0200 Subject: [PATCH] fix: Gitignore rules not being applied on new nodes. (#415) --- 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 553754e5..195db4ed 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 c88cf035..c3d584a8 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()