tabline.nvim
tabline.nvim copied to clipboard
An option to turn off show all buffers by default
In each tab I would like to see only the buffers of the current tab. I would like an option to make this the default behaviour.
Can you define “buffers of a current tab”? Currently, when you run the TablineBuffersBind … command, the file names passed into the command as arguments are stored in a global variable and that is used to keep track of the buffers in the current tab. However, if you open a buffer without using any of the tabline commands that this plugin provides, then there is no way for this plugin to know whether the buffers “belongs” to this tab or not.
There is a TablineTabNew … that does what you are asking by default. You can pass in arguments s file names to bind to that tab. Also there’s a toggle command which you can run manually or after running :tabnew yourself.
Does that help? I’m open to hearing feedback on how to improve the functionality to making it work the way you describe it.
if you open a buffer without using any of the tabline commands that this plugin provides, then there is no way for this plugin to know whether the buffers “belongs” to this tab or not.
Cannot we just hook into BufCreate autocomand and if it does not belong to the list of the current tab buffers then insert it.
I wanted to see all the buffers that were created while this tab was active not the others.
Yeah, I didn’t think of BufCreate. That’s a good idea. I can add that as a feature.
That still doesn’t help if someone wants to just open a subset of open buffers be sticky in a new separate tab.
@kdheepak is there an option to disable tabline in certain filetypes ?
Not at this point. What did you have in mind?
Not at this point. What did you have in mind?
I did wanna disable tabline in 'alpha' filetype.
You want to disable the entire tabline? Or just the buffers? One easy way to do it would be to create your own custom function that checks for the file type of the current buffer and returns an empty string when needed or calls the default tabline function and returns that output.
You want to disable the entire tabline? Or just the buffers? One easy way to do it would be to create your own custom function that checks for the file type of the current buffer and returns an empty string when needed or calls the default tabline function and returns that output.
entire tabline.
I just found tabline.nvim and thank you so much for creating it! I love how it looks and I never realised how useful it can be until I tried it.
I found that I always do :TablineToggleShowAllBuffers to isolate the buffers shown to only be what's visible in the current tab. It would be nice to make this configurable so I don't have to keep on toggling every time :)
I'm not a big fan of having all buffers visible - when I'm deep into working on a codebase, I may have as much as 30 buffers loaded, but only a handful visible. I would use something like Telescope.nvim to switch buffers instead. What's more useful for me is to have a nice way of organising tabs.
Just sharing my use case, hope it helps understand the need for it!
I tried both tabline.nvim and shadmansaleh/lualine's tabline components, but neither can provide the function as described above. I think vim's command :tabs would be helpful when implementing this function. Using :tabs, vim would list the tab pages and the windows they contain.
Here is Vim's implementaition, and here is Neovim's implementation.
I tried this:
augroup TablineBuffers
autocmd!
au! TabEnter,BufEnter * lua require('lualine-config').setTablineShowBuffers()
augroup END
and I copied the handler from the repo:
local function setTablineShowBuffers()
local data = vim.fn.json_decode(vim.g.tabline_tab_data)[vim.fn.tabpagenr()]
if(data and data.show_all_buffers) then
vim.cmd('TablineToggleShowAllBuffers')
end
end
But it doesn't work always. For example when I do "open in new tab"...
I was looking for the same feature I think the OP was describing, or at least the title of the issue suggests. My workflow is similar to what @rstacruz was describing above.
To clarify, in the current state of the plugin, all buffers are shown in the tabline by default, and, the TablineToggleShowAllBuffers is available to hide buffers (not displayed in a window) from the tabline.
What would be useful to me, would be to have an option that lets me set the opposite as the default. Meaning the tabline skips all "hidden buffers" by default, and the command TablineToggleShowAllBuffers is there to show them if I need to.
This would help me have a "clean" tabline and use some finder like Telescope or Fzf to browse through all open buffers.
Thanks for your time.
Unfortunately I'm swamped with personal life obligations and I won't be able to look into this at the moment. I am happy to review a PR, but I suspect I'll only be able to get around to this in a few months.
Thank you for taking the time to answer, and good luck with all your obligations :)
I wrote following solution and it is working for me.
local tabline = require("tabline")
tabline.setup({
enable = true,
options = {
-- If lualine is installed tabline will use separators configured in lualine by default.
-- These options can be used to override those settings.
max_bufferline_percent = 66, -- set to nil by default, and it uses vim.o.columns * 2/3
show_tabs_always = false, -- this shows tabs only when there are more than one tab or if the first tab is named
show_devicons = true, -- this shows devicons in buffer section
show_bufnr = false, -- this appends [bufnr] to buffer section,
show_filename_only = true, -- shows base filename only instead of relative path in filename
modified_icon = "+ ", -- change the default modified icon
modified_italic = false, -- set to true by default; this determines whether the filename turns italic if modified
show_tabs_only = false, -- this shows only tabs instead of tabs + buffers
},
})
vim.cmd([[
set guioptions-=e " Use showtabline in gui vim
set sessionoptions+=tabpages,globals " store tabpages and globals in session
]])
local augroup = vim.api.nvim_create_augroup("TablineBuffers", {})
function ShowCurrentBuffers()
local data = vim.t.tabline_data
if data == nil then
tabline._new_tab_data(vim.fn.tabpagenr())
data = vim.t.tabline_data
end
data.show_all_buffers = false
vim.t.tabline_data = data
vim.cmd([[redrawtabline]])
end
vim.api.nvim_create_autocmd({ "TabEnter" }, {
group = augroup,
callback = ShowCurrentBuffers,
})
Now when I create a new tab then I see only this tab's buffers starting with a single unnamed buffer that is created by default.