On Tue, Feb 27, 2007 at 07:04:13PM +0100, Ralf Schmitt wrote:
> Hi list
> 
> For now I've mapped the ctags command described in OmniCompletion
> plugin on a key to refresh project tags file.
> But very often I forget to update (press the hotkey) before I enter the
> omni completion. So it came to my mind to trigger ctag update run when
> I save (:w) a header file. 
> 
> - Does this make sense?
Yes it does. To generate tags you need the file beeing on disk (as long
as you aren't using a vim script to generate those tags .. which would
be slow ;)

> - any hint how I could add a function to :w for a special file type?

This is all done using autocommands.
Just register a BufWritePost command like this

(written of my head without testing)
augroup GenerateTags
  autocmd BufRead,BufNewFile *.c *.cpp *.h  call MyFuncToGenerateTags
  " using only a specia filetype:
  autocmd BufRead,BufNewFile * if &ft="c" | do something | endif
augroup end

I've also written a plugin providing a
TagCurrentDirectoryTagGroupXX
which does run the given tag command from the registered directory
automatically.

You can find a script installer here:
http://mawercer.de/marcweber/vim/vimlib/installers/vimlib_taghelper_installer_sourceme.vim

Its easy to manage adding tags of different libraries.
It looks like this:
call vl#lib#tags#taghelper#AddTagsToBufferTagList('c_lib_1')
call vl#lib#tags#taghelper#AddTagsToBufferTagList('c_lib')

If you're interested I'll assist you getting started as there may some lack of
documentation ;)

Marc

Reply via email to