ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* Re: Custom parameters/options for t-vim
  2011-08-30 14:27 Custom parameters/options for t-vim Andreas Schneider
@ 2011-08-29 21:35 ` Aditya Mahajan
  2011-08-31  7:15   ` Andreas Schneider
  0 siblings, 1 reply; 6+ messages in thread
From: Aditya Mahajan @ 2011-08-29 21:35 UTC (permalink / raw)
  To: mailing list for ConTeXt users

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
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Custom parameters/options for t-vim
@ 2011-08-30 14:27 Andreas Schneider
  2011-08-29 21:35 ` Aditya Mahajan
  0 siblings, 1 reply; 6+ messages in thread
From: Andreas Schneider @ 2011-08-30 14:27 UTC (permalink / raw)
  To: mailing list for ConTeXt users

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
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Custom parameters/options for t-vim
  2011-08-29 21:35 ` Aditya Mahajan
@ 2011-08-31  7:15   ` Andreas Schneider
  2011-08-31 23:00     ` Aditya Mahajan
  0 siblings, 1 reply; 6+ messages in thread
From: Andreas Schneider @ 2011-08-31  7:15 UTC (permalink / raw)
  To: mailing list for ConTeXt users

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
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Custom parameters/options for t-vim
  2011-08-31  7:15   ` Andreas Schneider
@ 2011-08-31 23:00     ` Aditya Mahajan
  2011-09-03  6:58       ` Aditya Mahajan
  0 siblings, 1 reply; 6+ messages in thread
From: Aditya Mahajan @ 2011-08-31 23:00 UTC (permalink / raw)
  To: mailing list for ConTeXt users

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
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Custom parameters/options for t-vim
  2011-08-31 23:00     ` Aditya Mahajan
@ 2011-09-03  6:58       ` Aditya Mahajan
  2011-09-06  9:07         ` Andreas Schneider
  0 siblings, 1 reply; 6+ messages in thread
From: Aditya Mahajan @ 2011-09-03  6:58 UTC (permalink / raw)
  To: mailing list for ConTeXt users

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

___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Custom parameters/options for t-vim
  2011-09-03  6:58       ` Aditya Mahajan
@ 2011-09-06  9:07         ` Andreas Schneider
  0 siblings, 0 replies; 6+ messages in thread
From: Andreas Schneider @ 2011-09-06  9:07 UTC (permalink / raw)
  To: mailing list for ConTeXt users

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
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2011-09-06  9:07 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-08-30 14:27 Custom parameters/options for t-vim Andreas Schneider
2011-08-29 21:35 ` Aditya Mahajan
2011-08-31  7:15   ` Andreas Schneider
2011-08-31 23:00     ` Aditya Mahajan
2011-09-03  6:58       ` Aditya Mahajan
2011-09-06  9:07         ` Andreas Schneider

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).