Git Product home page Git Product logo

lightline-bufferline's Introduction

lightline-bufferline

This plugin provides bufferline functionality for the lightline vim plugin.

Table Of Contents

Installation

Installation can be easily done with a plugin manager of your choice. For example vim-plug:

Plug 'mengelbrecht/lightline-bufferline'

Integration

  1. Add 'buffers' to g:lightline.tabline.
  2. Add 'buffers': 'lightline#bufferline#buffers' to g:lightline.component_expand.
  3. Add 'buffers': 'tabsel' to g:lightline.component_type.

The result looks for example like this:

let g:lightline = {
      \ 'colorscheme': 'one',
      \ 'active': {
      \   'left': [ [ 'mode', 'paste' ], [ 'readonly', 'filename', 'modified' ] ]
      \ },
      \ 'tabline': {
      \   'left': [ ['buffers'] ],
      \   'right': [ ['close'] ]
      \ },
      \ 'component_expand': {
      \   'buffers': 'lightline#bufferline#buffers'
      \ },
      \ 'component_type': {
      \   'buffers': 'tabsel'
      \ }
      \ }

If you are using neovim with a lua configuration the above example looks like this:

vim.g['lightline'] = {
  colorscheme = 'one',
  active = {
    left = {{'mode', 'paste'}, {'readonly', 'filename', 'modified'}}
  },
  tabline = {
    left = {{'buffers'}},
    right = {{'close'}}
  },
  component_expand = {
    buffers = 'lightline#bufferline#buffers'
  },
  component_type = {
    buffers = 'tabsel'
  }
}

If you're adding the buffers to the bottom statusbar, the modified indicator will not be updated immediately. To work around this, add this autocmd to your vim config:

autocmd BufWritePost,TextChanged,TextChangedI * call lightline#update()

Configuration

General

g:lightline#bufferline#unnamed

The name to use for unnamed buffers. Default is '*'.

g:lightline#bufferline#margin_left

The number of spaces to add on the left side of the buffer name. Default is 0.

g:lightline#bufferline#margin_right

The number of spaces to add on the right side of the buffer name. Default is 0.

g:lightline#bufferline#reverse_buffers

If enabled the buffers will be displayed in a reversed order. Default is 0 (buffers are not reversed).

g:lightline#bufferline#right_aligned

If the bufferline is used in the right component of the tabline this should be set to 1 to ensure the correct order of the buffers. Default is 0.

g:lightline#bufferline#clickable

If set to 1 the bufferline is clickable when using Neovim versions with tablineat feature. To enable this feature, you must also set the bufferline component to be raw in your vimrc:

let g:lightline.component_raw = {'buffers': 1}

Before the click handler for the buffer is executed a custom event LightlineBufferlinePreClick is emitted. To perform an operation before the buffer is switched via the click handler you can define an autocommand:

autocmd User LightlineBufferlinePreClick :echom "test"

Filename

g:lightline#bufferline#filename_modifier

The filename-modifier applied to each buffer name. Default is ':.'. To see the available options use the command :help filename-modifiers in vim.

g:lightline#bufferline#shorten_path

Defines whether to shorten the path using the pathshorten function. Default is 1.

g:lightline#bufferline#smart_path

If enabled, when two files have the same name the distinguishing sections of each file's path are added. Default is 1.

Indicators

g:lightline#bufferline#modified

The indicator to use for a modified buffer. Default is ' +'.

g:lightline#bufferline#read_only

The indicator to use for a read-only buffer. Default is ' -'.

g:lightline#bufferline#more_buffers

The indicator to use when there are buffers that are not shown on the bufferline because they didn't fit the available space. Default is ....

g:lightline#bufferline#unicode_symbols

Use unicode symbols for modified and read-only buffers as well as the more buffers indicator. Default is 0.

If set to 1 the symbols +, - and ... are replaced by , and .

Note: The symbols are only correctly displayed if your font supports these characters.

More Buffers

g:lightline#bufferline#disable_more_buffers_indicator

Disables the more buffers indicator so that all buffers are always shown on the bufferline even if they don't fit the available space. Default is 0.

g:lightline#bufferline#max_width

The more buffers functionality determines the available space for the bufferline and calculates how many buffers can be shown until the more buffers indicator is displayed. The default function to calculate the available space for the buffers returns the number of columns: &columns. To customize the available space calculation this option can be set to the name of a custom function which will be used instead.

The function receives no parameters and should return the amount of available space for the bufferline. For example if you know that you have exactly 80 columns space for the bufferline you can specify the following function:

function LightlineBufferlineMaxWidth()
  return 80
endfunction

let g:lightline#bufferline#max_width = "LightlineBufferlineMaxWidth"

Numbering

g:lightline#bufferline#show_number

Defines whether to add the buffer number to the buffer name. Default is 0. Valid values are:

  • 0: No numbers
  • 1: Buffer number as shown by the :ls command
  • 2: Ordinal number (buffers are numbered from 1 to n sequentially)
  • 3: Buffer number followed by ordinal number
  • 4: Ordinal number followed by buffer number

The separator between ordinal and regular buffer number can be configured using the option g:lightline#bufferline#ordinal_separator. The separator between the buffer numbers and the buffer name can be configured using the option g:lightline#bufferline#number_separator.

For option 2, 3 and 4 the number maps g:lightline#bufferline#ordinal_number_map and g:lightline#bufferline#composed_ordinal_number_map are used for ordinal numbers. For regular buffer numbers the number maps g:lightline#bufferline#buffer_number_map and g:lightline#bufferline#composed_buffer_number_map are used. The number maps are described below.

g:lightline#bufferline#composed_ordinal_number_map

Dictionary mapping ordinal numbers to their alternative character representations. Default is {}.

For example, to use parenthesized unicode numbers taken from Enclosed Alphanumerics Unicode block:

let g:lightline#bufferline#composed_ordinal_number_map = {
\ 1:  '', 2:  '', 3:  '', 4:  '', 5:  '',
\ 6:  '', 7:  '', 8:  '', 9:  '', 10: '',
\ 11: '', 12: '', 13: '', 14: '', 15: '',
\ 16: '', 17: '', 18: '', 19: '', 20: ''}

Note: The option only applies when g:lightline#bufferline#show_number is set to 2, 3 or 4.

g:lightline#bufferline#ordinal_number_map

Fallback dictionary mapping digits (0-9) which are used in ordinal number composing if the number is not mapped in g:lightline#bufferline#composed_ordinal_number_map. Default is {}.

For example, to use unicode superscript numerals:

let g:lightline#bufferline#ordinal_number_map = {
\ 0: '', 1: '¹', 2: '²', 3: '³', 4: '',
\ 5: '', 6: '', 7: '', 8: '', 9: ''}

... or unicode subscript numerals:

let g:lightline#bufferline#ordinal_number_map = {
\ 0: '', 1: '', 2: '', 3: '', 4: '',
\ 5: '', 6: '', 7: '', 8: '', 9: ''}

Note: The option only applies when g:lightline#bufferline#show_number is set to 2, 3 or 4.

g:lightline#bufferline#composed_buffer_number_map

Dictionary mapping regular buffer numbers to their alternative character representations. Default is {}.

See g:lightline#bufferline#composed_ordinal_number_map for example values.

Note: The option only applies when g:lightline#bufferline#show_number is set to 2, 3 or 4.

g:lightline#bufferline#buffer_number_map

Fallback dictionary mapping digits (0-9) which are used in regular buffer number composing if the number is not mapped in g:lightline#bufferline#composed_buffer_number_map. Default is {}.

See g:lightline#bufferline#ordinal_number_map for example values.

Note: The option only applies when g:lightline#bufferline#show_number is set to 2, 3 or 4.

g:lightline#bufferline#number_separator

Defines the string which is used to separate the buffer number (if enabled) and the buffer name. Default is ' '.

g:lightline#bufferline#ordinal_separator

Defines the string which is used to separate the buffer number and the ordinal number. Default is ''.

Icons

g:lightline#bufferline#enable_devicons

Enables the usage of vim-devicons or nvim-web-devicons to display a filetype icon for the buffer. Default is 0.

g:lightline#bufferline#enable_nerdfont

Enables the usage of nerdfont.vim to display a filetype icon for the buffer. Default is 0.

g:lightline#bufferline#icon_position

Defines the position of the filetype icon. Default is left. Valid values are:

  • left: Left of the buffer name and after the buffer number
  • right: Right of the buffer name
  • first: Left of the buffer name and number

Hiding

g:lightline#bufferline#auto_hide

Automatically hides the bufferline n milliseconds after switching the buffer. For example to show the bufferline for 4 seconds when switching the buffer and hide it afterwards use the following setting:

let g:lightline#bufferline#auto_hide = 4000

Default is 0 and disables the auto-hide behaviour.

g:lightline#bufferline#min_buffer_count

Hides the bufferline by default and shows it if there are n or more buffers. Default is 0 and the bufferline is always shown. If min_tab_count is also specified the bufferline will be shown if one of the conditions is met.

g:lightline#bufferline#min_tab_count

Hides the bufferline by default and shows it if there are n or more tabs. Default is 0 and the bufferline is always shown. If min_buffer_count is also specified the bufferline will be shown if one of the conditions is met. This option can be useful if you are also displaying tabs in the lightline tabline.

Filtering

g:lightline#bufferline#filter_by_tabpage

When more than one tab is opened, only buffers that are open in a window within the current tab are shown. When there is only one tab, all buffers are shown. Default is 0. This option can be useful if you are also displaying tabs in the lightline tabline.

g:lightline#bufferline#buffer_filter

This can be set to the name of a custom buffer filter function which will be used in addition to the standard buffer filtering. The function receives the buffer number as parameter and should return 1 to include the buffer and 0 to hide the buffer in the bufferline. For example to hide all neovim terminal buffers use this code in your vim config:

function LightlineBufferlineFilter(buffer)
  return getbufvar(a:buffer, '&buftype') !=# 'terminal'
endfunction

let g:lightline#bufferline#buffer_filter = "LightlineBufferlineFilter"

Instead of just 1 or 0, you can also return a string with a custom category name. The bufferline will only display the buffers with the same category as the active one. If the active buffer is hidden (empty string '' or 0) it will instead display category 'default' (equivalent to 1). This may be useful if you want to display different categories of buffers in different splits, and be able to jump between buffers without mixing categories. For example, if you want to keep all your terminals in a separate split, you can modify the function above:

function LightlineBufferlineFilter(buffer)
  return getbufvar(a:buffer, '&buftype') ==# 'terminal' ? 'terminal' : 1
endfunction

Mappings

This plugin provides Plug mappings to switch to buffers using their ordinal number in the bufferline. To display the ordinal numbers in the bufferline use the setting g:lightline#bufferline#show_number = 2.

To use the Plug mappings to navigate to buffers you can use e.g. these mappings:

nmap <Leader>1 <Plug>lightline#bufferline#go(1)
nmap <Leader>2 <Plug>lightline#bufferline#go(2)
nmap <Leader>3 <Plug>lightline#bufferline#go(3)
nmap <Leader>4 <Plug>lightline#bufferline#go(4)
nmap <Leader>5 <Plug>lightline#bufferline#go(5)
nmap <Leader>6 <Plug>lightline#bufferline#go(6)
nmap <Leader>7 <Plug>lightline#bufferline#go(7)
nmap <Leader>8 <Plug>lightline#bufferline#go(8)
nmap <Leader>9 <Plug>lightline#bufferline#go(9)
nmap <Leader>0 <Plug>lightline#bufferline#go(10)

nmap <Tab>   <Plug>lightline#bufferline#go_next()
nmap <S-Tab> <Plug>lightline#bufferline#go_previous()
nmap <Leader><Tab>   <Plug>lightline#bufferline#go_next_category()
nmap <Leader><S-Tab> <Plug>lightline#bufferline#go_previous_category()

For reordering buffers, you can use e.g. these mappings:

nmap <Leader>bl <Plug>lightline#bufferline#move_next()
nmap <Leader>bh <Plug>lightline#bufferline#move_previous()
nmap <Leader>bk <Plug>lightline#bufferline#move_first()
nmap <Leader>bj <Plug>lightline#bufferline#move_last()
nmap <Leader>bb <Plug>lightline#bufferline#reset_order()

Additionally you can use the following e.g. to delete buffers by their ordinal number.

nmap <Leader>c1 <Plug>lightline#bufferline#delete(1)
nmap <Leader>c2 <Plug>lightline#bufferline#delete(2)
nmap <Leader>c3 <Plug>lightline#bufferline#delete(3)
nmap <Leader>c4 <Plug>lightline#bufferline#delete(4)
nmap <Leader>c5 <Plug>lightline#bufferline#delete(5)
nmap <Leader>c6 <Plug>lightline#bufferline#delete(6)
nmap <Leader>c7 <Plug>lightline#bufferline#delete(7)
nmap <Leader>c8 <Plug>lightline#bufferline#delete(8)
nmap <Leader>c9 <Plug>lightline#bufferline#delete(9)
nmap <Leader>c0 <Plug>lightline#bufferline#delete(10)

Functions

This plugin provides some public functions to interact with the plugin.

lightline#bufferline#reload()

This function reloads the plugin configuration (e.g. when you have modified the configuration after vim is already running) and refreshes lightline.

lightline#bufferline#get_ordinal_number_for_buffer(buffer)

This function returns the ordinal number for the given buffer or -1 if the buffer is not found.

lightline#bufferline#get_buffer_for_ordinal_number(n)

This function returns the buffer for the ordinal number specified by parameter n or -1 if no buffer is found.

lightline#bufferline#go(n)

This function switches to the buffer with the ordinal number specified by parameter n. To switch to the first buffer using a mapping you can use the function like this:

nmap <Leader>1 :call lightline#bufferline#go(1)<CR>

lightline#bufferline#go_relative(offset)

This function switches to the buffer offset positions relative to the current buffer. Passing a value of 1 for offset would switch to the next buffer, while a value of -1 would switch to the previous buffer.

lightline#bufferline#go_next()

This function switches to the next buffer in the bufferline.

lightline#bufferline#go_previous()

This function switches to the previous buffer in the bufferline.

lightline#bufferline#go_next_category()

This function switches to the first buffer in the next category.

lightline#bufferline#go_previous_category()

This function switches to the first buffer in the previous category.

lightline#bufferline#move(target)

This function moves current buffer to given ordinal position.

lightline#bufferline#move_relative(offset)

This function moves current buffer by given number of positions. Passing a value of 1 for offset would move current buffer one position to right, while a value of -1 would move it one position to left.

lightline#bufferline#move_next()

This function moves current buffer one position to the right.

lightline#bufferline#move_previous()

This function moves current buffer one position to the left.

lightline#bufferline#move_first()

This function moves current buffer one position to the first position.

lightline#bufferline#move_last()

This function moves current buffer one position to the last position.

lightline#bufferline#reset_order()

This function resets the order of all buffers to default, which is the order buffers were created.

lightline#bufferline#delete(n)

This function deletes the buffer with the ordinal number specified by parameter n. To delete the first buffer using a mapping you can use the function like this:

nmap <D-1> :call lightline#bufferline#delete(1)<CR>

Example

The following minimal example adds the bufferline to the lightline tabline and demonstrates a few custom bufferline options:

