From 723987eca9fde4e69548e2cdfd7f9299138ed02d Mon Sep 17 00:00:00 2001 From: Mo Hyun Date: Mon, 23 Jul 2018 13:05:34 -0700 Subject: [PATCH 1/2] Add vim-grepper extension - Displays a segment when a grepper search is running --- autoload/airline/extensions.vim | 5 +++++ autoload/airline/extensions/grepper.vim | 19 +++++++++++++++++++ autoload/airline/init.vim | 3 ++- doc/airline.txt | 6 ++++++ 4 files changed, 32 insertions(+), 1 deletion(-) create mode 100644 autoload/airline/extensions/grepper.vim diff --git a/autoload/airline/extensions.vim b/autoload/airline/extensions.vim index cb94604f..34ad3018 100644 --- a/autoload/airline/extensions.vim +++ b/autoload/airline/extensions.vim @@ -309,6 +309,11 @@ function! airline#extensions#load() call add(loaded_ext, 'gutentags') endif + if (get(g:, 'airline#extensions#grepper#enabled', 1) && get(g:, 'loaded_grepper', 0)) + call airline#extensions#grepper#init(s:ext) + call add(loaded_ext, 'grepper') + endif + if (get(g:, 'airline#extensions#xkblayout#enabled', 1) && exists('g:XkbSwitchLib')) call airline#extensions#xkblayout#init(s:ext) call add(loaded_ext, 'xkblayout') diff --git a/autoload/airline/extensions/grepper.vim b/autoload/airline/extensions/grepper.vim new file mode 100644 index 00000000..3e5debf3 --- /dev/null +++ b/autoload/airline/extensions/grepper.vim @@ -0,0 +1,19 @@ +" MIT License. Copyright (c) 2014-2018 Mathias Andersson et al. +" vim: et ts=2 sts=2 sw=2 + +" Heavily derived from the Gutentags extension + +scriptencoding utf-8 + +if !get(g:, 'loaded_grepper', 0) + finish +endif + +function! airline#extensions#grepper#status() + let msg = grepper#statusline() + return empty(msg) ? '' : 'grepper' +endfunction + +function! airline#extensions#grepper#init(ext) + call airline#parts#define_function('grepper', 'airline#extensions#grepper#status') +endfunction diff --git a/autoload/airline/init.vim b/autoload/airline/init.vim index 73b7f558..faa4c299 100644 --- a/autoload/airline/init.vim +++ b/autoload/airline/init.vim @@ -151,6 +151,7 @@ function! airline#init#bootstrap() \ 'neomake_warning_count', 'ale_error_count', 'ale_warning_count']) call airline#parts#define_text('capslock', '') call airline#parts#define_text('gutentags', '') + call airline#parts#define_text('grepper', '') call airline#parts#define_text('xkblayout', '') call airline#parts#define_text('keymap', '') @@ -180,7 +181,7 @@ function! airline#init#sections() let g:airline_section_gutter = airline#section#create(['%=']) endif if !exists('g:airline_section_x') - let g:airline_section_x = airline#section#create_right(['tagbar', 'gutentags', 'filetype']) + let g:airline_section_x = airline#section#create_right(['tagbar', 'gutentags', 'grepper', 'filetype']) endif if !exists('g:airline_section_y') let g:airline_section_y = airline#section#create_right(['ffenc']) diff --git a/doc/airline.txt b/doc/airline.txt index 0cdd7070..d01be986 100644 --- a/doc/airline.txt +++ b/doc/airline.txt @@ -1002,6 +1002,12 @@ vim-gutentags * enable/disable vim-gutentags integration > let g:airline#extensions#gutentags#enabled = 1 +------------------------------------- *airline-grepper* +vim-grepper + +* enable/disable vim-grepper integration > + let g:airline#extensions#grepper#enabled = 1 + ------------------------------------- *airline-capslock* vim-capslock From 60eb44c94e539e86fdcd44e3814521de3b370092 Mon Sep 17 00:00:00 2001 From: Mo Hyun Date: Mon, 23 Jul 2018 14:27:59 -0700 Subject: [PATCH 2/2] Fix build error --- t/init.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/t/init.vim b/t/init.vim index b75d1851..64b7c6ce 100644 --- a/t/init.vim +++ b/t/init.vim @@ -34,7 +34,7 @@ describe 'init sections' end it 'section x should be filetype' - Expect g:airline_section_x == '%{airline#util#prepend("",0)}%{airline#util#wrap(airline#parts#filetype(),0)}' + Expect g:airline_section_x == '%{airline#util#prepend("",0)}%{airline#util#prepend("",0)}%{airline#util#wrap(airline#parts#filetype(),0)}' end it 'section y should be fenc and ff'