romgrk / barbar.nvim

The neovim tabline plugin.
2.2k stars 81 forks source link

Integration with filetree plugins doesn't work properly #407

Closed bavo96 closed 1 year ago

bavo96 commented 1 year ago

I use the below code to integrate with filetree plugins:

vim.api.nvim_create_autocmd('FileType', {
  callback = function(tbl)
    local set_offset = require('barbar.api').set_offset

    local bufwinid
    local last_width
    local autocmd = vim.api.nvim_create_autocmd('WinScrolled', {
      callback = function()
        bufwinid = bufwinid or vim.fn.bufwinid(tbl.buf)

        local width = vim.api.nvim_win_get_width(bufwinid)
        if width ~= last_width then
          set_offset(width, 'FileTree')
          last_width = width
        end
      end,
    })

    vim.api.nvim_create_autocmd('BufWipeout', {
      buffer = tbl.buf,
      callback = function()
        vim.api.nvim_del_autocmd(autocmd)
        set_offset(0)
      end,
      once = true,
    })
  end,
  pattern = 'NvimTree', -- or any other filetree's `ft`
})

But I got a strange behavior:

https://user-images.githubusercontent.com/27908949/229306920-e6fac00c-542e-4872-b970-148301d527c4.mp4

At first, the FileTree name doesn't exist. After I start srcolling, it shows up. I want it to show up at the very beginning when I start Neovim.

Iron-E commented 1 year ago

Try #395 instead— we're looking at setting up all that for you.

bavo96 commented 1 year ago

I have tried the configuration, but nothing seems to be done: image image

Iron-E commented 1 year ago

Just to be clear, what file tree are you using?

bavo96 commented 1 year ago

I'm using nvim-tree as my filetree https://github.com/nvim-tree/nvim-tree.lua.

bavo96 commented 1 year ago

Sorry for my mistake, forgot to check that this setting will be apply when the PR is merged. Waiting for (#395) and thank you for you lightning speed reply :D

Iron-E commented 1 year ago

So #395 works when you switch to that branch? Just want to make sure

bavo96 commented 1 year ago

I've tried feat/391 and I don't know if this behavior is normal. When I open nvim it looks like this (still doesn't show the filetree name): image And when I open a file, it shows up but doesn't have any text on it: image

Iron-E commented 1 year ago

We removed the text, since it's possible to have multiple sidebars open (e.g. a filetree, symbols-outline, undotree, etc) but I'll take a look at it not setting the offset when Neovim opens.

bavo96 commented 1 year ago

Many thanks for your help :D I've noticed that when I use macOS, everything shows up normally but when I'm on Ubuntu, the behavior is as previous comment.

image

And I think it would be great if there's a way that I can write name for filetree by myself :D

Iron-E commented 1 year ago

What is your nvim-tree config?