:colorscheme loses some syntax colouring

8 views
Skip to first unread message

Tarlika Elisabeth Schmitz

unread,
Feb 8, 2010, 1:24:45 PM2/8/10
to vim...@googlegroups.com
I have set up gvim as my Firefox text editor using the extension "It's
All Text" (https://addons.mozilla.org/en-US/firefox/addon/4125).


My MoinMoin wiki articles are prefixed with
## vim:filetype=moin
and I have a syntax file for MoinMoin.

When I load an article into gvim, it fires up with the correct syntax
highlighting. But when I then change the colour scheme, the syntax
highlighting for MoinMoin tables is lost. I can change between colour
schemes as much as I like; syntax highlting for MoinMoin tables will
not come back.

It does not make a difference which colour scheme I define in .gvimrc
as a default. The problem occurs regardless.

The reason why I would like to change the colour scheme on the fly is
that the colours my default scheme (pyte) uses for MoinMoin tables are
completely unreadable.

Any ideas what is causing the problem?

--

Best Regards,
Tarlika Elisabeth Schmitz

Andy Wokula

unread,
Feb 8, 2010, 2:29:23 PM2/8/10
to vim...@googlegroups.com

Buggy syntax file I guess.
I checked moin.vim v1.4.1 (Vimscript #1459).

It contains

--------------------------------
if version <600
syntax clear
elsif exists("b:current_syntax")
finish
endif

syn clear
hi clear
--------------------------------

The "hi clear" command should not be there!

And the "syn clear" commandis useless.
And "elsif" should become "elseif".

--
Andy

Tarlika Elisabeth Schmitz

unread,
Feb 8, 2010, 2:51:23 PM2/8/10
to vim...@googlegroups.com
On Mon, 08 Feb 2010 20:29:23 +0100
Andy Wokula <anw...@yahoo.de> wrote:

>Am 08.02.2010 19:24, schrieb Tarlika Elisabeth Schmitz:

>> I have set up gvim as my Firefox text editor [...]


>> and I have a syntax file for MoinMoin.
>>
>> When I load an article into gvim, it fires up with the correct syntax
>> highlighting. But when I then change the colour scheme, the syntax
>> highlighting for MoinMoin tables is lost.
>

>Buggy syntax file I guess.
>I checked moin.vim v1.4.1 (Vimscript #1459).

>--------------------------------
>if version <600
> syntax clear
>elsif exists("b:current_syntax")
> finish
>endif
>
>syn clear
>hi clear
>--------------------------------
>
>The "hi clear" command should not be there!
>
>And the "syn clear" commandis useless.
>And "elsif" should become "elseif".


Thank you for your quick response.

My syntax file is from 2nd Mar 2008. It does not contain these errors.

Andy Wokula

unread,
Feb 8, 2010, 3:15:11 PM2/8/10
to vim...@googlegroups.com
Am 08.02.2010 20:51, schrieb Tarlika Elisabeth Schmitz:
> My syntax file is from 2nd Mar 2008. It does not contain these errors.

Link?

--
Andy

Tarlika Elisabeth Schmitz

unread,
Feb 8, 2010, 4:04:59 PM2/8/10
to vim...@googlegroups.com


http://uploads.mitechie.com/configs/vim/vim/syntax/moin1_6.vim
This is what I am using.

I also found this one: http://moinmo.in/VimHighlighting (Jan 2008)


The January version does not colorize MoinMoin tables.

Table example:

||||||||
|| a || b || c ||
||||||||

a,b,c are cell content, the bars are separators. The March version
displays separators and content in different colours.

Andy Wokula

unread,
Feb 8, 2010, 4:44:12 PM2/8/10
to vim...@googlegroups.com, niem...@conectiva.com

Buggy as well ...

----------------------------------
if !exists("did_dic_syntax_inits")
let did_dic_syntax_inits = 1
hi link moinComment Comment
hi link moinInlineComment Comment
...
endif
----------------------------------

Once g:did_dic_syntax_inits is defined, it won't ever
be reset; the ":hi" commands get no chance to be executed again.

Not sure if this "if" condition can be safely removed, but
I'd give it a try (e.g. just comment it out).

--
Andy

@Gustavo - here is the full thread
http://groups.google.com/group/vim_use/browse_thread/thread/296b31684670182d#

Tarlika Elisabeth Schmitz

unread,
Feb 8, 2010, 5:25:07 PM2/8/10
to vim...@googlegroups.com
On Mon, 08 Feb 2010 22:44:12 +0100
Andy Wokula <anw...@yahoo.de> wrote:

>Am 08.02.2010 22:04, schrieb Tarlika Elisabeth Schmitz:
>> On Mon, 08 Feb 2010 21:15:11 +0100
>> Andy Wokula<anw...@yahoo.de> wrote:
>>
>>> Am 08.02.2010 20:51, schrieb Tarlika Elisabeth Schmitz:
>>
>> http://uploads.mitechie.com/configs/vim/vim/syntax/moin1_6.vim
>> This is what I am using.
>>
>> ||||||||

>> || a || b || c ||
>> ||||||||
>>
>> a,b,c are cell content, the bars are separators. The March version
>> displays separators and content in different colours.
>
>Buggy as well ...
>
>----------------------------------
>if !exists("did_dic_syntax_inits")
> let did_dic_syntax_inits = 1
> hi link moinComment Comment
> hi link moinInlineComment Comment
> ...
>endif
>----------------------------------
>
>Once g:did_dic_syntax_inits is defined, it won't ever
>be reset; the ":hi" commands get no chance to be executed again.
>
>Not sure if this "if" condition can be safely removed, but
>I'd give it a try (e.g. just comment it out).
>

Removed if/endif - makes no difference as far as my problem is
concerned.

Andy Wokula

unread,
Feb 8, 2010, 7:04:50 PM2/8/10
to vim...@googlegroups.com

Ok. The moin syntax file makes use of "hi def" statements, which
define explicit colors. These color settings will be removed
(:hi clear) when loading another color scheme, whereas color links
(:hi link ...) are not affected.


You can try to add the following code to your vimrc:

------------------------------------------
au ColorScheme * call s:AfterColorScheme()

func! s:AfterColorScheme()
hi moinBold term=bold cterm=bold gui=bold
hi moinItalic ctermfg=darkcyan gui=italic
hi moinSettings ctermfg=green guifg=green
hi moinPragma ctermfg=darkred guifg=darkred
hi moinStrike ctermfg=darkgray guifg=darkgray
hi moinTableMark ctermfg=yellow guifg=yellow
hi moinTableOpt ctermfg=darkyellow guifg=darkyellow
hi moinCode ctermfg=cyan guifg=cyan
hi moinLink ctermfg=red guifg=red
hi moinSmileys ctermfg=yellow guifg=yellow
endfunc
------------------------------------------

This explicitly sets the moin highlight groups again after switching to
another color scheme.


Alternatively, manually do
:e
or
:set syn=moin

--
Andy

Tarlika Elisabeth Schmitz

unread,
Feb 9, 2010, 5:29:37 AM2/9/10
to vim...@googlegroups.com
On Tue, 09 Feb 2010 01:04:50 +0100
Andy Wokula <anw...@yahoo.de> wrote:

>Am 08.02.2010 23:25, schrieb Tarlika Elisabeth Schmitz:
>> On Mon, 08 Feb 2010 22:44:12 +0100
>> Andy Wokula<anw...@yahoo.de> wrote:
>>
>>> Am 08.02.2010 22:04, schrieb Tarlika Elisabeth Schmitz:
>>>> On Mon, 08 Feb 2010 21:15:11 +0100
>>>> Andy Wokula<anw...@yahoo.de> wrote:
>>>>
>>>>> Am 08.02.2010 20:51, schrieb Tarlika Elisabeth Schmitz:
>>>>
>>>> http://uploads.mitechie.com/configs/vim/vim/syntax/moin1_6.vim
>>>> This is what I am using.
>>>>

>>>> [...]


>>>
>>> ----------------------------------
>>> if !exists("did_dic_syntax_inits")
>>> let did_dic_syntax_inits = 1
>>> hi link moinComment Comment
>>> hi link moinInlineComment Comment
>>> ...
>>> endif
>>> ----------------------------------
>>>
>>> Once g:did_dic_syntax_inits is defined, it won't ever
>>> be reset; the ":hi" commands get no chance to be executed again.
>>

>> Removed if/endif - makes no difference as far as my problem is
>> concerned.
>
>Ok. The moin syntax file makes use of "hi def" statements, which
>define explicit colors. These color settings will be removed
>(:hi clear) when loading another color scheme, whereas color links
>(:hi link ...) are not affected.
>
>
>You can try to add the following code to your vimrc:
>
>------------------------------------------
>au ColorScheme * call s:AfterColorScheme()
>
>func! s:AfterColorScheme()
> hi moinBold term=bold cterm=bold gui=bold

> [...]


> hi moinSmileys ctermfg=yellow guifg=yellow
>endfunc
>------------------------------------------
>
>This explicitly sets the moin highlight groups again after switching to
>another color scheme.
>
>
>Alternatively, manually do
> :e
>or
> :set syn=moin

I have not yet tried the .vimrc suggestion (a bit of a desparate
measure) but I have tried the other two:

Neither :e nor :set syn=moin take effect.

Andy Wokula

unread,
Feb 9, 2010, 6:53:21 AM2/9/10
to vim...@googlegroups.com
Am 09.02.2010 11:29, schrieb Tarlika Elisabeth Schmitz:
> On Tue, 09 Feb 2010 01:04:50 +0100
> Andy Wokula wrote:
>
>>>> Am 08.02.2010 22:04, schrieb Tarlika Elisabeth Schmitz:
>>>>> http://uploads.mitechie.com/configs/vim/vim/syntax/moin1_6.vim
>>>>> This is what I am using.
>
>> Ok. The moin syntax file makes use of "hi def" statements, which
>> define explicit colors. These color settings will be removed
>> (:hi clear) when loading another color scheme, whereas color links
>> (:hi link ...) are not affected.
>>
>>
>> You can try to add the following code to your vimrc:
>>
>> ------------------------------------------
>> au ColorScheme * call s:AfterColorScheme()
>>
>> func! s:AfterColorScheme()
>> hi moinBold term=bold cterm=bold gui=bold
>> [...]
>> hi moinSmileys ctermfg=yellow guifg=yellow
>> endfunc
>> ------------------------------------------
>>
>> This explicitly sets the moin highlight groups again after switching
>> to another color scheme.
>
> I have not yet tried the .vimrc suggestion (a bit of a desparate
> measure)

No, it's a normal thing to do. When a syntax file provides default
colors [1] that can be overridden by the user, then switching the color
scheme will wipe out these colors. You have to somehow restore the
original colors. To make this possible, the ColorScheme auto command
was added.

There is another alternative: Move your favorite color scheme scripts to
your ~\vimfiles\colors folder [2] and add the missing highlight groups.

[1] :h :hi-default
[2] look at the first entry of your 'runtimepath' and use that instead
of ~\vimfiles

--
Andy

Tarlika Elisabeth Schmitz

unread,
Feb 9, 2010, 3:55:28 PM2/9/10
to vim...@googlegroups.com
On Tue, 09 Feb 2010 01:04:50 +0100
Andy Wokula <anw...@yahoo.de> wrote:

This code snippet fixes the problem. When I change vim colour scheme
MoinMoin table colouring is no longer lost.

Thank you for your help!

Reply all
Reply to author
Forward
0 new messages