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 String cterm=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