Hi, 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). -- Best Regards, Andreas
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
On 29.08.2011 23:35, Aditya Mahajan wrote:
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.
As far as I can see, most of the relevant options (if not all) are 0/1 switches, so the first alternative should be enough. Thanks to the pipe syntax of vim's command mode, it might be even possible specify more parameters that way. [extras={let g:foo=bar | let g:shaz=bot}] -- at least vim accepts that usually, I guess it doesn't make a difference if specified as commandline parameter. However I also like the idea of the optional vimrc via buffer. I think it might be a nice-to-have feature for the ToDo list :-) Thank you for the analysis and for coming up with these possible implementations! -- Best Regards, Andreas
On Wed, 31 Aug 2011, Andreas Schneider wrote:
However I also like the idea of the optional vimrc via buffer. I think it might be a nice-to-have feature for the ToDo list :-)
In the end, adding a vimrc feature was not too difficult, so I have added that. See the dev branch at github. For usage, see the example at tests/vim/vimrc.tex. I have not tested this feature beyond that test file. Aditya
On Wed, 31 Aug 2011, Aditya Mahajan wrote:
On Wed, 31 Aug 2011, Andreas Schneider wrote:
However I also like the idea of the optional vimrc via buffer. I think it might be a nice-to-have feature for the ToDo list :-)
In the end, adding a vimrc feature was not too difficult, so I have added that. See the dev branch at github. For usage, see the example at tests/vim/vimrc.tex.
I uploaded a new version of vim module with this feature. See 'Tuning color schemes' in the user-guide for a terse documentation. Aditya
On 03.09.2011 08:58, Aditya Mahajan wrote:
On Wed, 31 Aug 2011, Aditya Mahajan wrote:
On Wed, 31 Aug 2011, Andreas Schneider wrote:
However I also like the idea of the optional vimrc via buffer. I think it might be a nice-to-have feature for the ToDo list :-)
In the end, adding a vimrc feature was not too difficult, so I have added that. See the dev branch at github. For usage, see the example at tests/vim/vimrc.tex.
I uploaded a new version of vim module with this feature. See 'Tuning color schemes' in the user-guide for a terse documentation.
Aditya
Sorry for the late answer, I've been on the road a lot the last few days and didn't have the time to test the new changes. Anyway, I now did test them and it works very well. Thanks for implementing this very versatile feature! :-) -- Best Regards, Andreas
participants (2)
-
Aditya Mahajan
-
Andreas Schneider