diff --git a/autoload/airline/extensions.vim b/autoload/airline/extensions.vim index 385fcb6..8707dbd 100644 --- a/autoload/airline/extensions.vim +++ b/autoload/airline/extensions.vim @@ -63,12 +63,7 @@ function! airline#extensions#apply(...) return -1 endif - if &buftype == 'quickfix' - let w:airline_section_a = '%q' - let w:airline_section_b = '%{get(w:, "quickfix_title", "")}' - let w:airline_section_c = '' - let w:airline_section_x = '' - elseif &buftype == 'help' + if &buftype == 'help' call airline#extensions#apply_left_override('Help', '%f') let w:airline_section_x = '' let w:airline_section_y = '' @@ -127,6 +122,8 @@ function! airline#extensions#load() " non-trivial number of external plugins use eventignore=all, so we need to account for that autocmd CursorMoved * call sync_active_winnr() + call airline#extensions#quickfix#init(s:ext) + if get(g:, 'loaded_unite', 0) call airline#extensions#unite#init(s:ext) endif diff --git a/autoload/airline/extensions/quickfix.vim b/autoload/airline/extensions/quickfix.vim new file mode 100644 index 0000000..7afad86 --- /dev/null +++ b/autoload/airline/extensions/quickfix.vim @@ -0,0 +1,37 @@ +" MIT License. Copyright (c) 2013 Bailey Ling. +" vim: et ts=2 sts=2 sw=2 + +let g:airline#extensions#quickfix#quickfix_text = 'Quickfix' +let g:airline#extensions#quickfix#location_text = 'Location' + +function! airline#extensions#quickfix#apply(...) + if &buftype == 'quickfix' + let w:airline_section_a = s:get_text() + let w:airline_section_b = '%{get(w:, "quickfix_title", "")}' + let w:airline_section_c = '' + let w:airline_section_x = '' + endif +endfunction + +function! airline#extensions#quickfix#init(ext) + call a:ext.add_statusline_func('airline#extensions#quickfix#apply') +endfunction + +function! s:get_text() + redir => buffers + silent ls + redir END + + let nr = bufnr('%') + for buf in split(buffers, '\n') + if match(buf, '\v^\s+'.nr) > -1 + if match(buf, '\[Quickfix List\]') > -1 + return g:airline#extensions#quickfix#quickfix_text + else + return g:airline#extensions#quickfix#location_text + endif + endif + endfor + return '' +endfunction + diff --git a/doc/airline.txt b/doc/airline.txt index 9a2d465..67afa03 100644 --- a/doc/airline.txt +++ b/doc/airline.txt @@ -233,6 +233,18 @@ configuration values that you can use. " Note: set to an empty dictionary to disable truncation. let g:airline#extensions#default#section_truncate_width = {} < +------------------------------------- *airline-quickfix* +The quickfix extension is a simple built-in extension which determines +whether the buffer is a quickfix or location list buffer, and adjusts the +title accordingly. + +* configure the title text for quickfix buffers > + let g:airline#extensions#quickfix#quickfix_text = 'Quickfix' +< +* configure the title text for location list buffers > + let g:airline#extensions#quickfix#location_text = 'Location' +< + ------------------------------------- *airline-bufferline* vim-bufferline