Skip to content

[very weird bug]: Newly Created Files Ignored by .gitignore Still Visible in nvim-tree #2511

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
michaelvanstraten opened this issue Nov 5, 2023 · 8 comments
Labels
awaiting feedback bug Something isn't working

Comments

@michaelvanstraten
Copy link

michaelvanstraten commented Nov 5, 2023

Description

I've come across an issue with nvim-tree, where newly created files that are meant to be ignored according to the .gitignore file are still appearing in the tree view.

Neovim version

NVIM v0.9.4
Build type: Release
LuaJIT 2.1.1696795921

Operating system and version

macOS 14.0

Windows variant

No response

nvim-tree version

master, 7e3c0be

Clean room replication

vim.g.loaded_netrw = 1
vim.g.loaded_netrwPlugin = 1

vim.cmd [[set runtimepath=$VIMRUNTIME]]
vim.cmd [[set packpath=/tmp/nvt-min/site]]
local package_root = "/tmp/nvt-min/site/pack"
local install_path = package_root .. "/packer/start/packer.nvim"
local function load_plugins()
  require("packer").startup {
    {
      "wbthomason/packer.nvim",
      "nvim-tree/nvim-tree.lua",
      "nvim-tree/nvim-web-devicons",
      -- ADD PLUGINS THAT ARE _NECESSARY_ FOR REPRODUCING THE ISSUE
    },
    config = {
      package_root = package_root,
      compile_path = install_path .. "/plugin/packer_compiled.lua",
      display = { non_interactive = true },
    },
  }
end
if vim.fn.isdirectory(install_path) == 0 then
  print "Installing nvim-tree and dependencies."
  vim.fn.system { "git", "clone", "--depth=1", "https://github.com/wbthomason/packer.nvim", install_path }
end
load_plugins()
require("packer").sync()
vim.cmd [[autocmd User PackerComplete ++once echo "Ready!" | lua setup()]]
vim.opt.termguicolors = true
vim.opt.cursorline = true

-- MODIFY NVIM-TREE SETTINGS THAT ARE _NECESSARY_ FOR REPRODUCING THE ISSUE
_G.setup = function()
  require("nvim-tree").setup {}
end

-- UNCOMMENT this block for diagnostics issues, substituting pattern and cmd as appropriate.
-- Requires diagnostics.enable = true in setup.
--[[
vim.api.nvim_create_autocmd("FileType", {
  pattern = "lua",
  callback = function()
    vim.lsp.start { cmd = { "lua-language-server" } }
  end,
})
]]

Steps to reproduce

  1. Create new git repo
cd /tmp && mkdir -p "Humboldt-Universität zu Berlin/Arbeiten" && cd "Humboldt-Universität zu Berlin/Arbeiten"
  1. Clone Repository
git clone https://github.com/michaelvanstraten/scholarly-work.git .
  1. Run Neovim with config
nvim -nu /tmp/nvt-min.lua
  1. Open nvim-tree
:NvimTreeOpen
  1. Execute from in neovim
:! touch Lineare\ Algebra\ und\ Analytische\ Geometrie\ I\*/test.pdf

Expected behavior

I expected the file tree in nvim-tree to remain unchanged, with the newly created file test.pdf hidden due to the entry in the .gitignore file.

Actual behavior

However, the actual behavior is that the file test.pdf is visible in the directory tree, despite being listed in the .gitignore file.

@michaelvanstraten michaelvanstraten added the bug Something isn't working label Nov 5, 2023
@michaelvanstraten michaelvanstraten changed the title [Very weird bug]: Newly Created Files Ignored by .gitignore Still Visible in nvim-tree [very weird bug]: Newly Created Files Ignored by .gitignore Still Visible in nvim-tree Nov 5, 2023
@michaelvanstraten
Copy link
Author

I have tried for almost an hour to get a reproducible example and I thought I found one, but I just noticed that this one does not work. I've cleaned the nvt-min directory before trying it again and notice that the example that I just tried didn't work any more.

@michaelvanstraten
Copy link
Author

Okay, this work 50% of the time now.

@alex-courtis
Copy link
Member

alex-courtis commented Nov 6, 2023

Unfortunately I'm not able to reproduce this one.

The German characters do not appear to be an issue as everything seems to be working.

I did see one strange behaviour that I could not reproduce: modifying .gitignore with the tree open, with the ignored file not appearing. That was under /tmp so I disregarded it - git and filesystem watchers do not behave well on tmpfs.

Testing in a normal filesystem directory was successful.

Suggestion: try reproducing on a regular filesystem with a very simple structure, maybe something like: #2468 (comment)

@michaelvanstraten
Copy link
Author

I was able to fix this by renaming the top level directory to something different. This also fixed some issues I was having with an LSP server.

I would prefer to leave this issue open for people who may have the same problem.

Again, I could not reproduce this reliability without literally copying the entire directory structure.

@alex-courtis
Copy link
Member

Can you please tgz the entire directory structure so that we may replicate?

Unless we can replicate this it will be closed. Closed issues may be searched and are often commented upon / reopened.

@michaelvanstraten
Copy link
Author

I will do so if I get to it. Expect it by Tuesday afternoon.

Thank you for your patience and interest.

@michaelvanstraten
Copy link
Author

Sorry for the wait.

I tried again and again at reproducing this, but I couldn't get it to reliably work, so I'm closing the issue.

Thank you for the relentless persuade to make the project better than it already is.

@alex-courtis
Copy link
Member

Sorry for the wait.

I tried again and again at reproducing this, but I couldn't get it to reliably work, so I'm closing the issue.

Thank you for the relentless persuade to make the project better than it already is.

Thanks mate.

Please do reopen if you see this again / can replicate.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting feedback bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants