From f9feafa5bbbc38ec883b4753e836521aa04c23b7 Mon Sep 17 00:00:00 2001 From: jdhao Date: Fri, 13 Aug 2021 02:05:13 +0800 Subject: [PATCH] Use barbar.nvim for tabline --- core/plugins.vim | 15 ---------- lua/config/barbar.lua | 66 +++++++++++++++++++++++++++++++++++++++++++ lua/plugins.lua | 2 ++ 3 files changed, 68 insertions(+), 15 deletions(-) create mode 100644 lua/config/barbar.lua diff --git a/core/plugins.vim b/core/plugins.vim index 9bfbe11..cf0b638 100644 --- a/core/plugins.vim +++ b/core/plugins.vim @@ -384,18 +384,6 @@ let s:idx = utils#RandInt(0, len(s:candidate_airlinetheme)-1) let s:theme = s:candidate_airlinetheme[s:idx] let g:airline_theme=s:theme -" Tabline settings -let g:airline#extensions#tabline#enabled = 1 -let g:airline#extensions#tabline#fnamemod = ':t' -let g:airline#extensions#tabline#formatter = 'unique_tail_improved' - -" Show buffer number for easier switching between buffer, -" see https://github.com/vim-airline/vim-airline/issues/1149 -let g:airline#extensions#tabline#buffer_nr_show = 1 - -" Buffer number display format -let g:airline#extensions#tabline#buffer_nr_format = '%s. ' - " Whether to show function or other tags on status line let g:airline#extensions#vista#enabled = 1 let g:airline#extensions#gutentags#enabled = 1 @@ -433,9 +421,6 @@ let g:airline_highlighting_cache = 1 " See also https://github.com/vim-airline/vim-airline/blob/master/autoload/airline/extensions/xkblayout.vim#L11 let g:airline#extensions#xkblayout#short_codes = {'0': 'CN', '1': 'US'} -" Disable scrollbar -let g:airline#extensions#scrollbar#enabled = 0 - """"""""""""""""""""""""""""vim-startify settings"""""""""""""""""""""""""""" " Do not change working directory when opening files. let g:startify_change_to_dir = 0 diff --git a/lua/config/barbar.lua b/lua/config/barbar.lua new file mode 100644 index 0000000..bf66b90 --- /dev/null +++ b/lua/config/barbar.lua @@ -0,0 +1,66 @@ +-- Set barbar's options +vim.g.bufferline = { + -- Enable/disable animations + animation = true, + + -- Enable/disable auto-hiding the tab bar when there is a single buffer + auto_hide = false, + + -- Enable/disable current/total tabpages indicator (top right corner) + tabpages = true, + + -- Enable/disable close button + closable = true, + + -- Enables/disable clickable tabs + -- - left-click: go to buffer + -- - middle-click: delete buffer + clickable = true, + + -- Excludes buffers from the tabline + exclude_ft = {'javascript',}, + exclude_name = {'package.json'}, + + -- Enable/disable icons + -- if set to 'numbers', will show buffer index in the tabline + -- if set to 'both', will show buffer index and icons in the tabline + icons = 'buffer_numbers', + + -- If set, the icon color will follow its corresponding buffer + -- highlight group. By default, the Buffer*Icon group is linked to the + -- Buffer* group (see Highlighting below). Otherwise, it will take its + -- default value as defined by devicons. + icon_custom_colors = false, + + -- Configure icons on the bufferline. + icon_separator_active = '▎', + icon_separator_inactive = '▎', + icon_close_tab = '', + icon_close_tab_modified = '●', + icon_pinned = '車', + + -- If true, new buffers will be inserted at the end of the list. + -- Default is to insert after current buffer. + insert_at_end = false, + + -- Sets the maximum padding width with which to surround each tab + maximum_padding = 1, + + -- Sets the maximum buffer name length. + maximum_length = 30, + + -- If set, the letters for each buffer in buffer-pick mode will be + -- assigned based on their name. Otherwise or in case all letters are + -- already assigned, the behavior is to assign letters in order of + -- usability (see order below) + semantic_letters = true, + + -- New buffer letters are assigned in this order. This order is + -- optimal for the qwerty keyboard layout but might need adjustement + -- for other layouts. + letters = 'asdfjkl;ghnmxcvbziowerutyqpASDFJKLGHNMXCVBZIOWERUTYQP', + + -- Sets the name of unnamed buffers. By default format is "[Buffer X]" + -- where X is the buffer number. But only a static string is accepted here. + no_name_title = 'No name', +} diff --git a/lua/plugins.lua b/lua/plugins.lua index c7b26fc..eb45abf 100644 --- a/lua/plugins.lua +++ b/lua/plugins.lua @@ -100,6 +100,8 @@ require('packer').startup( use 'vim-airline/vim-airline-themes' use 'vim-airline/vim-airline' + use {'romgrk/barbar.nvim', config = [[require('config.barbar')]]} + -- fancy start screen use {'mhinz/vim-startify'} use {'lukas-reineke/indent-blankline.nvim', config = [[require('config.indent-blankline')]]}