Comments (7)
Thank you. It works. Bufferline is perfect now haha. You can close this issue if you want.
from bufferline.nvim.
So I figured out that bufferline depends in a weird way on the showtabline
setting. I partially achieved my goal with the following autocmd:
autocmd group vimenter,bufadd * if len(getbufinfo({'buflisted':1})) > 1 | set showtabline=2
autocmd group bufdelete * if len(getbufinfo({'buflisted':1})) < 2 | set showtabline=1
The first autocmd works. It I open nvim with only one buffer the bufferline is not shown. It I then open a second buffer the bufferline is shown.
The second autocmd does not work for some reason. If I close the second buffer then the bufferline is still shown. If I then set manually set showtabline=1
it isnt shown anymore.
from bufferline.nvim.
Minimal vimrc
set runtimepath+=~/.local/share/nvim/plugins/nvim-bufferline.lua/
autocmd bufadd,vimenter * if len(getbufinfo({'buflisted':1})) > 1 | set showtabline=2 | endif
autocmd bufdelete * if len(getbufinfo({'buflisted':1})) < 2 | set showtabline=1 | endif
lua require'bufferline'.setup()
set showtabline=1
For some reason it doesn't work if I put set showtabline=1
before lua require'bufferline'.setup()
from bufferline.nvim.
@astier thanks for trying out the plugin 👍🏿 .
I use the showtabline
function primarily because it's the only way in vim to specify tabline visibility even though it was originally intended for use with tabs rather than buffers so the showtabline
setting doesn't really apply in the same way. 2
makes it show all the time and 1
makes it show if there are 2 or more tab pages
rather than buffers specifically.
To add something like that it would need to have specific logic. Tbh I personally don't think I'd ever use such an option but if you'd like to have a go at implementing it I'd be fine with that, if it didn't add too much complexity.
I think re implementation you'd need to pass in another option in the user config passed to the setup
and then register some autocommands to watch BufEnter
(or something) and check the bufferlist and if it's ever less than 2 then hide the line by setting showtabline=0
from bufferline.nvim.
I find it just weird that I am able to toggle bufferline by setting showtabline
manually. However, it doesn't work with the bufdelete autocmd. Do you have a clue why? I understand how showtabline
works and its purpose. If it would work with the bufdelete autocmd the issue would be pretty much fixed.
Or maybe it would be easier to offer a command to toggle the bufferline. Then instead of changing showtabline
I would call the command with the autocmds.
from bufferline.nvim.
Also I think my proposed solution would be very consistent. Since showtabline
is by default 1 and will only be set to 2 if a second buffer is added bufferline would show up if:
- 1 buffer open, 2+ tabs open
- 2+ buffers open, 1 tab open
- 2+ buffers open, 2+ tabs open
Since the bufdelete-autocmd would set showtabline back to 1 bufferline would always disappear if:
- 1 buffer open, 1 tab open
This would be my expected behavior. The only problem is for some reason bufferline does ignore showtabline
if it is set after bufdelete.
from bufferline.nvim.
@astier the issue with the autocommands you posted is that BufDelete
is called before the buffer is actually deleted. so the buffer list number will still be greater than 1. A way that I managed to get it to work is by tweaking you autocommand a little
" I minus the list length by one since it's going to be one down once the buffer is actually deleted
" alternatively you could just add an else clause to your BufEnter autocommand
autocmd BufDelete * if len(getbufinfo({'buflisted':1})) -1 < 2 | set showtabline=1 | endif
lightline bufferline uses a similar solution
Regarding an option within the plugin itself your proposed solution looks fine as long as it still behaves the same way it currently does by default, I'd much rather this was an opt in feature.
from bufferline.nvim.
Related Issues (20)
- [Bug]: With bufferline and telescope, buffers open in Insert (a) mode
- [Bug]: Icon bg colour not correct HOT 1
- [Bug]: (UNKNOWN PLUGIN): Error executing lua: attempt to call a number value HOT 5
- [Feature Request]: Text alignment in buffer tabs HOT 2
- [Bug]: offset doesn't work with neo-tree HOT 1
- [Bug]: Highlight "buffer" doesn't work
- [Bug]: Bufferline sets `showtabline=2` HOT 24
- Is it possible to ignore certain buffers in the bufferline, like terminal buffers for example? HOT 1
- [Feature Request]: A way to retrieve a buffer's `current_index` HOT 2
- [Bug]: Styling filetype icon for all filetypes not working/possible HOT 4
- [Bug]: (UNKNOWN PLUGIN): Error executing lua: attempt to call a nil value HOT 1
- [Feature Request]: Ability to pin all open buffers HOT 2
- Some common questions HOT 1
- [Feature Request]: I'd like to close only the current tab. HOT 6
- E5108 error in bufferline.nvim HOT 23
- [Bug]: vim.tbl_isarray is deprecated, use vim.isarray instead HOT 3
- [Bug]: FIx for LazyVim users who can't open mutltiple bufers HOT 2
- [Bug]: the example Custom Area from the documentation can be improved
- [Bug]: E5108: Error executing lua after upgrade to nvim 0.10.0 HOT 19
- [Bug]: deprecation check with is_list does not cover new nightly v0.11 HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from bufferline.nvim.