Re: [NTG-context] Custom color schemes in t-vim

2020-05-17 Thread Aditya Mahajan

On Sun, 17 May 2020, Nicola wrote:

2. The wiki has no mention of \startcolorscheme... \stopcolorscheme or
  \setups. An example of two would be very welcome!


Added documentation: https://github.com/adityam/filter/blob/dev/vim-README.md

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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___


Re: [NTG-context] Custom color schemes in t-vim

2020-05-17 Thread Aditya Mahajan

On Sun, 17 May 2020, Nicola wrote:


On 2020-05-17, Aditya Mahajan  wrote:

Since I already map the minor groups to preferred groups in `t-vim`, I think
that a good compromise is to enable the minor groups by default. I can do
that by adding statements similar to those above in `2context.vim`. This will
not have any visual impact on any existing code, but will allow those who
want to tweak the highlighting of minor groups to define their own syntax
highlighting.


Uploaded a new version with a fix.


Thanks for looking into it. I will download and test that soon.

A couple of remarks:

1. In one of my old documents, I had this command inside the colorscheme
  block:

   \setups{vim-minor-groups}

  Was that to achieve the same purpose?


Yes. This setup maps the minor groups to preferred groups.


2. The wiki has no mention of \startcolorscheme... \stopcolorscheme or
  \setups. An example of two would be very welcome!


OK. I will add that.

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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___


Re: [NTG-context] Custom color schemes in t-vim

2020-05-17 Thread Nicola
On 2020-05-17, Nicola  wrote:
> On 2020-05-17, Aditya Mahajan  wrote:

>> Uploaded a new version with a fix.

I have tried the latest beta and, indeed, it now seems to work as
expected.

Thanks!
Nicola


___
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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___


Re: [NTG-context] Custom color schemes in t-vim

2020-05-17 Thread Nicola
On 2020-05-17, Aditya Mahajan  wrote:
>> Since I already map the minor groups to preferred groups in `t-vim`, I think
>> that a good compromise is to enable the minor groups by default. I can do
>> that by adding statements similar to those above in `2context.vim`. This will
>> not have any visual impact on any existing code, but will allow those who
>> want to tweak the highlighting of minor groups to define their own syntax
>> highlighting.
>
> Uploaded a new version with a fix.

Thanks for looking into it. I will download and test that soon.

A couple of remarks:

1. In one of my old documents, I had this command inside the colorscheme
   block:

\setups{vim-minor-groups}

   Was that to achieve the same purpose?

2. The wiki has no mention of \startcolorscheme... \stopcolorscheme or
   \setups. An example of two would be very welcome!

Nicola

___
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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___


Re: [NTG-context] Custom color schemes in t-vim

2020-05-17 Thread Aditya Mahajan
Since I already map the minor groups to preferred groups in `t-vim`, I think 
that a good compromise is to enable the minor groups by default. I can do 
that by adding statements similar to those above in `2context.vim`. This will 
not have any visual impact on any existing code, but will allow those who 
want to tweak the highlighting of minor groups to define their own syntax 
highlighting.


Uploaded a new version with a fix.

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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___


Re: [NTG-context] Custom color schemes in t-vim

2020-05-17 Thread Aditya Mahajan

On Sat, 16 May 2020, Aditya Mahajan wrote:


On Sat, 16 May 2020, Nicola wrote:


On 2020-05-16, Aditya Mahajan  wrote:

On Sat, 16 May 2020, Aditya Mahajan wrote:



Moreover, if you comment line line 126 of `2context.vim`

 "let s:id  = synIDtrans (s:id)

[If you make a local copy of 2context.vim, then you need to run the
file with `--mode=dev-vim` to ensure that the local copy is used]

Then the ruby example generates the following file:

