Skip to content

Commit 1d3f306

Browse files
committed
initial release
0 parents  commit 1d3f306

13 files changed

+898
-0
lines changed

.luarc.json

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"$schema": "https://raw.githubusercontent.com/sumneko/vscode-lua/master/setting/schema.json",
3+
"Lua.diagnostics.globals": ["packer_plugins", "P"]
4+
}

.pre-commit-config.yaml

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
repos:
3+
- repo: https://github.com/JohnnyMorganz/StyLua
4+
rev: v0.13.1
5+
hooks:
6+
- id: stylua-system

LICENSE

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2022 Gero Hillebrandt (github.com/ghillb)
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

+130
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
# Cybu.nvim
2+
3+
**_Cy_**[cle]**_bu_**[ffer]**_.nvim_** is essentially a wrapper around `:bnext` & `:bprevious`. It adds a customizable notification window, that shows the buffer in focus and its neighbors, to provide context when cycling the buffer list with the provided plugin commands / key bindings.
4+
5+
See [:help cybu.nvim](https://github.com/ghillb/cybu.nvim/blob/trunk/doc/cybu.nvim.txt) for the docs.
6+
7+
<p align="center">
8+
<img src="https://user-images.githubusercontent.com/35503959/169406683-6fb0c4dd-2083-4b9b-87b2-3928da81d472.gif" alt="demo1.gif"/>
9+
</p>
10+
11+
<details>
12+
<summary>More previews</summary>
13+
14+
<p align="center">
15+
<img src="https://user-images.githubusercontent.com/35503959/169406698-6d5e5eab-88a0-4804-a9a0-4add54d7a368.gif" alt="demo2.gif"/>
16+
</p>
17+
18+
<p align="center">
19+
<img src="https://user-images.githubusercontent.com/35503959/169406701-aabebcb5-fbcb-4f4e-b43c-ce605d77a8d7.gif" alt="demo3.gif"/>
20+
</p>
21+
22+
</details>
23+
24+
## Requirements
25+
26+
- Neovim >= 0.7.0
27+
28+
## Installation
29+
30+
### Quickstart with [packer](https://github.com/wbthomason/packer.nvim)
31+
32+
```lua
33+
use({
34+
"ghillb/cybu.nvim",
35+
branch = "v1.x", -- won't receive breaking changes
36+
-- branch = "main", -- timely updates
37+
requires = { "kyazdani42/nvim-web-devicons" }, --optional
38+
config = function()
39+
local ok, cybu = pcall(require, "cybu")
40+
if not ok then
41+
return
42+
end
43+
cybu.setup()
44+
vim.keymap.set("n", "K", "<Plug>(CybuPrev)")
45+
vim.keymap.set("n", "J", "<Plug>(CybuNext)")
46+
end,
47+
})
48+
```
49+
50+
After installing, run the `:CybuNext` or `:CybuPrev` command to cycle buffers and display the context window or use the exemplary key bindings defined above.
51+
52+
### Setup with other plugin managers
53+
54+
If you use another plugin manager, install `"ghillb/cybu.nvim"` and optionally `"kyazdani42/nvim-web-devicons"` with it, like you would with any other plugin.
55+
56+
Setup up **_Cybu_** by calling its setup function and placing the respective key bindings, which load the previous/next buffer, somewhere into your `init.lua`.
57+
58+
```lua
59+
require("cybu").setup()
60+
vim.keymap.set("n", "[b", "<Plug>(CybuPrev)")
61+
vim.keymap.set("n", "]b", "<Plug>(CybuNext)")
62+
```
63+
64+
## Configuration
65+
66+
If you want to customize the appearance and behaviour of **_Cybu_**, you can do it by adapting the configuration table.
67+
68+
```lua
69+
require("cybu").setup({
70+
position = {
71+
relative_to = "win", -- win, editor, cursor
72+
anchor = "topcenter", -- topleft, topcenter, topright,
73+
-- centerleft, center, centerright,
74+
-- bottomleft, bottomcenter, bottomright
75+
vertical_offset = 10, -- vertical offset from anchor in lines
76+
horizontal_offset = 0, -- vertical offset from anchor in columns
77+
max_win_height = 5, -- height of cybu window in lines
78+
max_win_width = 0.5, -- integer for absolute in columns
79+
-- float for relative to win/editor width
80+
},
81+
style = {
82+
path = "relative", -- absolute, relative, tail (filename only)
83+
border = "rounded", -- single, double, rounded, none
84+
separator = " ", -- string used as separator
85+
prefix = "", -- string used as prefix for truncated paths
86+
padding = 1, -- left & right padding in number of spaces
87+
devicons = {
88+
enabled = true, -- enable or disable web dev icons
89+
colored = true, -- enable color for web dev icons
90+
},
91+
highlights = { -- see highlights via :highlight
92+
current_buffer = "Visual", -- used for the current buffer
93+
adjacent_buffers = "Comment", -- used for buffers not in focus
94+
background = "Normal", -- used for the window background
95+
},
96+
},
97+
display_time = 750, -- time the cybu window is displayed
98+
exclude = { -- filetypes, cybu will not be active
99+
"neo-tree",
100+
"fugitive",
101+
"qf",
102+
},
103+
fallback = function() end, -- arbitrary fallback function
104+
-- used in excluded filetypes
105+
})
106+
```
107+
108+
## Features
109+
110+
- Adaptive size of the **_Cybu_** window
111+
- Various styling & positioning options
112+
- Exclude filetypes and define fallback
113+
- Autocmd events `CybuOpen` & `CybuClose`
114+
115+
## Breaking changes
116+
117+
If breaking changes (will be kept to a minimum) are of no concern to you, use the `main` branch. Otherwise you can use the version pinned branches, e.g. `v1.x`. These branches will only receive bug fixes and other non-breaking changes.
118+
119+
## Roadmap
120+
121+
- Improve tests, tooling and add CI
122+
- Add possibility to further customize the entry layout
123+
124+
## Testing via [plenary.nvim](https://github.com/nvim-lua/plenary.nvim)
125+
126+
Run tests with
127+
128+
```bash
129+
nvim --headless -c "PlenaryBustedDirectory tests/"
130+
```

doc/cybu.nvim.txt

+179
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,179 @@
1+
*cybu.nvim.txt* cybu.nvim for neovim 0.7.0+ Author: Gero Hillebrandt
2+
================================================================================
3+
4+
TABLE OF CONTENTS *cybu.nvim.toc*
5+
1. Introduction (|cybu.nvim|)
6+
2. Quickstart (|cybu-quickstart|)
7+
3. Configuration (|cybu-config|)
8+
4. Commands (|cybu-commands|)
9+
5. Mappings (|cybu-mappings|)
10+
6. Lua functions (|cybu-lua|)
11+
7. Auto commands (|cybu-autocmds|)
12+
13+
14+
================================================================================
15+
INTRODUCTION *cybu.nvim*
16+
17+
This plugin is essentially a wrapper around |:bnext| & |:bprevious|. It adds
18+
a customizable window, that shows the buffer in focus and its neighbors,
19+
when cycling the buffer list with the cybu commands.
20+
21+
22+
================================================================================
23+
QUICKSTART *cybu-quickstart*
24+
25+
If you just want to use Cybu.nvim with the default settings (|cybu-config|)
26+
put this into the your packer startup function:
27+
>
28+
use({
29+
"ghillb/cybu.nvim",
30+
branch = "v1.x", -- won't receive breaking changes
31+
-- branch = "main", -- branch with timely updates
32+
requires = { "kyazdani42/nvim-web-devicons" },
33+
config = function()
34+
require("cybu").setup()
35+
vim.keymap.set("n", "K", "<Plug>(CybuPrev)")
36+
vim.keymap.set("n", "J", "<Plug>(CybuNext)")
37+
end,
38+
})
39+
<
40+
If you use another plugin manager, just install `"ghillb/cybu.nvim"` with
41+
it, like you would with any other plugin and put
42+
>
43+
require("cybu").setup()
44+
vim.keymap.set("n", "K", "<Plug>(CybuPrev)")
45+
vim.keymap.set("n", "J", "<Plug>(CybuNext)")
46+
<
47+
somewhere into your |init.lua|.
48+
49+
If you want to customize the cybu settings see the |cybu-config| section.
50+
51+
52+
================================================================================
53+
CONFIG *cybu-config*
54+
55+
The table below contains all config keys with some exemplary values.
56+
>
57+
local config = {
58+
position = {
59+
relative_to = "win", -- win, editor, cursor
60+
anchor = "topcenter", -- topleft, topcenter, topright,
61+
-- centerleft, center, centerright,
62+
-- bottomleft, bottomcenter, bottomright
63+
vertical_offset = -1, -- vertical offset from anchor in lines
64+
horizontal_offset = -1, -- vertical offset from anchor in columns
65+
max_win_height = 5, -- height of cybu window in lines
66+
max_win_width = 0.5, -- integer for absolute in columns
67+
-- float for relative width to win/editor
68+
},
69+
style = {
70+
path = "relative", -- absolute, relative, tail (filename)
71+
border = "single", -- single, double, rounded, none
72+
separator = " ", -- string used as separator
73+
prefix = "…", -- string prefix for truncated paths
74+
padding = 1, -- left & right padding in nr, of spaces
75+
devicons = {
76+
enabled = true, -- enable or disable web dev icons
77+
colored = true, -- enable color for web dev icons
78+
},
79+
highlights = { -- see highlights via :highlight
80+
current_buffer = "Visual", -- used for the current buffer
81+
adjacent_buffers = "Comment",-- used for buffers not in focus
82+
background = "Normal", -- used for the window background
83+
},
84+
},
85+
display_time = 750, -- time in ms the cybu win is displayed
86+
exclude = { -- filetypes, cybu will not be active
87+
"neo-tree",
88+
"fugitive",
89+
"qf",
90+
},
91+
fallback = function() end, -- arbitrary fallback function
92+
-- used in excluded filetypes
93+
}
94+
95+
After customizing the config table, call the |cybu.setup| function somewhere
96+
in your |init.lua|, like so:
97+
>
98+
require("cybu").setup(config)
99+
<
100+
101+
================================================================================
102+
COMMANDS *cybu-commands*
103+
104+
The commands *CybuNext* & *CybuPrev* cycle to the next or previous buffer and
105+
show the context window of Cybu.nvim.
106+
107+
Example usage:
108+
>
109+
:CybuNext
110+
<
111+
or
112+
>
113+
:CybuPrev
114+
<
115+
116+
================================================================================
117+
MAPPINGS *cybu-mappings*
118+
119+
If you prefer <Plug> mappings, Cybu.nvim provides the mappings
120+
*<Plug>(CybuPrev)* and *<Plug>(CybuNext)* which yield the same behavior as
121+
|CybuNext| and |CybuPrev| respectively.
122+
123+
Example usage:
124+
>
125+
vim.keymap.set("n", "K", "<Plug>(CybuPrev)")
126+
vim.keymap.set("n", "J", "<Plug>(CybuNext)")
127+
<
128+
129+
================================================================================
130+
LUA_FUNCTIONS *cybu-lua*
131+
132+
cybu.setup({config}) *cybu.setup*
133+
134+
The |cybu.setup| function takes an {config} table as parameter containing
135+
the configuration (|cybu-config|) for |cybu.nvim|. This function must be
136+
called in your |init.lua|. The options table can be empty.
137+
138+
Example usage:
139+
>
140+
require("cybu").setup(config)
141+
<
142+
143+
cybu.cycle({direction}) *cybu.cycle*
144+
145+
Cybu.nvim provides the |cybu.cycle| lua function, which takes the {direction}
146+
parameter to load the respective buffer and show the context window.
147+
148+
Example usage:
149+
>
150+
require("cybu").cycle("next")
151+
<
152+
or
153+
>
154+
require("cybu").cycle("prev")
155+
<
156+
157+
================================================================================
158+
AUTOCOMMANDS *cybu-autocmds*
159+
160+
Cybu.nvim defines two events:
161+
162+
- `CybuOpen`, fired when the cybu window is opened
163+
- `CybuClose`, fired when the cybu window is closed
164+
165+
You can define auto commands for these events like so:
166+
>
167+
local cybu = vim.api.nvim_create_augroup("Cybu", { clear = true })
168+
vim.api.nvim_create_autocmd("User", {
169+
pattern = "CybuOpen",
170+
callback = function()
171+
-- execute arbitrary lua code here
172+
end,
173+
group = cybu,
174+
})
175+
<
176+
177+
==============================================================================
178+
179+
vim:tw=78:ts=8:ft=help:norl:

doc/tags

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<Plug>(CybuNext) cybu.nvim.txt /*<Plug>(CybuNext)*
2+
<Plug>(CybuPrev) cybu.nvim.txt /*<Plug>(CybuPrev)*
3+
CybuNext cybu.nvim.txt /*CybuNext*
4+
CybuPrev cybu.nvim.txt /*CybuPrev*
5+
cybu-autocmds cybu.nvim.txt /*cybu-autocmds*
6+
cybu-commands cybu.nvim.txt /*cybu-commands*
7+
cybu-config cybu.nvim.txt /*cybu-config*
8+
cybu-lua cybu.nvim.txt /*cybu-lua*
9+
cybu-mappings cybu.nvim.txt /*cybu-mappings*
10+
cybu-quickstart cybu.nvim.txt /*cybu-quickstart*
11+
cybu.cycle cybu.nvim.txt /*cybu.cycle*
12+
cybu.nvim cybu.nvim.txt /*cybu.nvim*
13+
cybu.nvim.toc cybu.nvim.txt /*cybu.nvim.toc*
14+
cybu.nvim.txt cybu.nvim.txt /*cybu.nvim.txt*
15+
cybu.setup cybu.nvim.txt /*cybu.setup*

0 commit comments

Comments
 (0)