let g:lightline#bufferline#show_number  = 1
let g:lightline#bufferline#shorten_path = 0
let g:lightline#bufferline#unnamed      = '[No Name]'

let g:lightline                  = {}
let g:lightline.tabline          = {'left': [['buffers']], 'right': [['close']]}
let g:lightline.component_expand = {'buffers': 'lightline#bufferline#buffers'}
let g:lightline.component_type   = {'buffers': 'tabsel'}

FAQ

Q: I can't see the tabline!
A: Add set showtabline=2 to your configuration. This forces the tabline to always show.

Q: My vim GUI (MacVim, gVim, etc.) displays a graphical tabline and not the lightline tabline!
A: Add set guioptions-=e to your configuration (and guard it with if has('gui_running') ... endif). This will disable the GUI tabline and enable the lightline tabline.

Q: How can I hide the path and show only the filename?
A: Add let g:lightline#bufferline#filename_modifier = ':t' to your configuration.

Q: My buffer filter behaves oddly when trying to use filetype!
A: getbufvar(a:buffer, '&filetype') return an empty string before buffer is loaded, e.g. when opening multiple files. You can use file extension fnamemodify(bufname(a:buffer), ':e') as a fallback.

Q: How to dynamically change how a single buffer is filtered?
A: You can declare a buffer local variable (e.g. let b:buffer_filter_override = 0) and check if it exists at the entry of your filter function.

License

Released under the MIT License

lightline-bufferline's People

Contributors

brglng avatar diartyz avatar dkaszews avatar dreomite avatar fdietze avatar gpanders avatar jparise avatar macig avatar maximbaz avatar mengelbrecht avatar mgee avatar mivanchev avatar peymanmortazavi avatar sandangel avatar shatur avatar spywhere avatar sung-kim avatar tiberiuichim avatar xbaotg avatar zeroknight avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

lightline-bufferline's Issues

bufferline not updating when using vim-bbye or BClose

Issue:

Since I don't want to delete splits when deleting a buffer, I am running :Bclose offered by vim-bbye. This sometimes leads to not updating the bufferline or even removing the whole bufferline itself.

With scripts like BClose I have similar behaviour.

How to reproduce:

  1. Install lightline-bufferline
  2. install vim-bbye
  3. open two buffers

image

  1. Delete first buffer

image

As you can see, .vimrc is still in the bufferline although deleted. :e will refresh the bufferline.

image

  1. Delete second buffer

image

Aaaand its gone....

Procedure might differ slightly. But essentially lightline-bufferline seems to have trouble with various kind of Bclose implementations.

How to remove 'X' in top right corner

Hello! I was just curious how I can remove the close buffer 'x' that displays on the right side:
Screenshot 2020-06-14 12 42 19

