![](https://secure.gravatar.com/avatar/c5ae4f9aa0d3a9bd5376e92b322c3e50.jpg?s=120&d=mm&r=g)
On Tue, 30 Aug 2011, Andreas Schneider wrote:
I worked with t-vim a bit more and encountered a small problem with the way vim handles syntax definitions. Some of them have several modes that get activated by setting a variable first. For example the syntax "sh" (shell scripts) can be enhanced for bash, ksh, etc.
Example: let g:is_bash=1 set syntax=sh
Now a line like "export foo=bar" is highlighted differently than when I would omit the "let g:is_bash=1".
Therefore I would propose another options to \setupvimtyping to specify custom options to be passed to vim. Preferably they should be passed at least before the "set syntax=..." line to make sure that this particular case -- i.e. switching syntax modes -- works well (which may be the only necessary case).
That is certainly possible, but the exact solution depends on how robust you want it to be. I can easily add an option so that \definevimtyping [....] [extras={let g:is_bash=1}] will pass the argument to vim. However, string arguments like \definevimtyping [....] [extras={let g:name="Whatever"}] will not work. The reason is that, t-vim first creates a command line argument that is passed to mtxrun. mtxrun parses the entire expression, including all the options, When mtxrun figures out that all the arguments were meant for an external program, it recreates the list of arguments (to the best of its abilities), and passes the arguments to the shell. Then the shell tries to interpret the quotes. I haven't been able to find a solution that will work correctly though these three transformations. Another option is to write everything to an external file and source it as a vimrc file. So, you could do: \definevimtyping [...] [vimrc=shell] \startvimrc[shell] let g:is_bash = 1 \stopvimrc This requires more coding, but is much more flexible than the first option. Do all syntax highlighting options work with 0/1 parameters? If so, then the first alternative is easiest. Aditya