An open API service indexing awesome lists of open source software.

https://github.com/hernancerm/bufpin.nvim

Manually track a list of bufs and visualize it in the tabline
https://github.com/hernancerm/bufpin.nvim

lua neovim neovim-plugin nvim nvim-plugin plugin tabline

Last synced: about 1 month ago
JSON representation

Manually track a list of bufs and visualize it in the tabline

Awesome Lists containing this project

README

          

# Bufpin

Manually track a list of bufs and visualize it in the tabline.


bufpin.nvim demo

## Features

- Display the pinned bufs in the tabline.
- Out of the box key mappings to manage pinned bufs.
- Sensible default colors for Bufpin's highlight groups.
- Mouse support to left-click to edit buf and middle-click to remove buf.
- Store the pinned bufs in session (`:mksession`) if `vim.opt.ssop:append("globals")`.
- Auto-hide the tabline when there are no pinned bufs.
- Expose an API to track the pinned bufs.
- Show file type icons.

Suggested complementary plugins:

- [mini.icons](https://github.com/echasnovski/mini.icons):
Display file type icon next to buf name. Use a [Nerd Font](https://www.nerdfonts.com/).
- [mini.bufremove](https://github.com/echasnovski/mini.bufremove):
Preserve window layout when removing bufs.
- [vim-lastplace](https://github.com/farmergreg/vim-lastplace):
Remember the cursor location in visited bufs.

## Out of scope

- Be a fully-fledged tabline plugin like
[bufferline.nvim](https://github.com/akinsho/bufferline.nvim).

## Requirements

- Neovim >= 0.11.0

## Installation

Use your favorite package manager. For example, [Lazy.nvim](https://github.com/folke/lazy.nvim):

```lua
{
"hernancerm/bufpin.nvim",
opts = {}
},
```

The function `require("bufpin").setup()` needs to be called. Lazy.nvim does this using the snippet
above.

## Default config

```lua
local bufpin = require("bufpin")
bufpin.setup()
```

Is equivalent to:

```lua
local bufpin = require("bufpin")
bufpin.setup({
auto_hide_tabline = true,
set_default_keymaps = true,
exclude = function(_) end,
exclude_runr_bufs = true,
use_mini_bufremove = true,
icons_style = "monochrome_selected",
ghost_buf_enabled = true,
remove_with = "delete",
logging = {
enabled = false,
level = vim.log.levels.INFO,
},
})
```

Default key mappings:

```lua
local kset = vim.keymap.set
local opts = { silent = true }
kset("n", "p", ":cal v:lua.Bufpin.toggle()", opts)
kset("n", "w", ":cal v:lua.Bufpin.remove()", opts)
kset("n", "", ":cal v:lua.Bufpin.edit_left()", opts)
kset("n", "", ":cal v:lua.Bufpin.edit_right()", opts)
kset("n", "", ":cal v:lua.Bufpin.move_to_left()", opts)
kset("n", "", ":cal v:lua.Bufpin.move_to_right()", opts)
kset("n", "", ":cal v:lua.Bufpin.edit_by_index(1)", opts)
kset("n", "", ":cal v:lua.Bufpin.edit_by_index(2)", opts)
kset("n", "", ":cal v:lua.Bufpin.edit_by_index(3)", opts)
kset("n", "", ":cal v:lua.Bufpin.edit_by_index(4)", opts)
```

## Documentation

Please refer to the help file: [bufpin.txt](./doc/bufpin.txt).

## JetBrains IDEs

To get a similar experience in JetBrains IDEs follow these instructions:

- IDE: In Settings set the tab limit to 1: "Editor > Editor Tabs > Tab limit: 1".
- [IdeaVim](https://github.com/JetBrains/ideavim): In `~/.ideavimrc` add this to match the default
key maps of this plugin:

```vim
nmap p (PinActiveEditorTab)
nmap w (CloseContent)
nmap (PreviousTab)
nmap (NextTab)
nnoremap :tabmove -1
nnoremap :tabmove +1
nmap (GoToTab1)
nmap (GoToTab2)
nmap (GoToTab3)
nmap (GoToTab4)
```

## Inspiration

- [Harpoon](https://github.com/ThePrimeagen/harpoon)
- [IntelliJ IDEA](https://www.jetbrains.com/idea/)
- [IdeaVim](https://github.com/JetBrains/ideavim)

## Contributing

I welcome issues requesting any behavior change. However, please do not submit a PR unless it's for
a trivial fix.

## License

[MIT](./LICENSE)