I tried removing the 'close' option from my config, but it still displays after removing it?

      \   'tabline': {
      \     'left': [ [ 'buffers' ] ],
      \     'right': [ [ 'close' ] ],  <--- still appears even after removing this

Thanks!

Buffer reordering

Is it possible to reorder opened buffers on a tabline? Right now they are placed in the order of opening.

I think Airline couldn't do that because it used vim's buffer ids, I wonder if that is the case for Lightline also.

Hide path?

Is there a way to hide the file path and only show the basename of the file?

Special case for handling index files

It is common in NodeJS development to use index.js (or index.ts) file names. Sample project:

src
|- api
|  |- index.js
|- foo
|  |- index.js

If api/index.js is open, it just shows up as index.js, but this name is not informative. If both are open I get a/index.js and f/index.js. It would be preferred to have something like api/i to indicate the index file. I was reading up on filename-modifiers, but couldn't tell if there was an easy way to make it happen that way.

Any insights?

Thanks.

Feature request: buffer reordering and general buffer manupulation in tabline

Feature request: make it possible to visually reorder buffers in tabline.

Since (I suppose) most people (me included, at least) are using this plugin to unify experience between simple editors and vim and not for a minute be involved into thinking about buffers or tabs, there is a need to be able to reorder buffers. I am talking about something like :tabmove for tabs. It doesn't need to represent real buffer order as per :ls, because it would be impossible to implement.

What I suggest is:

  • create a level of abstraction above :ls (I don't know if the plugin already does that, sorry) which would be a list that represents order
  • maintain this custom list and allow to edit this list:
    • provide something to map a key to that would move current buffer left/right (like :tabmove +1/-1)
      • if it's first/last in the list, stop moving it (e.g. trying to move the leftmost buffer to the left is nop)
    • provide some command that would open (in sense of :edit) file in the next buffer to the right: that is, instead of opening file god knows where (which is what :edit does, which opens based on number which the buffer is assigned (great idea, isn't it?)), open it in the direct next buffer to the right of the current buffer: that is, open the file, see which number it gets and edit the plugin's buffer list accordingly to point at the right buffer in global buffer list
    • same with closing the buffer
    • probably something else I am not accounting for
  • display the plugin's list instead of the global list

Now that I've written all that, it started with a desire to have movable buffers in the list, but now it feels like this feature has to be twice the scope of this plugin.

Anyway, what do you think?

Option let g:lightline not working

In my .vimrc:
Plug 'mgee/lightline-bufferline'
Plug 'edkolev/tmuxline.vim' " Change tmux bar color
...
let g:lightline.tabline = {'left': [['buffers']], 'right': [['close']]}
let g:lightline.component_expand = {'buffers': 'lightline#bufferline#buffers'}
let g:lightline.component_type = {'buffers': 'tabsel'}

Bash output:
line 55:
E121: Undefined variable: g:lightline
line 56:
E121: Undefined variable: g:lightline
line 57:
E121: Undefined variable: g:lightline

lightline-bufferline conflicts with vim-noscrollbar plugin

I noticed that when lightline-bufferline is used along-side of vim-noscrollbar, the buffer list at the top is no longer rendered properly, and instead, only a single buffer tab is displayed.

Relevant config:

# lightline / bufferline
let g:lightline = { 'colorscheme': 'ThemerVimLightline' }
let g:lightline.tabline          = {'left': [['buffers']], 'right': [['close']]}
let g:lightline.component_expand = {'buffers': 'lightline#bufferline#buffers'}
let g:lightline.component_type   = {'buffers': 'tabsel'}
let g:lightline#bufferline#enable_devicons = 1
let g:lightline#bufferline#show_number  = 1

# vim-noscrollbar
Replace percent component of Lightline statusline
https://codeyarns.com/2017/10/25/how-to-add-noscrollbar-to-lightline/
let g:lightline = {
     \ 'component_function': {
     \   'percent': 'NoScrollbarForLightline'
     \ }
     \ }

Instead of % show NoScrollbar horizontal scrollbar
function! NoScrollbarForLightline()
   return noscrollbar#statusline()
endfunction

Do you think it would be possible to support using both plugins?

Is a option in README.md wrong?

I added options according to README.md, but it didn't work properly.

After I changed a value for g:lightline.component_expand as below, it worked.
Is this correct?

Before

let g:lightline.component_expand = {'buffers': 'lightline#bufferline#buffers'}

After

let g:lightline.component_expand = {'buffers': 'lightline#buffer#bufferline'}

feature request: mouse support

just saw a video about spacevim and saw that in spacevim u can switch buffers by clicking on the tabs in the tabline.

just went threw the spacevim config and aw theyre using airline and tabline. id like to stay with lightline and lightline bufferline. but that feature would be awesome cuz i often work from the laptop and there i use the touchpad quite a bit with vim.

is there a way to make it happen with this plugin?

modification marker "+" stays after saving

I broke it down to this small .vimrc (I'm using neovim):

set nocompatible
set laststatus=2
set hidden
set noshowmode


call plug#begin('~/.vim/bundle')
Plug 'itchyny/lightline.vim'
Plug 'mgee/lightline-bufferline'
call plug#end()

let g:lightline = {
      \ 'active': {
      \   'left': [ [ 'mode' ], [  'buffers' ]],
      \ },
      \ 'component_expand': {
      \   'buffers' : 'lightline#bufferline#buffers'
      \ },
      \ 'component_type': {
      \   'buffers': 'tabsel'
      \ },
      \ }

To reproduce:

  1. Open two files: vim a b (should start with the current buffer = a)
  2. Insert new line: o<Esc>
  3. Switch buffer two times :bn :bn
  4. Save :w

The plus is still displayed for buffer a, even though it is not modified anymore. It disappears with another buffer change :bn.

vim-devicons integration

As of now, I cannot find a way to have vim-devicons into this bufferline. I am attempting to do it in the same manner as the status line given by the instructions of vim-devicons. Is there any plans to integrate it?

Change color of the modified buffers

Having a + symbol to indicate modified buffers is good, but showing the modified buffers in a different color would be awesome. Airline does that, I hope it is possible to achieve with lightline too (presumably via component_expand)?

modified

Show both buffer number and ordinal number

Hi, is there a way for me to show both the ordinal number and buffer number?
I could map the ordinal number to the unicode character, and use <leader>1 ~ 0 to quickly go to the buffer by ordinal number, with a buffer that ordinal number is 11, I will use the buffer number with [N]<space> to quickly go there.

shorten_path isn't working

Hi,

I am using the latest version of neovim and lightline(-bufferline) on Mac and while the plugin works fine in general, the option shorten_path doesn't seem to have any effect. Any ideas?

Color scheme seems inverted & insert color doesn't apply

The color scheme seems inverted from it's normal appearance. As you can see, the light color is the background when the darker color likely should be the background.

Also insert coloring doesn't apply.

I looked through the code a little bit but couldn't see anything obvious that pointed to how the color colorscheme applies.

Normal
screen shot 2019-02-19 at 11 27 48 am

Insert
screen shot 2019-02-19 at 11 31 20 am

Triangle separator visual bug

Hello i have a visual bug on bufferline :

vimbug

I use this theme : https://github.com/ayu-theme/ayu-vim

My lightline config :

 let g:lightline = {
         \ 'colorscheme': 'ayu',
         \ 'separator': { 'left': '', 'right': '' },
         \ 'subseparator': { 'left': '', 'right': '' },
         \ 'active': {
         \   'left': [ [ 'mode', 'paste' ],
         \             [ 'gitbranch', 'readonly', 'filename', 'modified' ] ]
         \ },
         \ 'component_function': {
         \   'gitbranch': 'FugitiveHead'
         \ },
         \ 'tabline': {
         \   'left': [ ['buffers'] ],
         \   'right': [ ['close'] ]
         \ },
         \ 'component_expand': {
         \   'buffers': 'lightline#bufferline#buffers'
         \ },
         \ 'component_type': {
         \   'buffers': 'tabsel'
         \ }
         \ } 
let g:lightline#bufferline#unnamed     = '[No Name]'
set showtabline=2
set guioptions-=e

[Bug] lightline-bufferline doesn't handle very well more buffers than can be displayed at once

I genrated a lot of dummy files to quickly illustrate the issue, and opened them all at once.

If I try to reach one of the latter buffers (here, 2.txt), the selected buffer is on the screen and that is correct.
2017-01-26-135114_958x529_scrot

If I try to reach one of the buffers hidden by the < arrow (in this case, 14.txt), the bufferline does not update to display the selected buffer.
2017-01-26-135102_958x529_scrot

Thank you for creating that bufferline! I miss a feature or two from the airline bufferline (inactive splits shown as selected inactive buffers (lightline-bufferline vs airline, mostly)), but in my search for lightweight but good-looking powerline/airline replacements, your project meets the requirements. 👍 for super readable code, I hope to have the time to look into it to tweak it to my liking.

Spacing / margins?

Maybe I'm not seeing the obvious, but is there a straight-forward way to make tabs wider? I.e.:

|    foo.vim    |    context.js   |    style.css    |

Feature Request - Tabline visible only when switching

Hi,

Would it be possible to make the tabline visible only when switching buffers? That way I can see where I'm going when moving buffers and it doesn't take place when I am just editing the current one?

Thank you, and if you don't have, time tell me. I can take a look and make a pull request

Support lightline#bufferline#go mapping for buffers with ordinal number beyond 10

I really love mappings the go mappings this plugin offers, eg:
noremap lightline#bufferline#go(10) :call goto_nth_buffer(9)

I have an ultrawide monitor, on which vim can display up to 18 buffers in the bufferline.
Currently, it seems like we only have the mapping until buffer 10: https://github.com/mengelbrecht/lightline-bufferline/blob/master/autoload/lightline/bufferline.vim#L331

Because of that I am unable to jump to buffers beyond 10 with that mapping.

Can we add mappings for more buffers please (may be up to 20) ?

The goto_nth_buffer() doesn't seem to be visible outside the plugin (unless I am mistaken), so there's no easy way to add additional mapping (except modifying this plugin's code locally). I can think of two approaches here:

  1. Either add additional mappings like existing ones
    OR
  2. Make a public interface to access goto_nth_buffer() , that way users can call it on any number they want.

Reverse tabs order

At the moment, if I place buffers component on the right side (either on tabline or statusline), it get 'reversed' like this:
current

My quick fixes:

  1. Change lightline#bufferline#buffers
function! lightline#bufferline#buffers()
  ...
  "return s:select_buffers(l:before, l:current, l:after)
  return s:select_buffers(l:after, l:current, l:before)
endfunction

fix1

  1. Change s:get_buffer_names
function! s:get_buffer_names(buffers, from, to)
  ...
  "return l:names
  return reverse(l:names)
endfunction

fix2

  1. BONUS: If both hacks applied, and buffers component is on the left side, we'll have this
    both

Though, for my use case only the first one is needed. And of course, if implemented, they would need to be manually enabled by user through config variable.

I'd like to hear your thoughts on this.

makes git branch disappear in bottom status left with example config

VIM - Vi IMproved 8.2 (2019 Dec 12, compiled Apr 13 2020 07:47:09)
macOS version
Included patches: 1-550
Compiled by Homebrew
Huge version without GUI.  Features included (+) or not (-):
+acl               -farsi             -mouse_sysmouse    -tag_old_static
+arabic            +file_in_path      +mouse_urxvt       -tag_any_white
+autocmd           +find_in_path      +mouse_xterm       -tcl
+autochdir         +float             +multi_byte        +termguicolors
-autoservername    +folding           +multi_lang        +terminal
-balloon_eval      -footer            -mzscheme          +terminfo
+balloon_eval_term +fork()            +netbeans_intg     +termresponse
-browse            +gettext           +num64             +textobjects
++builtin_terms    -hangul_input      +packages          +textprop
+byte_offset       +iconv             +path_extra        +timers
+channel           +insert_expand     +perl              +title
+cindent           +job               +persistent_undo   -toolbar
-clientserver      +jumplist          +popupwin          +user_commands
+clipboard         +keymap            +postscript        +vartabs
+cmdline_compl     +lambda            +printer           +vertsplit
+cmdline_hist      +langmap           +profile           +virtualedit
+cmdline_info      +libcall           -python            +visual
+comments          +linebreak         +python3           +visualextra
+conceal           +lispindent        +quickfix          +viminfo
+cryptv            +listcmds          +reltime           +vreplace
+cscope            +localmap          +rightleft         +wildignore
+cursorbind        +lua               +ruby              +wildmenu
+cursorshape       +menu              +scrollbind        +windows
+dialog_con        +mksession         +signs             +writebackup
+diff              +modify_fname      +smartindent       -X11
+digraphs          +mouse             -sound             -xfontset
-dnd               -mouseshape        +spell             -xim
-ebcdic            +mouse_dec         +startuptime       -xpm
+emacs_tags        -mouse_gpm         +statusline        -xsmp
+eval              -mouse_jsbterm     -sun_workshop      -xterm_clipboard
+ex_extra          +mouse_netterm     +syntax            -xterm_save
+extra_search      +mouse_sgr         +tag_binary


let g:lightline = {
      \ 'colorscheme': 'wombat',
            \ 'separator': { 'left': '', 'right': '' },
            \ 'subseparator': { 'left': '', 'right': '' },
            \ 'tabline': {
            \   'left': [ ['tabs'] ],
            \   'right': [ ['close'] ]
            \ },
      \ 'active': {
      \   'left': [ [ 'mode', 'paste' ],
      \             [ 'gitbranch', 'readonly', 'filename', 'modified' ] ],
      \ 'right': [['lineinfo'],
      \            ['percent'],
     \            [ 'fileformat', 'fileencoding', 'filetype'] ]
      \},
      \ 'component_function': {
      \   'gitbranch': 'FugitiveHead'
      \ },
      \ }
"bottom status line"
let g:lightline#bufferline#show_number  = 1
let g:lightline#bufferline#shorten_path = 0
let g:lightline#bufferline#unnamed      = '[No Name]'
let g:lightline                  = {}
let g:lightline.tabline          = {'left': [['buffers']], 'right': [['close']]}
let g:lightline.component_expand = {'buffers': 'lightline#bufferline#buffers'}
let g:lightline.component_type   = {'buffers': 'tabsel'}

in absence of lightline-bufferline the git branch is displayed in left corner as configured.When lightline-bufferline is enabled then it makes git status disappear.
please let me know if you require more details.

Adding a option to disable showing paths

I know there's a shorten path option, but it would be really nice to have an option that disable showing the paths, but only show the file names, is it already available or that's something that need to implement?

No theming/coloring applied

I just installed this plugin and enabled it but it seems like no theming and/or coloring is applied to the top bar (buffer bar now). Please see this screenshot.

lightline_buffers

I am using nvim and the important bits on my config file are as follows:


Plug 'mengelbrecht/lightline-bufferline'
Plug 'itchyny/lightline.vim'

set showtabline=2

let g:lightline#bufferline#show_number  = 1
let g:lightline#bufferline#shorten_path = 0
let g:lightline#bufferline#unnamed      = '[No Name]'
let g:lightline                  = {}
let g:lightline.tabline          = {'left': [['buffers']], 'right': [['close']]}
let g:lightline.component_expand = {'buffers': 'lightline#bufferline#buffers'}
let g:lightline.component_type   = {'buffers': 'tabsel'}

What am I missing?

I'd like the buffer bar to resemble lightline. Most importantly, I would like the color of the selected buffer to be different.

you forgot " " in show_number

In bufferline.vim line 48, you forgot to add a space.

Now it looks like this:
let l:name = s:get_from_number_map(a:i + 1) . l:name
It should look like this
let l:name = s:get_from_number_map(a:i + 1) . ' ' . l:name

Place Tabs on Status Bar

Is there any way to place tabs in the status bar rather the actual tab bar?

I like having my buffers on top since I have more space and I always have more buffers than tabs.

Just like the image below:
tabline
Also, is there a way to add the powerline symbols to the tab as well? For example, from the image above, 'Tab1' is the current tab and should be highlighted. Basically I'd like it to look exactly like the buffers above.

Vim location list / quickfix is visible in bufferline

The location list / quickfix buffer is visible in the bufferline.

image

I could fix this by changing the following line

return bufexists(a:i) && buflisted(a:i)

to this

return bufexists(a:i) && buflisted(a:i) && !(getbufvar(a:i, '&filetype') ==# 'qf')

Sorry if my solution should not be good but I'm new to dealing with Vim and VimL

Thanks for the great plugin.

The last buffername stays inactive at the StatusBar after :bdelete

I have configured lightline and lightline-bufferline as following

set laststatus=2 " Always show statusline
let g:lightline = {
\ 'colorscheme': 'nord',
\ 'active': {
\ 'left': [ [ 'mode', 'paste' ],
\ [ 'readonly' ], ['buffers'] ],
\ 'right': [ [ 'lineinfo' ],
\ [ 'percent' ],
\ [ 'chdir', 'filetype' ] ]
\ },
\ 'component_function': {
\ 'chdir': 'LightlineWorkingDir',
\ },
\ 'component_expand': {
\ 'buffers': 'lightline#bufferline#buffers'
\ },
\ 'component_type': {
\ 'buffers': 'tabsel'
\ }
\ }

let g:lightline#bufferline#show_number = 1
let g:lightline#bufferline#filename_modifier = ':t'
let g:lightline#bufferline#shorten_path = 2
let g:lightline#bufferline#unnamed = ''
function! LightlineWorkingDir()
let dir = fnamemodify(getcwd(), ":~:.")
return dir
endfunction

autocmd BufLeave,BufDelete,BufWritePost,TextChanged,TextChangedI * call lightline#update()

Burffers are being showed at the StatusBar and Everything's working as it should. Howwver, when I have only one buffer active and I type :bd or :dw to delete the buffer, the buffername remains inactive at the StatusBar and the focus goes to the new No Name buffer. The zombie buffername goes away if I type :bd again or :call lightline#update(). Tried to automatically call lightline#update() on BufLeave but it does not work.

This does not happens when buffers are shown in tabline though.

Can't get it work

Have the exact lines from your example in my .vimrc and it's not showing open buffers. Any insight?

my .vimrc:

" lightline-bufferline integration
let g:lightline#bufferline#unnamed	= '[No Name]'
let g:lightline						= {}
let g:lightline.tabline				= {'left': [['buffers']], 'right': [['close']]}
let g:lightline.component_expand	= {'buffers': 'lightline#bufferline#buffers'}
let g:lightline.component_type		= {'buffers': 'tabsel'}

my Vim window:
screen shot 2018-09-24 at 1 12 09 pm

No devicons with filename modifier ':t:r'

If ':t:r' as filename modifier is used, the devicons are not showing.
I could fix this by changing the following line

let l:name = WebDevIconsGetFileTypeSymbol(l:name) . ' ' . l:name

to this

let l:name = WebDevIconsGetFileTypeSymbol(fnamemodify(bufname(a:buffer), ':t')) . ' ' . l:name.

I think this has the advantage that the devicons are determined independently of the used filename modifiers.
Sorry if my solution should not be good but I'm new to dealing with Vim and VimL

Thanks for the great plugin.

Request: function to close current buffer

I know there's the lightline#bufferline#delete(n) function to delete the n-th buffer, but it would be nice to have a function to close the current buffer, whatever its number may be.

Or equivalently, a function that returns the current buffer's ordinal number, which could then be used as lightline#bufferline#delete()'s argument.

`Undefined variable: g:lightline`

I use vim 8.1.1401 on Debian buster. Vundle is used for integration:

[...]
Plugin 'itchyny/lightline.vim'                                                                                                                     
Plugin 'mengelbrecht/lightline-bufferline'
[...]

I copy & pasted the configuration code from readme.md into my ~/.vimrc:

let g:lightline.tabline          = {'left': [['buffers']], 'right': [['close']]}                                                                   
let g:lightline.component_expand = {'buffers': 'lightline#bufferline#buffers'}                                                                     
let g:lightline.component_type   = {'buffers': 'tabsel'}

Upon opening vim I get E121: Undefined variable: g:lightline messages for each of the three lines above. Any hints appreciated.

Bufferline disappears after closing floating terminal

The bufferline seems to disappear after closing a terminal window spawned with the vim-floaterm plugin when two buffers are open. Weirdly enough, it doesn't disappear when three buffers are open.
output

I have

let g:lightline#bufferline#show_number = 2
let g:lightline#bufferline#number_separator = ": "
let g:lightline#bufferline#enable_devicons = 1
let g:lightline#bufferline#icon_position = "first"
let g:lightline#bufferline#min_buffer_count = 2
let g:lightline#bufferline#clickable = 1

in my config files.

gray tabline

I stripped my config with everything, and left just this

if empty(glob('~/.local/share/nvim/site/autoload/plug.vim'))
  silent !mkdir -p ~/.local/share/nvim/site/autoload
  silent !curl -fLo ~/.local/share/nvim/site/autoload/plug.vim
    \ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
  autocmd VimEnter * PlugInstall
endif


" Section: Plugin settings
"
call plug#begin('~/.local/share/nvim/plugged')

Plug 'itchyny/lightline.vim'
Plug 'mengelbrecht/lightline-bufferline'

call plug#end()

set showtabline=2
let g:lightline                  = {}
let g:lightline.tabline          = {'left': [['buffers']], 'right': [['close']]}
let g:lightline.component_expand = {'buffers': 'lightline#bufferline#buffers'}
let g:lightline.component_type   = {'buffers': 'tabsel'}

All I'm left with is a gray tabline.
screenshot_2020-04-22_12-15-03_123581114

I tried changing terminal and shell.
When I don't have this plugin installed, I get the current buffer in the tabline like normal.
Any idea?

Instead of the number of the buffer the file path is shown

OS: MacOS 10.14.6
Editor: Neovim v0.4.4

I have an issue when the following settings are applied in my init.vim:

let g:lightline#bufferline#unnamed = '[No Name]'
let g:lightline#bufferline#unicode_symbols = 0
let g:lightline#bufferline#enable_devicons = 1
let g:lightline#bufferline#shorten_path = 1
let g:lightline#bufferline#show_number = 1
let g:lightline#bufferline#smart_path = 0

The issue only appears when I turn lightline#bufferline#smart_path off.

I also attached a screenshot:
Screenshot 2020-10-28 at 8 07 58 PM

I was able to do a quick dirty fix in the plugin by modifying the following on line 74 in autoload/lightline/bufferline.vim. I basically wrapped the a:buffer with bufnr(), but I'm not sure if this is the right way to deal with the issue. I'm not experienced with vimscript.

Here is what I did:

let l:name = bufnr(a:buffer) . s:number_separator . l:name

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.