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

Aditya Mahajan adityam at umich.edu
Sat May 16 17:03:29 CEST 2020


On Sat, 16 May 2020, Aditya Mahajan wrote:

> On Sat, 16 May 2020, Nicola wrote:
>
>> On 2020-05-14, Aditya Mahajan <adityam at umich.edu> 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


More information about the ntg-context mailing list