romgrk / barbar.nvim

The neovim tabline plugin.
2.29k stars 85 forks source link

Integration with fern.vim #274

Closed OddBread closed 2 years ago

OddBread commented 2 years ago

Sorry if it's a dumb question, but i'm trying to set up barbar alongside a file manager, fern https://github.com/lambdalisue/fern.vim. I noticed the plugin has support for moving alongside nvimtree, but i'm not entirely sure what needs to be changed if i want to use it with fern instead, since the code you provided seems to be specifically built for nvimtree. How would i go about using it for fern instead of nvim tree? Thank you in advance.

Iron-E commented 2 years ago

I would use this snippet:

vim.api.nvim_create_autocmd('BufWinEnter', {
  pattern = '*',
  callback = function()
    if vim.bo.filetype == 'NvimTree' then
      require'bufferline.state'.set_offset(31, 'FileTree')
    end
  end
})

vim.api.nvim_create_autocmd('BufWinLeave', {
  pattern = '*',
  callback = function()
    if vim.fn.expand('<afile>'):match('NvimTree') then
      require'bufferline.state'.set_offset(0)
    end
  end
})

The only thing that needs to be changed is the 'NvimTree' string. You'll need to enter the fern window, and then run :echo &filetype. Replace 'NvimTree' with whatever is output.

OddBread commented 2 years ago

This worked, thank you so much. For anyone looking for this, the &filetype output is just 'fern'.