Closed FahimAnayet closed 1 year ago
If I use the following code in barbar instead, it's works fine.
local function is_neotree_open()
for _, win in ipairs(vim.api.nvim_tabpage_list_wins(0)) do
if vim.api.nvim_buf_get_option(vim.api.nvim_win_get_buf(win), 'ft') == 'neo-tree' then
return require 'bufferline.api'.set_offset(35, 'FileTree')
end
end
return require 'bufferline.api'.set_offset(0)
end
vim.api.nvim_create_autocmd({ 'BufWinEnter', 'BufWipeout' }, {
pattern = '*',
callback = function()
is_neotree_open()
end
})
Thanks.
is there a way to make this dynamic? to somehow get the current width of neo tree?
@FahimAnayet can you try #360 to see if that also works with neo-tree?
@szechp since there is no WinResized
event (yet), the only way to accomplish that would be to write a window resize command that then updates the number for require 'bufferline.api'.set_offset(35, 'FileTree')
.
@Iron-E unfortunately #360 doesn't work with the given instructions with neo-tree either. The main problem is neo-tree doesn't leave rather it just wipes out the buffer. So, if we use the following
-- Doesn't work
vim.api.nvim_create_autocmd('BufWinEnter', {
callback = function(tbl)
if vim.bo[tbl.buf].filetype == 'NvimTree' then
require'bufferline.api'.set_offset(31, 'FileTree')
end
end
})
vim.api.nvim_create_autocmd('BufWinLeave', {
callback = function(tbl)
if vim.bo[tbl.buf].filetype == 'NvimTree' then
require'bufferline.api'.set_offset(0)
end
end
})
-- Does work
vim.api.nvim_create_autocmd('BufWinEnter', {
callback = function(tbl)
if vim.bo[tbl.buf].filetype == 'NvimTree' then
require'bufferline.api'.set_offset(31, 'FileTree')
end
end
})
vim.api.nvim_create_autocmd('BufWipeout', {
callback = function(tbl)
if vim.bo[tbl.buf].filetype == 'NvimTree' then
require'bufferline.api'.set_offset(0)
end
end
})
then #360 certainly does work. So, For neo-tree we must use BufWipeout instead of BufWinLeave.
I updated the PR to include the BufWipeout
event, thanks for the feedback.
is there a way to make this dynamic? to somehow get the current width of neo tree?
Hey buddy, can your current configuration dynamically obtain the width of the neo-tree?
is there a way to make this dynamic? to somehow get the current width of neo tree?
Hey buddy, can your current configuration dynamically obtain the width of the neo-tree?
After closing neotree file tree offset stays there.
barbar config. Everything is default except following
neo-tree config
video for better understanding
https://user-images.githubusercontent.com/48918937/213254266-cb26584f-7663-430f-b3dd-84c7c8d75b35.mov