This article isLearn Neovim full configuration and escape VSCodeThe seventh in a series

Please subscribe on Github

This chapter describes how to install and configure the Bufferline plug-in for Nvim.


A bufferline displays a buffer similar to a Tab page in VSCode, as shown in the following GIF:

Those of you who use VSCode will be familiar with this, and my goal is to get as close to VSCode as possible.

Install bufferline nvim

Open plugins.lua and add nvim-tree code

-- bufferline
use {'akinsho/bufferline.nvim', requires = 'kyazdani42/nvim-web-devicons'}
Copy the code

The complete plugins.lua file is as follows:

return require('packer').startup(function() -- Packer can manage itself use 'wbthomason/packer.nvim' -- gruvbox theme use { "ellisonleao/gruvbox.nvim", requires = {"rktjmp/lush.nvim"} } -- nvim-tree use { 'kyazdani42/nvim-tree.lua', Requires = 'kyazdani42/nvim-web-devicons'} -- bufferline use {'akinsho/bufferline.nvim', requires = 'kyazdani42/nvim-web-devicons'} -- bufferline use {'akinsho/bufferline.nvim', requires = 'kyazdani42/nvim-web-devicons'} end)Copy the code

:wq Save the changes and exit. Open the file again and run PackerSync

Packer. Nvim is used in the previous section

After success, press Q to exit as shown in the figure

If a network error is reported, re-run :PackerSync

Configuration bufferline

Create lua/plugin-config/bufferline.lua

Add the configuration

Vim.opt.termguicolors = true require("bufferline").setup {options = {-- NVIm built-in LSP diagnostics = "nvim_LSP ", {{fileType = "NvimTree", text = "File Explorer", highlight = "Directory", text_align = "left" }} } }Copy the code

Bufferline. nvim has a lot of configuration items, I didn’t set too much, mainly left the position of nvim-tree out, in order to be consistent with VSCode,

If offsets are not set it will default to Tab from the top left corner.

Bufferline. nvim has more detailed Settings, which you have good options, welcome to let me know.

Open init.vim, load lua/plugin-config/bufferline.lua configuration file, add

lua require('plugin-config/bufferline')
Copy the code

:wq Save the changes and exit.

Configure shortcut Keys

Open /lua/keybindings. Lua according to personal habit, add

-- BufferLine Left Tab toggle map("n", "< C-H >", ":BufferLineCyclePrev<CR>", ":BufferLineCycleNext<CR>", opt)Copy the code

Because I’ve assigned Alt + H and Alt + L to the cursor to jump between the left and right split screens

In keeping with my habit in VSCode, use Ctrl + h and Ctrl + l to toggle left and right tabs.

My usual operation

  • Alt + mOpen thenvim-tree
  • j/kMove the cursor
  • oOpen the file
  • Alt + hJump backnvim-treeSplit screen
  • oGo ahead and open the file
  • Alt + mShut downnvim-tree
  • Ctrl + hCtrl + lLeft and right TAB

The bufferline.nvim home page contains other configurations that are not commonly used but will be added in the future

The next chapter continues with other plug-ins, thanks for your attention.

  • Next chapter :(I’m writing, please click like to follow, thank you)
  • Back to the home page:Learn Neovim full configuration, escape VSCode