Merge pull request #932 from chrisbra/updated-doc

clarify buffer_idx mode mappings
This commit is contained in:
Bailey Ling 2016-01-23 13:47:17 -05:00
commit 698db37591
3 changed files with 39 additions and 13 deletions

View File

@ -45,6 +45,7 @@ function! airline#extensions#tabline#buffers#invalidate()
endfunction
function! airline#extensions#tabline#buffers#get()
call <sid>map_keys()
let cur = bufnr('%')
if cur == s:current_bufnr
if !g:airline_detect_modified || getbufvar(cur, '&modified') == s:current_modified
@ -180,16 +181,18 @@ function! s:jump_to_tab(offset)
endif
endfunction
if s:buffer_idx_mode
noremap <silent><unique> <Plug>AirlineSelectTab1 :call <SID>select_tab(0)<CR>
noremap <silent><unique> <Plug>AirlineSelectTab2 :call <SID>select_tab(1)<CR>
noremap <silent><unique> <Plug>AirlineSelectTab3 :call <SID>select_tab(2)<CR>
noremap <silent><unique> <Plug>AirlineSelectTab4 :call <SID>select_tab(3)<CR>
noremap <silent><unique> <Plug>AirlineSelectTab5 :call <SID>select_tab(4)<CR>
noremap <silent><unique> <Plug>AirlineSelectTab6 :call <SID>select_tab(5)<CR>
noremap <silent><unique> <Plug>AirlineSelectTab7 :call <SID>select_tab(6)<CR>
noremap <silent><unique> <Plug>AirlineSelectTab8 :call <SID>select_tab(7)<CR>
noremap <silent><unique> <Plug>AirlineSelectTab9 :call <SID>select_tab(8)<CR>
noremap <silent><unique> <Plug>AirlineSelectPrevTab :<C-u>call <SID>jump_to_tab(-v:count1)<CR>
noremap <silent><unique> <Plug>AirlineSelectNextTab :<C-u>call <SID>jump_to_tab(v:count1)<CR>
endif
function s:map_keys()
if s:buffer_idx_mode
noremap <silent> <Plug>AirlineSelectTab1 :call <SID>select_tab(0)<CR>
noremap <silent> <Plug>AirlineSelectTab2 :call <SID>select_tab(1)<CR>
noremap <silent> <Plug>AirlineSelectTab3 :call <SID>select_tab(2)<CR>
noremap <silent> <Plug>AirlineSelectTab4 :call <SID>select_tab(3)<CR>
noremap <silent> <Plug>AirlineSelectTab5 :call <SID>select_tab(4)<CR>
noremap <silent> <Plug>AirlineSelectTab6 :call <SID>select_tab(5)<CR>
noremap <silent> <Plug>AirlineSelectTab7 :call <SID>select_tab(6)<CR>
noremap <silent> <Plug>AirlineSelectTab8 :call <SID>select_tab(7)<CR>
noremap <silent> <Plug>AirlineSelectTab9 :call <SID>select_tab(8)<CR>
noremap <silent> <Plug>AirlineSelectPrevTab :<C-u>call <SID>jump_to_tab(-v:count1)<CR>
noremap <silent> <Plug>AirlineSelectNextTab :<C-u>call <SID>jump_to_tab(v:count1)<CR>
endif
endfunction

View File

@ -31,6 +31,7 @@ endfunction
function! airline#extensions#tabline#tabs#get()
let curbuf = bufnr('%')
let curtab = tabpagenr()
call s:map_keys()
if curbuf == s:current_bufnr && curtab == s:current_tabnr
if !g:airline_detect_modified || getbufvar(curbuf, '&modified') == s:current_modified
return s:current_tabline
@ -80,3 +81,18 @@ function! airline#extensions#tabline#tabs#get()
let s:current_tabline = b.build()
return s:current_tabline
endfunction
function s:map_keys()
noremap <silent> <Plug>AirlineSelectTab1 :1tabn<CR>
noremap <silent> <Plug>AirlineSelectTab2 :2tabn<CR>
noremap <silent> <Plug>AirlineSelectTab3 :3tabn<CR>
noremap <silent> <Plug>AirlineSelectTab4 :4tabn<CR>
noremap <silent> <Plug>AirlineSelectTab5 :5tabn<CR>
noremap <silent> <Plug>AirlineSelectTab6 :6tabn<CR>
noremap <silent> <Plug>AirlineSelectTab7 :7tabn<CR>
noremap <silent> <Plug>AirlineSelectTab8 :8tabn<CR>
noremap <silent> <Plug>AirlineSelectTab9 :9tabn<CR>
noremap <silent> <Plug>AirlineSelectPrevTab gT
" tabn {count} goes to count tab does not go {count} tab pages forward!
noremap <silent> <Plug>AirlineSelectNextTab :<C-U>exe repeat(':tabn\|', v:count1)<cr>
endfunction

View File

@ -493,9 +493,16 @@ exposed.
nmap <leader>7 <Plug>AirlineSelectTab7
nmap <leader>8 <Plug>AirlineSelectTab8
nmap <leader>9 <Plug>AirlineSelectTab9
nmap <leader>- <Plug>AirlineSelectPrevTab
nmap <leader>+ <Plug>AirlineSelectNextTab
Note: Mappings will be ignored within a NERDTree buffer.
Note: In buffer_idx_mode these mappings won't change the
current tab, but switch to the buffer visible in that tab.
Use |gt| for switching tabs.
In tabmode, those mappings will switch to the specified tab.
* defines the name of a formatter for how buffer names are displayed. >
let g:airline#extensions#tabline#formatter = 'default'