All Projects → jose-elias-alvarez → buftabline.nvim

jose-elias-alvarez / buftabline.nvim

Licence: Unlicense license
A low-config, minimalistic buffer tabline Neovim plugin written in Lua.

Programming Languages

lua
6591 projects

Projects that are alternatives of or similar to buftabline.nvim

Vim Ghost
Vim/Nvim client for GhostText - Edit browser text areas in Vim/Neovim
Stars: ✭ 245 (+231.08%)
Mutual labels:  neovim-plugin
auto-session
A small automated session manager for Neovim
Stars: ✭ 688 (+829.73%)
Mutual labels:  neovim-plugin
skim.vim
vim support for skim
Stars: ✭ 127 (+71.62%)
Mutual labels:  neovim-plugin
sphinx.nvim
Sphinx integrations for Neovim
Stars: ✭ 64 (-13.51%)
Mutual labels:  neovim-plugin
cmp-tmux
Tmux completion source for nvim-cmp and nvim-compe
Stars: ✭ 98 (+32.43%)
Mutual labels:  neovim-plugin
fwatch.nvim
fwatch.nvim lets you watch files or directories for changes and then run vim commands or lua functions.
Stars: ✭ 57 (-22.97%)
Mutual labels:  neovim-plugin
Indent Blankline.nvim
Indent guides for Neovim
Stars: ✭ 203 (+174.32%)
Mutual labels:  neovim-plugin
nvim-lsp-ts-utils
Utilities to improve the TypeScript development experience for Neovim's built-in LSP client.
Stars: ✭ 437 (+490.54%)
Mutual labels:  neovim-plugin
vim-readme-viewer
📖 Viewing plugin's README easily like vim help
Stars: ✭ 26 (-64.86%)
Mutual labels:  neovim-plugin
stable-windows
Keeps vim windows stable on layout changes
Stars: ✭ 41 (-44.59%)
Mutual labels:  neovim-plugin
qf helper.nvim
A collection of improvements for the quickfix buffer
Stars: ✭ 70 (-5.41%)
Mutual labels:  neovim-plugin
package-info.nvim
✍️ All the npm/yarn commands I don't want to type
Stars: ✭ 248 (+235.14%)
Mutual labels:  neovim-plugin
bad-practices.nvim
A plugin to help give up bad practices in vim.
Stars: ✭ 41 (-44.59%)
Mutual labels:  neovim-plugin
Coc.nvim
Nodejs extension host for vim & neovim, load extensions like VSCode and host language servers.
Stars: ✭ 18,268 (+24586.49%)
Mutual labels:  neovim-plugin
persistence.nvim
💾 Simple session management for Neovim
Stars: ✭ 238 (+221.62%)
Mutual labels:  neovim-plugin
Vim Vsnip
Snippet plugin for vim/nvim that supports LSP/VSCode's snippet format.
Stars: ✭ 224 (+202.7%)
Mutual labels:  neovim-plugin
nvim-config
My neovim config
Stars: ✭ 63 (-14.86%)
Mutual labels:  neovim-plugin
trouble.nvim
🚦 A pretty diagnostics, references, telescope results, quickfix and location list to help you solve all the trouble your code is causing.
Stars: ✭ 2,663 (+3498.65%)
Mutual labels:  neovim-plugin
modes.nvim
Prismatic line decorations for the adventurous vim user
Stars: ✭ 299 (+304.05%)
Mutual labels:  neovim-plugin
nvim-cheat.sh
cheat.sh integration for neovim in elegant way
Stars: ✭ 130 (+75.68%)
Mutual labels:  neovim-plugin

ARCHIVED

I'm no longer using buftabline.nvim and don't plan on updating it, so I'm archiving this repository. I found that I was spending too much of my time managing my open buffers (something Vim doesn't want you to do) and that using standard tabpages and switching buffers via Telescope / FZF vastly sped up my editing. Adjusting to this workflow took time, but I recommend trying it before resorting to a buffer tabline plugin like this one.

To my knowledge, everything in this plugin works, so if it fits your needs, feel free to use it as-is or fork it.

buftabline.nvim

A low-config, minimalistic buffer tabline Neovim plugin written in Lua, shamelessly inspired by vim-buftabline.

Screen Shot 2021-08-25 at 3 30 42 PM

Setup

Install using your favorite plugin manager and call the following Lua code somewhere in your configuration:

require("buftabline").setup {}

If you're using packer.nvim, you can install and set up buftabline simultaneously:

use {
    "jose-elias-alvarez/buftabline.nvim",
    requires = {"kyazdani42/nvim-web-devicons"}, -- optional!
    config = function() require("buftabline").setup {} end
}

Features

Buftabline shows your open buffers in your tabline with (optional) filetype icons and applies highlighting to each tab based its buffer's state. If you want, it'll also show your tabpages (:help tabpages). That's pretty much it.

