Skip to content

nvim-tree opening when editing non existant file with open_on_setup_file = false #1663

Closed
@LordMZTE

Description

@LordMZTE

Description

When starting nvim with the config below editing an empty/new file (nvim empty-file.txt), nvim tree will open despite the config saying it shouldn't.

Neovim version

NVIM v0.8.0-dev-1121-g10196f1b46
Build type: RelWithDebInfo
LuaJIT 2.1.0-beta3

Operating system and version

Linux 6.0.1-arch2-1

nvim-tree version

c995ce0

Minimal config

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 {
    open_on_setup = true,
    open_on_setup_file = false,
  }
end

Steps to reproduce

  1. nvim some-empty-or-nonexistant-file
  2. tree opens

Expected behavior

The tree stays close an the file is opened

Actual behavior

The tree opens despite a file being edited

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions