nvim-neo-tree/neo-tree.nvim

BUG: Source selector tabs behaves weirdly when *it thinks* there is not enough space (while actually there is)

Open

#1286 opened on Jan 2, 2024

View on GitHub
 (6 comments) (0 reactions) (1 assignee)Lua (5,436 stars) (291 forks)batch import
bughelp wanted

Description

Did you check docs and existing issues?

  • I have read all the docs.
  • I have searched the existing issues.
  • I have searched the existing discussions.

Neovim Version (nvim -v)

NVIM v0.10.0-dev-2009+g4095b2838

Operating System / Version

Irrelevant

Describe the Bug

I have the following behaviour in neo-tree:

https://github.com/nvim-neo-tree/neo-tree.nvim/assets/32161460/5fed459a-63dd-48c2-ae82-90d492a97ffb

I know it is clearly stated it in the docs that tabs_layout work when there is more than enough space:

tabs_layout defines how the tabs are aligned inside the window when there is more than enough space.

But it is also stated in readme:

If you find anything janky, wanky, broken, or unintuitive, please open an issue so we can fix it.

So here I am :)

Screenshots, Traceback

No response

Steps to Reproduce

  1. Run neovim with repro.lua provided
  2. Toggle neo-tree
  3. Resize neo-tree window with mouse and observe that all tabs are trimmed when there are plenty amount of space

Expected Behavior

I expect the active tab to be shown without trimming and other tabs to be trimmed when there is not enough space.

Your Configuration

-- DO NOT change the paths and don't remove the colorscheme
local root = vim.fn.fnamemodify("./.repro", ":p")

-- set stdpaths to use .repro
for _, name in ipairs({ "config", "data", "state", "cache" }) do
  vim.env[("XDG_%s_HOME"):format(name:upper())] = root .. "/" .. name
end

-- bootstrap lazy

local lazypath = root .. "/plugins/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
  vim.fn.system({ "git", "clone", "--filter=blob:none", "https://github.com/folke/lazy.nvim.git", lazypath, })
end
vim.opt.runtimepath:prepend(lazypath)

-- install plugins
local plugins = {
  "folke/tokyonight.nvim",
  -- add any other plugins here
}

vim.opt.mouse = "a" -- allow the mouse to be used in neovim
vim.g.mapleader = " " -- leader is space

local neotree_config = {
  "nvim-neo-tree/neo-tree.nvim",
  dependencies = { "MunifTanjim/nui.nvim", "nvim-tree/nvim-web-devicons", "nvim-lua/plenary.nvim" },
  cmd = { "Neotree" },
  keys = {
    { "<Leader>e", "<Cmd>Neotree<CR>" }, -- change or remove this line if relevant.
  },
  opts = {
    source_selector = {
      winbar = true,
      tabs_layout = "active",
      sources = {
        {
          source = "filesystem", -- string
          display_name = " 󰉓 Files " -- string | nil
        },
        {
          source = "buffers", -- string
          display_name = " 󰈚 Buffers " -- string | nil
        },
        {
          source = "git_status", -- string
          display_name = " 󰊢 Git " -- string | nil
        },
        {
          source = "diagnostics", -- string
          display_name = " Diagnostics  " -- string | nil
        },
      }
    },
  },
}

table.insert(plugins, neotree_config)
require("lazy").setup(plugins, {
  root = root .. "/plugins",
})

vim.cmd.colorscheme("tokyonight")
-- add anything else here

Contributor guide