Open snorkysnark opened 2 years ago
This is an interesting proposal I'll definitely think about it.
You can probably catch the event with OptionSet showtabline
It seems lualine & neo(vim)s current behavior is limiting for this . Only way I can make tabline not take 1 screenline is by setting showtabline to 0 . But then nvim no longer evaluates ex[ression in &tabline so it gets locked into that state and doesn't get updated to show tabline when condition is true 🤷♂️. This does seem like a valid optimization on neo(vim)s part but limits our ability at this . The other way would be to make lualines redraw completely independent of how often statusline/tabline evaluates . I'm not yet sure if that's something worth doing just for this.
If you just want the ability to not have tabline when only one tab is present . Then you can set showtablineto 1 with autocommand. For example:
au OptionSet showtabline :set showtabline=1
You can apply cond
option per component in tabline too if you want to hide certain component based on some condition.
au OptionSet showtabline :set showtabline=1
I have tried this and it is working. Thanks.
For now I'm dropping this idea. As it's too complicated to add for too little gain for now.
I wanted to achieve the same effect as airline -- to hide tabline when there is only single buffer:
let g:airline#extensions#tabline#buffer_min_count = 2
But I don't understand how to use your workaround above to achieve the same thing. @shadmansaleh do you have any other suggestion?
Maybe simple corner case of "hide when there is only one buffer/tab" can be much more easily hacked, than the proper solution of "evaluate conditional function inside of tabline" ?
This hack does not work in neovim 0.7.0:
au OptionSet showtabline :set showtabline=1
For some reason OptionSet is not fired when lualine does it. I can set showtabline=1
manually, but when switching colorschemes it reappears. Is there any reason why we can't add an option to simply leave showtabline
alone here?
@shadmansaleh, because of not working OptionSet in neovim 0.7.0, can we reopen this feature request?
Maybe an easier approach is to let users control if we want Lualine to set showtabline=2
?
If we wrap that in an condition, it would allow users to set showtabline=1
in their config and get the default behavior of only displaying the tabline if at least two tabs exists:
'showtabline' 'stal' number (default 1)
global
The value of this option specifies when the line with tab page labels
will be displayed:
0: never
1: only if there are at least two tab pages
2: always
This is both for the GUI and non-GUI implementation of the tab pages
line.
See |tab-page| for more information about tab pages.
How #736 supports hiding the tabline conditionally? I couldn't understand from read the code.
Maybe an easier approach is to let users control if we want Lualine to set
showtabline=2
?If we wrap that in an condition, it would allow users to set
showtabline=1
in their config and get the default behavior of only displaying the tabline if at least two tabs exists:
I agree that this will be very useful as we can use whatever options vim provides by default.
If this worked then we could also hide tabline completely using showtabline=0
I added this after require("lualine").setup(...)
and it seems to work as desired:
vim.cmd("set showtabline=1")
But I agree that it would be better if Lualine didn't override the default here: https://github.com/nvim-lualine/lualine.nvim/blob/3cf45404d4ab5e3b5da283877f57b676cb78d41d/lua/lualine.lua#L472
Requested feature
In global options, add a function that is called on redraw to determine whether the tabline should be visible. For example, you can only show it if there is more than one tab/more than one buffer, etc.
Motivation
Currently, this plugin forces the tabline to be always visible, decreasing the available screen space. Since the option is set during the first redraw, I haven't found a good way to override it with autocmds. As people have different tabline configurations (with buffers and other custom components), you need a more flexible alternative to vim's showtabline=1 (that shows and hides the tabline based on tab count)