basilgor / vim-autotags

vim plugin for easy ctags and cscope handling in a separate directory
21 stars 4 forks source link

Auto update on e.g CursorHold, BufWritePost etc. #6

Open hendrik-donner opened 11 years ago

hendrik-donner commented 11 years ago

Would be nice to have a silent call to AutotagsUpdate() on BufWritePost and (optionally) on CursorHold. Probably other events could make sense, too.

From my .vimrc: autocmd BufWritePost * silent call AutotagsUpdate() autocmd CursorHold * silent call AutotagsUpdate()

Edit: Well probably only for already initialized projects.

hendrik-donner commented 11 years ago

This works fine for me:

fun! AutotagsAutoUpdate()
    if s:AutotagsIsLoaded() != 0
        call AutotagsUpdate()
    endif
endfun

augroup PluginAutotags
    autocmd!

    autocmd BufWritePost * silent call AutotagsAutoUpdate()
    autocmd CursorHold * silent call AutotagsAutoUpdate()
augroup END

EDIT: I should note that i have zero experience with writting vim plugins and no real clue if what i'm doing here is sane :-)