|
| 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: |
0 commit comments