From 42b31b966b90b646d41cff4014ceba637640f33c Mon Sep 17 00:00:00 2001 From: Kamil Cukrowski Date: Fri, 16 Oct 2020 16:43:22 +0200 Subject: [PATCH] Add gen_tags.vim plugin support Display a "Gen. gen_tags" text in section x when gen_tags is generating tags, similar to gutentags support. --- CHANGELOG.md | 1 + autoload/airline/extensions.vim | 5 +++++ autoload/airline/extensions/gen_tags.vim | 19 +++++++++++++++++++ autoload/airline/init.vim | 3 ++- doc/airline.txt | 6 ++++++ t/init.vim | 2 +- 6 files changed, 34 insertions(+), 2 deletions(-) create mode 100644 autoload/airline/extensions/gen_tags.vim diff --git a/CHANGELOG.md b/CHANGELOG.md index f935c13c..08ed3424 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,7 @@ This is the Changelog for the vim-airline project. - [Vim-CMake](https://github.com/cdelledonne/vim-cmake) support - [battery.vim](https://github.com/lambdalisue/battery.vim) support - [nvim-lspconfig](https://github.com/neovim/nvim-lspconfig) support + - [gen_tags.vim](https://github.com/jsfaint/gen_tags.vim) support - Improvements - git branch can also be displayed using [gina.vim](https://github.com/lambdalisue/gina.vim) - coc extensions can also show additional status messages diff --git a/autoload/airline/extensions.vim b/autoload/airline/extensions.vim index 7d50bf5e..22f657bf 100644 --- a/autoload/airline/extensions.vim +++ b/autoload/airline/extensions.vim @@ -408,6 +408,11 @@ function! airline#extensions#load() call add(s:loaded_ext, 'gutentags') endif + if get(g:, 'airline#extensions#gen_tags#enabled', 1) && (get(g:, 'loaded_gentags#gtags', 0) || get(g:, 'loaded_gentags#ctags', 0)) + call airline#extensions#gen_tags#init(s:ext) + call add(s:loaded_ext, 'gen_tags') + endif + if (get(g:, 'airline#extensions#grepper#enabled', 1) && get(g:, 'loaded_grepper', 0)) call airline#extensions#grepper#init(s:ext) call add(s:loaded_ext, 'grepper') diff --git a/autoload/airline/extensions/gen_tags.vim b/autoload/airline/extensions/gen_tags.vim new file mode 100644 index 00000000..c3952454 --- /dev/null +++ b/autoload/airline/extensions/gen_tags.vim @@ -0,0 +1,19 @@ +" MIT License. Copyright (c) 2014-2020 Mathias Andersson et al. +" Written by Kamil Cukrowski 2020 +" Plugin: https://github.com/jsfaint/gen_tags.vim +" vim: et ts=2 sts=2 sw=2 + +scriptencoding utf-8 + +if !(get(g:, 'loaded_gentags#gtags', 0) || !get(g:, 'loaded_gentags#ctags', 0)) + finish +endif + +function! airline#extensions#gen_tags#status(...) abort + return gen_tags#job#is_running() != 0 ? 'Gen. gen_tags' : '' +endfunction + +function! airline#extensions#gen_tags#init(ext) abort + call airline#parts#define_function('gen_tags', 'airline#extensions#gen_tags#status') +endfunction + diff --git a/autoload/airline/init.vim b/autoload/airline/init.vim index 7acc06d4..fc47e3e8 100644 --- a/autoload/airline/init.vim +++ b/autoload/airline/init.vim @@ -176,6 +176,7 @@ function! airline#init#bootstrap() call airline#parts#define_text('bookmark', '') call airline#parts#define_text('capslock', '') call airline#parts#define_text('gutentags', '') + call airline#parts#define_text('gen_tags', '') call airline#parts#define_text('grepper', '') call airline#parts#define_text('xkblayout', '') call airline#parts#define_text('keymap', '') @@ -211,7 +212,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(['bookmark', 'tagbar', 'vista', 'gutentags', 'omnisharp', 'grepper', 'filetype']) + let g:airline_section_x = airline#section#create_right(['bookmark', 'tagbar', 'vista', 'gutentags', 'gen_tags', 'omnisharp', '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 80cec944..b4b485c4 100644 --- a/doc/airline.txt +++ b/doc/airline.txt @@ -787,6 +787,12 @@ vim-gutentags * enable/disable vim-gutentags integration > let g:airline#extensions#gutentags#enabled = 1 +------------------------------------- *gen_tags.vim* +gen_tags.vim + +* enable/disable gen_tags.vim integration > + let g:airline#extensions#gen_tags#enabled = 1 + ------------------------------------- *airline-hunks* vim-gitgutter vim-signify diff --git a/t/init.vim b/t/init.vim index e92fb153..27e6644a 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#prepend("",0)}%{airline#util#prepend("",0)}%{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#prepend("",0)}%{airline#util#prepend("",0)}%{airline#util#prepend("",0)}%{airline#util#wrap(airline#parts#filetype(),0)}' end it 'section y should be fenc and ff'