jsfaint / gen_tags.vim

Async plugin for vim and neovim to ease the use of ctags/gtags
https://vim.sourceforge.io/scripts/script.php?script_id=5499
MIT License
312 stars 42 forks source link

Add global accessor function for checking if any job is running #91

Closed Kamilcuk closed 3 years ago

Kamilcuk commented 3 years ago

This is so that this function may be used to implement custom notification messages that will call-back this funtion seeing if we are currently generating tags. I used it to implement airline plugin.

The airline plugin may be implemented then with:

""" in my vimrc """""""""
function! airline#extensions#gen_tags#enable_on_section_x(...)
    if get(g:, 'airline#extensions#gen_tags#enabled', 1) && (get(g:, 'loaded_gentags#gtags', 0) || get(g:, 'loaded_gentags#ctags', 0))
        call airline#parts#define_function('gen_tags', 'airline#extensions#gen_tags#status')
        let g:airline_section_x = airline#section#create_right(['gen_tags'])
    endif
endfunction
let g:airline#extensions#gen_tags#enabled = 1
call airline#add_statusline_func('airline#extensions#gen_tags#enable_on_section_x')

""""""""""""" in autoload """"""""""

if !get(g:, 'loaded_gentags#gtags', 0) && !get(g:, 'loaded_gentags#ctags', 0)
    finish
endif

function! airline#extensions#gen_tags#status()
  return gen_tags#job#is_running() != 0 ? 'Gen. gen_tags' : ''
  "      ^^^^^^^^^^^^^^^^^^^^^^^^^ this is needed
endfunction

function! airline#extensions#gen_tags#init(ext)
  call airline#parts#define_function('gen_tags', 'airline#extensions#gen_tags#status')
endfunction

which I guess will pull request to airline later.

jsfaint commented 3 years ago

Merged, thanks for the PR!