Skip to content

Tab title left as NvimTree_1 when file opened in new tab #1769

Closed

Description

@sarahkittyy

Description

2022-11-22.17-55-57.mp4

Opening a new file by hitting t leaves NvimTree_X as the tab title.

Currently, I use autocmd BufLeave NvimTree* wincmd l, which moves the cursor from the tree buffer when switching tabs, so that the title changes to the actual buffer I'm working on.

This doesn't work when first hitting t to open the file in a new tab.

How can I make nvimtree not show up in the tab title? It's helpful to be able to see

Neovim version

NVIM v0.8.0-dev-1178-g1d337d4e2
Build type: Release
LuaJIT 2.1.0-beta3

Operating system and version

Linux sarah-pc 5.10.43.3-microsoft-standard-WSL2 #1 SMP Wed Jun 16 23:47:55 UTC 2021 x86_64 GNU/Linux

nvim-tree version

68a2a09

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 {
	view = {
		mappings = {
			list = {
				{ key = "t",                        action = "tabnew" },
			}
		}
	}
  }
end

Steps to reproduce

  1. nvim -nu nvt-min.lua
  2. :NvimTreeOpen
  3. Open one file with <CR>
  4. Open another file with t

Expected behavior

The tab with the first file opened should contain the name of the opened file.

Actual behavior

The tab title contains NvimTree_1

Activity

  1. alex-courtis commented on Nov 26, 2022

    @alex-courtis
    Member

    This is working as expected: vim shows a truncated buffer name for the focused window when &tabline is not set. In this case the focused window is nvim-tree and thus its name is shown.

    How can I make nvimtree not show up in the tab title? It's helpful to be able to see

    This might not be useful: the tab's title would be empty.

    There are also some logical difficulties here: what happens when nvim-tree is the only window in the tab?

    Suggestion: create a custom action. See :help nvim-tree-mappings and :help nvim-tree.api.node.

    1. change focus to the window you wish to appear in the title
    2. invoke Api.node.open.tab for the node
  2. alex-courtis commented on Nov 26, 2022

    @alex-courtis
    Member

    It would be fantastic if you could add your solution to the wiki Recipes page.

    Moving to discussions as this is not a bug.

  3. locked and limited conversation to collaborators on Nov 26, 2022
  4. converted this issue into a discussion #1774 on Nov 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions