Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/roobert/bufferline-cycle-windowless.nvim
:window: A Neovim/Bufferline extension to cycle through windowless buffers to give a more traditional tab based experience
https://github.com/roobert/bufferline-cycle-windowless.nvim
Last synced: 14 days ago
JSON representation
:window: A Neovim/Bufferline extension to cycle through windowless buffers to give a more traditional tab based experience
- Host: GitHub
- URL: https://github.com/roobert/bufferline-cycle-windowless.nvim
- Owner: roobert
- Created: 2022-12-19T10:15:07.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2023-01-08T11:23:08.000Z (almost 2 years ago)
- Last Synced: 2024-07-31T20:49:49.057Z (3 months ago)
- Language: Lua
- Homepage:
- Size: 11.7 KB
- Stars: 38
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
- awesome-neovim - roobert/bufferline-cycle-windowless.nvim - A bufferline extension to cycle through windowless buffers to give a more traditional tab based experience. (Bars and Lines / Tabline)
README
# :window: Bufferline Cycle Windowless
![Screenshot](https://user-images.githubusercontent.com/226654/208528189-10984843-96cc-4e86-bcfe-efa5b4b13707.gif)
A [bufferline](https://github.com/akinsho/bufferline.nvim) extension to cycle through windowless buffers.
## :zap: Motivation
Neovims default tab-window-buffer model allows viewing open buffers in multiple windows.
This plugin helps give a more traditional behaviour for tabs by configuring the ability to skip past
buffers that are already open in an existing window. The behaviour is toggleable and
configurable to be on or off by default.## :rocket: Installation
### Lazy
```lua
{
"roobert/bufferline-cycle-windowless.nvim",
dependencies = {
{ "akinsho/bufferline.nvim" },
},
config = function()
require("bufferline-cycle-windowless").setup({
-- whether to start in enabled or disabled mode
default_enabled = true,
})
end,
},
```### Packer
```lua
use {
"roobert/bufferline-cycle-windowless.nvim",
requires = {
{ "akinsho/bufferline.nvim" },
},
setup = function()
require("bufferline-cycle-windowless").setup({
-- whether to start in enabled or disabled mode
default_enabled = true,
})
end,
}
```## :hammer_and_wrench: Usage
### Simple Example
#### Standard Neovim
``` lua
vim.api.nvim_set_keymap("n", "", "BufferLineCycleWindowlessNext",
{ noremap = true, silent = true })
vim.api.nvim_set_keymap("n", "", "BufferLineCycleWindowlessPrev",
{ noremap = true, silent = true })
vim.api.nvim_set_keymap("n", "", "BufferLineCycleWindowlessToggle",
{ noremap = true, silent = true })
```#### Lunarvim
``` lua
lvim.keys.normal_mode[""] = "BufferLineCycleWindowlessNext"
lvim.keys.normal_mode[""] = "BufferLineCycleWindowlessPrev"
lvim.keys.normal_mode[""] = "BufferLineCycleWindowlessToggle"
```### Advanced Example
This example firstly creates empty splits rather than splits with a view of the current file, and secondly, when cycling through buffers occurs it will delete the `[no file]` buffers, removing them from the buffer list / bufferline.
#### Standard Neovim
``` lua
-- open empty splits
vim.api.nvim_set_keymap("n", "|", "vsplit +enew", {})
vim.api.nvim_set_keymap("n", "_", "split +enew", {})-- since we open empty splits - clean them up as we cycle through open buffers
function ChangeTab(motion)
local last_buffer_id = vim.fn.bufnr()
local last_buffer_name = vim.fn.expand("%")if motion == "next" then
vim.cmd([[BufferLineCycleWindowlessNext]])
elseif motion == "prev" then
vim.cmd([[BufferLineCycleWindowlessPrev]])
else
error("Invalid motion: " .. motion)
return
endif last_buffer_name == "" then
vim.cmd("bd " .. last_buffer_id)
end
end-- switch through visible buffers with shift-l/h
vim.api.nvim_set_keymap("n", "", "lua ChangeTab('next')", {})
vim.api.nvim_set_keymap("n", "", "lua ChangeTab('prev')", {})
vim.api.nvim_set_keymap("n", "", "BufferLineCycleWindowlessToggle", {})-- lighten up bufferline background
lvim.builtin.bufferline = {
active = true,
options = {
separator_style = "slant",
},
highlights = {
fill = {
bg = "#252d52",
},separator_selected = {
fg = "#252d52",
},separator_visible = {
fg = "#252d52",
},separator = {
fg = "#252d52",
},buffer_visible = {
fg = "#9696ca",
bold = false,
},buffer_selected = {
fg = "#eeeeee",
bold = false,
},tab_selected = {
bold = false,
},
},
}```
#### Lunarvim
``` lua
-- open empty splits
lvim.builtin.which_key.mappings["|"] = { "vsplit +enew", "Vertical split" }
lvim.builtin.which_key.mappings["_"] = { "split +enew", "Horizontal split" }-- since we open empty splits - clean them up as we cycle through open buffers
function ChangeTab(motion)
local last_buffer_id = vim.fn.bufnr()
local last_buffer_name = vim.fn.expand("%")if motion == "next" then
vim.cmd([[BufferLineCycleWindowlessNext]])
elseif motion == "prev" then
vim.cmd([[BufferLineCycleWindowlessPrev]])
else
error("Invalid motion: " .. motion)
return
endif last_buffer_name == "" then
vim.cmd("bd " .. last_buffer_id)
end
end-- switch through visible buffers with shift-l/h
lvim.keys.normal_mode[""] = "lua ChangeTab('next')"
lvim.keys.normal_mode[""] = "lua ChangeTab('prev')"
lvim.keys.normal_mode[""] = "BufferLineCycleWindowlessToggle"-- lighten up bufferline background
lvim.builtin.bufferline = {
active = true,
options = {
separator_style = "slant",
},
highlights = {
fill = {
bg = "#252d52",
},separator_selected = {
fg = "#252d52",
},separator_visible = {
fg = "#252d52",
},separator = {
fg = "#252d52",
},buffer_visible = {
fg = "#9696ca",
bold = false,
},buffer_selected = {
fg = "#eeeeee",
bold = false,
},tab_selected = {
bold = false,
},
},
}```