\SYNBOL{}\SYN[rubyComment]{# Ruby program listing}\SYNEOL{}
\SYNBOL{}\SYN[rubyDefine]{def}\SYN[rubyMethodBlock]{ 

}\SYN[rubyMethodName]{foobar}\SYNEOL{}
\SYNBOL{}\SYN[rubyMethodBlock]{ 
print(}\SYN[rubyStringDelimiter]{"}\SYN[rubyString]{Hello 
World}\SYN[rubyStringDelimiter]{"}\SYN[rubyMethodBlock]{)}\SYNEOL{}

\SYNBOL{}\SYN[rubyDefine]{end}\SYNEOL{}

So, if you are willing to define wrappers for all ruby syntax blocks,
then I can provide a configuration option so that `2context` does not
apply that line.



That might provide a finer control over the highlighting, but the main
issue here seems to be that the generated file has Identifier instead of
Function, Special instead of Delimiter and Constant instead of String.
Looking at 2context.vim, AFAICS s:id_name seems computed correctly.
Maybe, the script does not set the appropriate filetype?


filetype is set correctly (since we get `ruby` options), but something 
weird is happening even with 2html.vim. Here is a minimal example:


Figured out what is happening. From `:he syntax`

"The names marked with * are the preferred groups; the others are minor groups.
For the preferred groups, the "syntax.vim" file contains default highlighting.
The minor groups are linked to the preferred groups, so they get the same
highlighting.  You can override these defaults by using ":highlight" commands
after sourcing the "syntax.vim" file."

All three `Function`, `Delimiter` and `String` are minor groups, so they get 
mapped to the preferred groups, which are `Identifier`, `Special`, and 
`Constant`, respectively. Most colorschemes define colors for minor groups as 
well, but since we are not loading any colorscheme, the minor groups are mapped 
to preferred groups, and we only get the preferred groups in the output.

Now that I know what is happening, it is relatively easy to fix.

```
\definecolor[colorone][r=0.251, g=0.349, b=0.322]
\definecolor[colortwo][r=0.612, g=0.608, b=0.478]
\definecolor[colorthree]  [r=1.0,   g=0.827, b=0.576]
\definecolor[colorfour]   [r=1.0,   g=0.592, b=0.310]
\definecolor[colorfive]   [r=0.960, g=0.310, b=0.161]
\definecolor[nearlywhite] [r=0.988, g=0.988, b=0.988]

\setupinteraction[state=start]
\setupcolors[textcolor=colorone]
\setupbackgrounds[page][background=color,backgroundcolor=nearlywhite]

\usemodule[vim]

\startvimrc[name=minor-groups]
hi Function  cterm=NONE
hi Stringcterm=NONE
hi Delimiter cterm=NONE
\stopvimrc


\startcolorscheme[oceansunset]
  \definesyntaxgroup[Comment] [color={colorfive},style=italic]
  \definesyntaxgroup[Function][color={colorfive},style=italic]
\stopcolorscheme

\definevimtyping[RUBY]
[
  syntax=ruby,
  alternative=oceansunset,
  escape=on, %NOTE, the comma was missing in your test file
  % Without the comma, the option is not set
  extras=minor-groups,
]

\starttext
\startRUBY
# Ruby program listing
def foobar
  print("Hello World")
end
\stopRUBY
\stoptext
```

Since I already map the minor groups to preferred groups in `t-vim`, I think 
that a good compromise is to enable the minor groups by default. I can do that 
by adding statements similar to those above in `2context.vim`. This will not 
have any visual impact on any existing code, but will allow those who want to 
tweak the highlighting of minor groups to define their own syntax highlighting.

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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___


Re: [NTG-context] Custom color schemes in t-vim

2020-05-16 Thread Aditya Mahajan

On Sat, 16 May 2020, Nicola wrote:


On 2020-05-16, Aditya Mahajan  wrote:

On Sat, 16 May 2020, Aditya Mahajan wrote:



Moreover, if you comment line line 126 of `2context.vim`

 "let s:id  = synIDtrans (s:id)

[If you make a local copy of 2context.vim, then you need to run the
file with `--mode=dev-vim` to ensure that the local copy is used]

Then the ruby example generates the following file:

\SYNBOL{}\SYN[rubyComment]{# Ruby program listing}\SYNEOL{}
\SYNBOL{}\SYN[rubyDefine]{def}\SYN[rubyMethodBlock]{ 
}\SYN[rubyMethodName]{foobar}\SYNEOL{}
\SYNBOL{}\SYN[rubyMethodBlock]{  
print(}\SYN[rubyStringDelimiter]{"}\SYN[rubyString]{Hello 
World}\SYN[rubyStringDelimiter]{"}\SYN[rubyMethodBlock]{)}\SYNEOL{}
\SYNBOL{}\SYN[rubyDefine]{end}\SYNEOL{}

So, if you are willing to define wrappers for all ruby syntax blocks,
then I can provide a configuration option so that `2context` does not
apply that line.



That might provide a finer control over the highlighting, but the main
issue here seems to be that the generated file has Identifier instead of
Function, Special instead of Delimiter and Constant instead of String.
Looking at 2context.vim, AFAICS s:id_name seems computed correctly.
Maybe, the script does not set the appropriate filetype?


filetype is set correctly (since we get `ruby` options), but something 
weird is happening even with 2html.vim. Here is a minimal example:

```test.rb
# Ruby program listing
def foobar
  print("Hello World")
end
```

Run:

vim -u NONE -c "syntax manual" -c "set syntax=ruby" -c "source 
/usr/share/nvim/runtime/syntax/2html.vim" -c "wqa" test.rb

gives

```test.rb.html
http://www.w3.org/TR/html4/strict.dtd;>


...



# Ruby program listing
def foobar
  print(Hello World)
end





```

which is similar to what 2context.vim gets. If I source tohtml.vim or 
2context.vim from an existing vim session, then the tags are correct. I have 
not been able to figure out why this is happening.

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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___


Re: [NTG-context] Custom color schemes in t-vim

2020-05-16 Thread Nicola
On 2020-05-16, Aditya Mahajan  wrote:
> On Sat, 16 May 2020, Aditya Mahajan wrote:

> Moreover, if you comment line line 126 of `2context.vim`
>
>  "let s:id  = synIDtrans (s:id)
>
> [If you make a local copy of 2context.vim, then you need to run the
> file with `--mode=dev-vim` to ensure that the local copy is used]
>
> Then the ruby example generates the following file:
>
> \SYNBOL{}\SYN[rubyComment]{# Ruby program listing}\SYNEOL{}
> \SYNBOL{}\SYN[rubyDefine]{def}\SYN[rubyMethodBlock]{ 
> }\SYN[rubyMethodName]{foobar}\SYNEOL{}
> \SYNBOL{}\SYN[rubyMethodBlock]{  
> print(}\SYN[rubyStringDelimiter]{"}\SYN[rubyString]{Hello 
> World}\SYN[rubyStringDelimiter]{"}\SYN[rubyMethodBlock]{)}\SYNEOL{}
> \SYNBOL{}\SYN[rubyDefine]{end}\SYNEOL{}
>
> So, if you are willing to define wrappers for all ruby syntax blocks,
> then I can provide a configuration option so that `2context` does not
> apply that line.

That might provide a finer control over the highlighting, but the main
issue here seems to be that the generated file has Identifier instead of
Function, Special instead of Delimiter and Constant instead of String.
Looking at 2context.vim, AFAICS s:id_name seems computed correctly.
Maybe, the script does not set the appropriate filetype?

Nicola


___
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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___


Re: [NTG-context] Custom color schemes in t-vim

2020-05-16 Thread Aditya Mahajan

On Sat, 16 May 2020, Aditya Mahajan wrote:


On Sat, 16 May 2020, Nicola wrote:


On 2020-05-14, Aditya Mahajan  wrote:

On Thu, 14 May 2020, Nicola wrote:


Quick question: Is \startcolorscheme... \stopcolorscheme (still)
supported by t-vim?



It is supposed to work. If it doesn't, then it is a bug. Could you
provide a complete MWE.


Please find a MWE at the bottom of this post.

The expected behaviour is that the keyword `function` in the JavaScript
snippet and `foobar` in the Ruby snippet should be colored and in
italics, as comments are. The respective Vim highlight groups are
`javaScriptFunction` and `rubyMethodName`, which both resolve to
`Function`.


The reason that there is no highlighting is because the generated `.vimout` 
does not contain any `\SYN[rubyMethodName]` or `\SYN[javaScriptFunction]` for 
the following reason:


Vim has the concept of a hierarchy of names for the syntax highlighting 
regions. For example, $VIMRUNTIME/syntax/ruby.rb contains the following 
lines:


hi def link rubyMethodName  rubyFunction
hi def link rubyFunction  Function

So, `rubyMethodName` maps to `rubyFunction`, which in turn maps to 
`Function`. Now, a vim colorscheme first checks if a highlighting style is 
available for `rubyMethodName`; if not it tries `rubyFunction`; and if not it 
tries `Function`.


Although something similar might have been possible in 2context.vim, I follow 
the `TOHtml` function of vim, and simply created a single tag for each syntax 
highlighting element, which in this case is `Function`. So, there is no tag 
generated for `rubyMethodName` and that is why changing the syntaxhighlight 
for that doesn't change anything.


Moreover, if you comment line line 126 of `2context.vim`

"let s:id  = synIDtrans (s:id)

[If you make a local copy of 2context.vim, then you need to run the file with 
`--mode=dev-vim` to ensure that the local copy is used]

Then the ruby example generates the following file:

\SYNBOL{}\SYN[rubyComment]{# Ruby program listing}\SYNEOL{}
\SYNBOL{}\SYN[rubyDefine]{def}\SYN[rubyMethodBlock]{ 
}\SYN[rubyMethodName]{foobar}\SYNEOL{}
\SYNBOL{}\SYN[rubyMethodBlock]{  
print(}\SYN[rubyStringDelimiter]{"}\SYN[rubyString]{Hello 
World}\SYN[rubyStringDelimiter]{"}\SYN[rubyMethodBlock]{)}\SYNEOL{}
\SYNBOL{}\SYN[rubyDefine]{end}\SYNEOL{}

So, if you are willing to define wrappers for all ruby syntax blocks, then I 
can provide a configuration option so that `2context` does not apply that line.

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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___


Re: [NTG-context] Custom color schemes in t-vim

2020-05-16 Thread Aditya Mahajan

On Sat, 16 May 2020, Nicola wrote:


On 2020-05-14, Aditya Mahajan  wrote:

On Thu, 14 May 2020, Nicola wrote:


Quick question: Is \startcolorscheme... \stopcolorscheme (still)
supported by t-vim?



It is supposed to work. If it doesn't, then it is a bug. Could you
provide a complete MWE.


Please find a MWE at the bottom of this post.

The expected behaviour is that the keyword `function` in the JavaScript
snippet and `foobar` in the Ruby snippet should be colored and in
italics, as comments are. The respective Vim highlight groups are
`javaScriptFunction` and `rubyMethodName`, which both resolve to
`Function`.


The reason that there is no highlighting is because the generated `.vimout` 
does not contain any `\SYN[rubyMethodName]` or `\SYN[javaScriptFunction]` for 
the following reason:

Vim has the concept of a hierarchy of names for the syntax highlighting 
regions. For example, $VIMRUNTIME/syntax/ruby.rb contains the following lines:

hi def link rubyMethodName  rubyFunction
hi def link rubyFunction  Function

So, `rubyMethodName` maps to `rubyFunction`, which in turn maps to `Function`. 
Now, a vim colorscheme first checks if a highlighting style is available for 
`rubyMethodName`; if not it tries `rubyFunction`; and if not it tries 
`Function`.

Although something similar might have been possible in 2context.vim, I follow 
the `TOHtml` function of vim, and simply created a single tag for each syntax 
highlighting element, which in this case is `Function`. So, there is no tag 
generated for `rubyMethodName` and that is why changing the syntaxhighlight for 
that doesn't change anything.

Now, as I was looking into this, I noticed that `foobar` gets mapped to 
`Identifier` rather than `Function`. I am not sure why that is happening and I 
will look into that.

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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___


Re: [NTG-context] Custom color schemes in t-vim

2020-05-16 Thread Nicola
On 2020-05-14, Aditya Mahajan  wrote:
> On Thu, 14 May 2020, Nicola wrote:
>
>> Quick question: Is \startcolorscheme... \stopcolorscheme (still)
>> supported by t-vim?

> It is supposed to work. If it doesn't, then it is a bug. Could you
> provide a complete MWE.

Please find a MWE at the bottom of this post.

The expected behaviour is that the keyword `function` in the JavaScript
snippet and `foobar` in the Ruby snippet should be colored and in
italics, as comments are. The respective Vim highlight groups are
`javaScriptFunction` and `rubyMethodName`, which both resolve to
`Function`.

The actual behaviour is that comments are highlighted correctly, but
I do not get any syntax highlighting for functions.

Thanks for t-vim, btw: I can't express in words how nice an idea it is!

Nicola


\setupcolors[state=start]

\definecolor[colorone][r=0.251, g=0.349, b=0.322]
\definecolor[colortwo][r=0.612, g=0.608, b=0.478]
\definecolor[colorthree]  [r=1.0,   g=0.827, b=0.576]
\definecolor[colorfour]   [r=1.0,   g=0.592, b=0.310]
\definecolor[colorfive]   [r=0.960, g=0.310, b=0.161]
\definecolor[nearlywhite] [r=0.988, g=0.988, b=0.988]

\setupinteraction[state=start]
\setupcolors[textcolor=colorone]
\setupbackgrounds[page][background=color,backgroundcolor=nearlywhite]

\usemodule[vim]
\unprotect
\startcolorscheme[oceansunset]
  \definesyntaxgroup[Comment][\c!color={colorfive},\c!style=italic]
  \definesyntaxgroup[Function][\c!color={colorfive},\c!style=italic]
  % \definesyntaxgroup[rubyMethodName][\c!color={colorfive},\c!style=italic]
  % \definesyntaxgroup[javaScriptFunction][\c!color={colorfive},\c!style=italic]
\stopcolorscheme
\protect

\definevimtyping[JAVASCRIPT][
  syntax=javascript,
  alternative=oceansunset,
  escape=on
]

\definevimtyping[RUBY][
  syntax=ruby,
  alternative=oceansunset,
  escape=on
]

\starttext
\startJAVASCRIPT
// JavaScript program listing
function foobar() {
  print("Hello World");
}
\stopJAVASCRIPT

\startRUBY
# Ruby program listing
def foobar
  print("Hello World")
end
\stopRUBY
\stoptext


___
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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___


Re: [NTG-context] Custom color schemes in t-vim

2020-05-14 Thread Aditya Mahajan

On Thu, 14 May 2020, Nicola wrote:


Quick question: Is \startcolorscheme... \stopcolorscheme (still)
supported by t-vim?

In a template I wrote long time ago to typeset code, I have:

   \usemodule[vim]
   \unprotect
   \startcolorscheme[oceansunset]
 \definesyntaxgroup[Comment][\c!color={colortwo},\c!style=italic]
 % etc.
   \stopcolorscheme
   \protect

which I use as described in the wiki:

   \definevimtyping
[...]
[...
 alternative=oceansunset,
 ...]

But that does not seem to have any effect (if I change the colors, the
syntax highlighting does not change). I can use pscolor and
blackandwhite, though. I see that \startcolorscheme is not documented,
so maybe there is another mechanism?


It is supposed to work. If it doesn't, then it is a bug. Could you provide a 
complete MWE.

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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___


[NTG-context] Custom color schemes in t-vim

2020-05-14 Thread Nicola
Quick question: Is \startcolorscheme... \stopcolorscheme (still)
supported by t-vim?

In a template I wrote long time ago to typeset code, I have:

\usemodule[vim]
\unprotect
\startcolorscheme[oceansunset]
  \definesyntaxgroup[Comment][\c!color={colortwo},\c!style=italic]
  % etc.
\stopcolorscheme
\protect

which I use as described in the wiki:

\definevimtyping
 [...]
 [...
  alternative=oceansunset,
  ...]

But that does not seem to have any effect (if I change the colors, the
syntax highlighting does not change). I can use pscolor and
blackandwhite, though. I see that \startcolorscheme is not documented,
so maybe there is another mechanism?

Nicola

___
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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___