Comments (11)
@siduck76 I've already started some work over in #179 I'm probably not going to go with the structure above since that is way more work/complexity i.e. hiding buffers and then trying to add a new secondary UI. The main way this is probably going to work will be different highlighting/icons for grouped buffers and just as a visual indicator, I might also allow some custom separator e.g. a space or divider between groups or a sort of header tab.
Anyway I'm trying to keep the initial implementation lean so won't be adding a bunch of complexity otherwise chances are I'll never finish anyway. You can have a look at that PR to see where it's at. It's not fully documented yet though
from bufferline.nvim.
Hi @akinsho & @siduck76,
I thought I might explain my implementation a little, though mine clearly has flaws with it's implementation as it is currently. (I intend to improve it after my exams soon!)
On Terminal creation,
- set a local terminal variable
term_type
to indicate that this is amanaged term
&what kind of window the user created the term as
- Eg:
map("n", "<leader>w", ":execute 'terminal' | let b:term_type = 'wind' | startinsert <CR>", opt)
- Eg:
map("n", "<leader>v", ":execute 'vnew +terminal' | let b:term_type = 'vert' | startinsert <CR>", opt)
- Eg:
- This could probably be done with an autocommand instead
This code is an edited excerpt from here
Closing buffers
There are several implementation choices to make:
- Re-map locally (in any term buffer), the normal close buffer keybind, to instead
hide a term
- Re-map globally your close buffer keybind to a function, part of this function
hide the term
- There is likely some way to hijack
:bd!
or similar with an autocommand?
We implemented # 2
map("n", "<leader>x", ":lua require('utils').close_buffer() <CR>", opt) -- close buffer
This code is an edited excerpt from here
This code is an edited excerpt from here
What hiding a term means
close_buffer()
local chad_term, type = pcall(function()
-- try to get our special buffer variable
return vim.api.nvim_buf_get_var(buf, "term_type")
end)
if chad_term then
-- this is a managed terminal!
if type == "wind" then
-- hide from bufferline
vim.cmd(string.format("%d bufdo setlocal nobl", buf))
-- swtich to another buff
vim.cmd "BufferLineCycleNext"
else
-- this is instead a split window term
local cur_win = vim.fn.winnr()
-- we can close this window
vim.cmd(string.format("%d wincmd c", cur_win))
return
end
else
-- normally close this buffer
vim.cmd(string.format("bd! %d", buf))
end
This code is an edited excerpt from here
How to bring back / show a term
As this implementation is designed to created many terms (instead of toggleterm.nvim
's approach),
we now need some kind of selector to choose what term to show again
.
I've decided to use a Telescope picker
, as that already has many in-built tools and can live-preview buffers
.
The general idea behind the picker:
- only show our managed terminal buffers
- only show hidden buffers
- on selection, checks local buffer var
term_type
to see how best to re-show the terminal in a window
-- for a window term, create a new window and set it to listed to show on thebufferline
-- for a split term, create a split with the selected term
if chad_term then
if type == "wind" then
-- swtich to term buff & show in bufferline
vim.cmd(string.format("b %d | setlocal bl", buf))
elseif type == "vert" then
vim.cmd(string.format("vsp #%d", buf))
elseif type == "hori" then
vim.cmd(string.format("15 sp #%d ", buf))
end
This code is an edited excerpt from here
I hope this helps, or is at least curious.
I'm more than happy to explain more, and it's totally understandable if you completely disagree with my implementation 😆
I am by all means new to plugin & proper NeoVim modification!
G
from bufferline.nvim.
closed by #179
from bufferline.nvim.
@CooperAnderson potentially the filtering you had in your PR could be done on top of this e.g. certain groups could be assigned to specific tabs etc., thoughts?
from bufferline.nvim.
Is there any updates on buffer groups?
from bufferline.nvim.
Nope. Haven't looked into it properly. A big part of the way centaur-tabs does it is that it can render the UI in a way that can't really be achieved in nvim so not super clear how this would look.
It's also a non-trivial amount of work I don't currently have time for.
from bufferline.nvim.
Nope. Haven't looked into it properly. A big part of the way centaur-tabs does it is that it can render the UI in a way that can't really be achieved in nvim so not super clear how this would look.
It's also a non-trivial amount of work I don't currently have time for.
Idk if this sounds dumb lol , maybe you can use one buffer for grouping multiple buffers and pressing a mapping when you're in the group buffer will open a lil popup over the bottom of the grouped buffer and cycling within the popup ( of grouped buffer ) with a mapping.
from bufferline.nvim.
@akinsho My friend has added a PR to NvChad (my config) which lets me hide/unhide specific terminal buffers through telescope.Idk if this would be useful but you could implement the same with hiding buffers and unhiding them through telescope or any other floating window like thing
from bufferline.nvim.
I'm sure I understand tbh or if it relates to this particular functionality at all really.
from bufferline.nvim.
@G-Rowell thanks for explaining the terminal functionality referenced above. Just to clarify, I think there's generally a bit of confusion about what this issue is about and what the related PR will do. It doesn't have anything to do with hiding buffers or toggling things or secondary UI's. The buffer group logic is a mechanism for users to specify how buffers get grouped, things like highlights and icons for a group and exposes functionality for interacting with a group e.g. all test files are grouped or all files matching some other criteria can be grouped and then closed together, or opened in splits all at once.
I don't think most of the recent comments really relate to this issue, just to be clear.
from bufferline.nvim.
Yeah, my apologies, I barely got any sleep last night 😢
I was mainly trying to supplement SiDuck's answer.
I'm slightly more awake now and agree, it's quite irrelevant.
Sorry, my bad 😆
Let me know if you want me to ping you if I do get bufferline grouping working
from bufferline.nvim.
Related Issues (20)
- [Bug]: attempt to call field 'setup' (a nil value) HOT 4
- [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 18
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.