Skip to content

Pheon-Dev/buffalo-nvim

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

91 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Linux macOS Windows

buffalo-nvim

buffalo-nvim

This is a harpoon like plugin that provides an interface to navigate through buffers or tabs.

Their respective totals can be displayed on the statusline, tabline or winbar.


NOTE:

Please note this plugin is still in its early development stages. Breaking changes are to be expected!

BUFFERS

buffalo-buffers


TABS

buffalo-tabs


STATUSLINE

buffalo-statusline

tabs: 4 | buffers: 7 [lualine]

Installation

Using Lazy

  {
     'Pheon-Dev/buffalo-nvim'
  }

Using packer.nvim

use 'Pheon-Dev/buffalo-nvim'

Using vim-plug

Plug 'Pheon-Dev/buffalo-nvim'

Setup

-- default config
require('buffalo').setup({})

Usage

-- Keymaps
local opts = { noremap = true }
local map = vim.keymap.set
local buffalo = require("buffalo.ui")

-- buffers
map({ 't', 'n' }, '<C-Space>', buffalo.toggle_buf_menu, opts)

map('n', '<C-j>', buffalo.nav_buf_next, opts)
map('n', '<C-k>', buffalo.nav_buf_prev, opts)

-- tabpages
map({ 't', 'n' }, '<M-Space>', buffalo.toggle_tab_menu, opts)

map('n', '<C-n>', buffalo.nav_tab_next, opts)
map('n', '<C-p>', buffalo.nav_tab_prev, opts)

-- Example in lualine
...
sections = {
  ...
  lualine_x = {
      {
        function()
          local buffers = require("buffalo").buffers()
          local tabpages = require("buffalo").tabpages()
          return "󱂬 " .. buffers .. " 󰓩 " .. tabpages
        end,
        color = { fg = "#ffaa00", bg = "#24273a",},
      }
    },
  ...
    },
...

Config

require("buffalo").setup({
  tab_commands = {  -- use default neovim commands for tabs e.g `tablast`, `tabnew` etc
    next = { -- you can use any unique name e.g `tabnext`, `tab_next`, `next`, `random` etc
      key = "<CR>",
      command = "tabnext"
    },
    close = {
      key = "c",
      command = "tabclose"
    },
    dd = {
      key = "dd",
      command = "tabclose"
    },
    new = {
      key = "n",
      command = "tabnew"
    }
  },
  buffer_commands = { -- use default neovim commands for buffers e.g `bd`, `edit`
    edit = {
      key = "<CR>",
      command = "edit"
    },
    vsplit = {
      key = "v",
      command = "vsplit"
    },
    split = {
      key = "h",
      command = "split"
    }
    buffer_delete = {
      key = "d",
      command = "bd"
    }
  },
  general_commands = {
    cycle = true, -- cycle through buffers or tabs
    exit_menu = "x", -- similar to 'q' and '<esc>'
  },
  go_to = {
    enabled = true,
    go_to_tab = "<leader>%s",
    go_to_buffer = "<M-%s>",
  },
  filter = {
    enabled = true,
    filter_tabs = "<M-t>",
    filter_buffers = "<M-b>",
  },
  ui = {
    width = 60,
    height = 10,
    row = 2,
    col = 2,
    borderchars = { "", "", "", "", "", "", "", "" },
  }
})

Tips

  • Hit any number on the menu to navigate to that buffer or tab without having to scroll.
  • Use normal keymap defaults for neovim e.g dd to delete a buffer, on the open menu.

Highlights

  • BuffaloBorder
  • BuffaloWindow
  • BuffaloBuffersModified
  • BuffaloBuffersCurrentLine
  • BuffaloTabsCurrentLine

Acknowledgement


Contributions

  • PRs and Issues are always welcome.