Make clickable buffers (only Neovim)

fixes #369
This commit is contained in:
Christian Brabandt 2016-02-09 21:54:27 +01:00
parent a45a96c881
commit d8d08ada7b

View File

@ -71,6 +71,10 @@ function! airline#extensions#tabline#buffers#get()
let s:current_modified = (group == 'airline_tabmod') ? 1 : 0
endif
" Neovim feature: Have clickable buffers
if has("tablineat")
call b.add_raw('%'.nr.'@airline#extensions#tabline#buffers#switchbuf@')
endif
if s:buffer_idx_mode
if len(s:number_map) > 0
call b.add_section(group, s:spc . get(s:number_map, l:index, '') . '%(%{airline#extensions#tabline#get_buffer_name('.nr.')}%)' . s:spc)
@ -81,6 +85,9 @@ function! airline#extensions#tabline#buffers#get()
else
call b.add_section(group, s:spc.'%(%{airline#extensions#tabline#get_buffer_name('.nr.')}%)'.s:spc)
endif
if has("tablineat")
call b.add_raw('%X')
endif
endfor
call b.add_section('airline_tabfill', '')
@ -188,3 +195,11 @@ function s:map_keys()
noremap <silent> <Plug>AirlineSelectNextTab :<C-u>call <SID>jump_to_tab(v:count1)<CR>
endif
endfunction
function airline#extensions#tabline#buffers#switchbuf(minwid, clicks, button, modifiers) abort
" Run the following code only on a single left mouse button click without modifiers pressed
" works only in recent NeoVim with has('tablineat')
if a:clicks == 1 && a:button is# 'l' && a:modifiers !~# '[^ ]'
sil execute 'buffer' a:minwid
endif
endfunction