For convenience, the plugin exposes a function, buftarget(number, command) which will target a buffer in the tabline with a command:

require("buftabline").buftarget(1, "rightbelow sb")

By default, the plugin maps <Leader>0-9 to go to the corresponding buffer (0 gets converted to 10), but you can disable this by setting go_to_maps to false (see Options).

To simplify the creation of more custom commands, buftabline also exposes a map method. The following example will map <Leader>c1 through Leader<c9> to the corresponding bdelete command:

require("buftabline").map({ prefix = "<Leader>c", cmd = "bdelete" })

Lastly, the plugin adds the following Vim commands:

  • :ToggleBuftabline (useful for smaller screens / focus sessions)

  • :BufNext and :BufPrev (like :bnext and :bprev, but they correspond to bufferline indexes.

Options

For most users, everything should work out-of-the-box, but the plugin exposes the following options (defaults shown):

local options = {
    tab_format = " #{n}: #{b}#{f} ",
    buffer_id_index = false,
    icon_colors = true,
    start_hidden = false,
    auto_hide = false,
    disable_commands = false,
    go_to_maps = true,
    flags = {
        modified = " [+]",
        not_modifiable = " [-]",
        readonly = " [RO]",
    },
    hlgroups = {
        current = "TabLineSel",
        normal = "TabLine",
        active = nil,
        spacing = nil,
        modified_current = nil,
        modified_normal = nil,
        modified_active = nil,
        tabpage_current = nil,
        tabpage_normal = nil,
    },
    show_tabpages = true,
    tabpage_format = " #{n} ",
    tabpage_position = "right",
}
Option Description
tab_format Defines how the plugin formats buffer tabs (see Format below for details).
buffer_id_index Uses buffer numbers (the ones shown in :ls) instead of sequential indexes.
icon_colors Shows icon colors in your tabline. Can be true (always show), current (show for current tab), and normal (show for background tabs).
start_hidden Hides the tabline when Neovim starts.
auto_hide Shows the tabline when you have more than one buffer open and hides it when you don't. Not compatible with start_hidden.
disable_commands Stops the plugin from defining commands.
go_to_maps Maps <Leader>0-9 to go to the corresponding buffer.
flags Sets the flags used to mark a buffer's status.
hlgroups Sets highlight groups (see Colors below for details).
show_tabpages Shows tabpages (:h tabpages) in your bufferline. Can be true (show if more than one tabpage), always (always show), and false (disable). If you don't use tabpages, there's no need to change this.
tabpage_format Defines how the plugin formats tabpages (see Format below for details).
tabpage_position Determines where the plugin shows tabpages. Can be right or left. Does nothing if you've set show_tabpages to false.

Format

The tab_format string accepts the following special options and replaces them with the corresponding buffer information. The plugin won't do anything to other characters, including spaces and separators.

Option Information
#{n} The buffer's index. Modified by buffer_id_index.
#{b} The buffer's filename. If two or more buffers share a filename, it'll add the name of each buffer's enclosing directory.
#{f} The buffer's flags (modified, modifiable, and read-only).
#{i} The buffer's filetype icon.

The tabpage_format string accepts the following option:

Option Information
#{n} The tabpage's index.

Colors

The hlgroups option is a table that accepts the following keys to allow setting highlight groups based on buffer state. Leaving a value empty will cause the plugin to fall back to the next available group.

Key Condition
current The current buffer.
normal The buffer is not current visible in any window.
active The buffer is visible in another window.
spacing Applied to the empty space between buffer tabs and any right-aligned tabs (or the end of the viewport).
modified_current Same as current, but the buffer is modified.
modified_normal Same as normal, but the buffer is modified.
modified_active Same as active, but the buffer is modified.
tabpage_current The current tabpage. Falls back to current if not defined.
tabpage_normal Tabpages other than the current. Falls back to normal if not defined.

FAQ

How do I enable icons?

Add #{i} to tab_format. For example, to keep the default format but show icons after the buffer's filename:

tab_format = " #{n}: #{b}#{f} #{i} "

Non-goals

  • Vim support. Use vim-buftabline!
  • Mouse support.
  • Visual customization beyond what's available now.

Aside from these, I'm open to PRs.

Tests

Run make test from the plugin's root directory. Depends on plenary.nvim.

Inspiration

  • vim-buftabline, the direct inspiration for this plugin and still a solid plugin.

  • nvim-bufbar by @ojroques, who directed me to his plugin and encouraged me to use it as a starting point.

  • lightline-bufferline, which gave me the idea to "target" buffers in the tabline with commands.

  • nvim-bufferline and barbar.nvim, two tabline plugins that are far and away better than this one but are a little too much for my simple needs. (Thanks to barbar.nvim for its implementation of colored icons, which provided the basis for the implementation in this plugin.)

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].