I wrote a (perl) script that generates a syntax highlight vim script (tags.vim) from the tags file (generated by ctags). However, when I open a file I have to manually load it. I can fix that by starting vim with the right command line, but once inside vim every time I switch source file (for example by pressing ^] to jump to a definition in another file) the syntax highlighting is lost and I need to re-source my generated tags.vim.
Is there a way to execute a command (:so tags.vim) or source a script etc, automatically whenever the current source file changes (by :n, :N, ^] or :tnext etc.)?
:highlight, which is Vim-global, it might make more sense to change the syntax definition for your filetype (or make a custom filetype for your custom syntax). This way, your syntax definition (and consequently highlights) are buffer-local, and would persist across buffer switching...