nvim-neo-tree / neo-tree.nvim

Neovim plugin to manage the file system and other tree like structures.
MIT License
3.95k stars 227 forks source link

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

Open sahinakkaya opened 11 months ago

sahinakkaya commented 11 months ago

Did you check docs and existing issues?

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
pysan3 commented 8 months ago

Fixed! Your issue was VERY easy to read and replicate. Thank you so much!

sahinakkaya commented 8 months ago

I'm glad I could have helped. And thank you for the fix! :heart:

sahinakkaya commented 8 months ago

Hey @pysan3, I just got a chance to test this. I think it fixes the half of the problem.

Expected Behavior

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

Currently, it trims active tab with all other tabs. Is it too hard to achieve what I want?

pysan3 commented 8 months ago

I know what you are trying say. It's fixable but I'm currently busy on other tasks and went with the easiest fix.

I promise I come back to this issue ;)

sahinakkaya commented 6 months ago

Hey @pysan3, I wonder if you are still busy with other things or you forgot about this. If latter, consider this as a friendly ping :)

pysan3 commented 6 months ago

Hi, thanks for the notification.

Well unfortunately it's my time constraints... I'm now focusing on the performance improvements that should affect most people and I don't think I can come back to this issue until that's finished.

As always, contributions are welcome!