VI colormappings for dcabe

Brian K. White brian at aljex.com
Wed Oct 15 16:00:34 PDT 2014


On 10/14/2014 12:54 PM, Jay Ashworth wrote:
> Who was it wrote these?  Brian?  Mark?
>
> They're actually pretty useful and spiffy, but there's two things I
> would change about them, one of which I can probably figure out how to
> do, and one of which is more opaque:
>
> The choice of color for the reverse video on the colons is a bit jarring;
> I think I'm going to try changing them to cyan.  What would actually be
> much more useful -- though I don't know if vim knows how -- is to make
> them *only be reverse if there aren't three of them on a line*.
>
> The other, more opaque thing (no, that wasn't it :-) is that it does
> quote-matching across lines, which, of course, dcabe generally does not
> (browse lookup definitions being the only exception I know of).  Is there
> a way to tell it to stop looking at the end of the line?  Arguments can,
> I suppose, be made both ways, but while I'm *writing* the code, it's a
> bit disconcerting to have a half dozen lines change color while I'm inside
> a quoted string...
>
>
> If you write a lot of code in VIM, you probably oughtta grab these.  :-)
>
> Cheers
> -- jra
>

He's talking about these:
http://www.aljex.com/fp/vim/

It were me. I haven't used them myself since 10 or 12 years ago when I 
made them! It got only about as far as proof of concept, where I hadn't 
put too much thought into color combinations because selecting other 
colors is trivial compared to getting the syntax recognition working 
right at all.

I do remember that the colons were deliberate, because I couldn't figure 
out how to get vim to do what I REALLY wanted, which was display the 
single line of raw text as 2 lines on the display, and not even show the 
colons on screen but do them for you, and do the same raw-vs-display 
remapping for "^A" <-> ":" .  Without that, I really wanted the 3 
sections to be unmistakable at a glance, even though the lengths of the 
lines and sections were random.

I still believe the vim syntax engine is powerful enough to do all of 
that, but that our needs are so weird that there are no examples and 
practically no people expert enough to know how to do it.

The color choices are all pretty easy to change now that they already 
exist, except the obfuscation is that most of the colors are not being 
directly specified, but are specified as roles. Like it doesn't say 
"recognize a literal string quote this way, and make it green" it says 
"recognize a literal string quote this way, and make them literal string 
quote color" then somewhere else in a separate color theme file it says 
"in this theme, literal string quotes color = green"

A few things are hard coded that probably don't need to be. But you have 
to look at src/syntax.c to get a list of all default recognized labels 
are and what all the default colors are to pick things that would work 
and be distinct from the other things already being used.

So you have a few different approaches:

* edit syntax/filepro.vim file that instead of saying colon = Todo, it 
hard-codes a particular color.

* find a vim colorscheme file (colors/*.vim) that naturally results in 
colors you like. Loading a different vim theme will change almost all 
the fp colors, including colon, but not including the different kinds of 
operators.

* find a vim theme you mostly like, and edit it a little to change what 
color "Todo" is, or change some other color and change the colon to use 
that other instead of "Todo".

By not specifying colors explicitly in syntax/filepro.vim, it allows 
different users to load themes of their choice .


I think what you want to do is:

in syntax/filepro.vim, this line defines the colon to be a 
"fileproDelimiter"

syn match   fileproDelimiter   	   ":"

Then a few lines later "fileproDelimiter" is given the color/role/type 
"Todo"
HiLink fileproDelimiter	Todo

So, I never picked the colors for the colon, they are the "Todo" color 
for whatever theme you have loaded.

So the most graceful way to change it is to find some other thing 
besides "Todo" that most themes define, and change the HiLink line to 
that. Like "Preproc":
HiLink fileproDelimiter	PreProc
It's not using that for anything else already. I don't know what all the 
common options are besides Todo, Preproc, etc.

This readme just says that the default colors and the default color/role 
names are listed in src/syntax.c, so you have to get a source tar to see 
what all your choices are without hacking.
http://vim.cybermirror.org/runtime/colors/README.txt


Or, if you want to hard code a color, I think you change
HiLink fileproDelimiter	Todo
to
hi def fileproDelimiter term=standout ctermfg=3

where there are several optional things you can put after 
"fileproDelimiter" besides term annd ctermfg

This color scheme file has a lot of examples:
http://vim.cybermirror.org/runtime/colors/koehler.vim

like
hi ErrorMsg term=standout cterm=bold ctermfg=grey ctermbg=red 
guifg=White guibg=Red

I think term is for mono terminals, cterm* are for color text terminals, 
and gui* are for gui windows.

And as you can see in that file and others, cterm* colors may be 
described by name or number, and gui* colors may be described by name or 
hex, maybe by the cterm numbers too I don't know.

term = at least bold|underline|standout|reverse probably blink too just 
no one uses it. Probably dim too. All the ansi standout modes.
and combos joined with commas like
term=bold,reverse

ctermfg=1
ctermfg=red

guifg=red
guifg=#C00000

The term= ones will actually be colors on color terminals usually. Like 
your "bold" could really be bright yellow.

The syntax is slightly different in a color scheme file vs a syntax file 
it looks like.
When you see:
"hi Something term= cterm= ..." in a color file, that probably needs to be
"hi def Something term= cterm= ..." in a syntax file.

Up higher in the filepro.vim file, the colons are counted and the LABEL 
and IF sections are given their own region labels, so you can set a 
different background for each 3 regions. The THEN section is just the 
overall default. To give the label or If: sections different background 
colors, change these lines:
HiLink fileproCondition	Conditional
HiLink fileproLabel Include

like

hi def fileproCondition ctermbg=blue

Then you could actually subdue the colons instead of trying to make them 
stand out when everything else is already standing out and all the good 
color combos are already used up. The colons could be an otherwise 
unsable low contrast combination like blue on black, because you 
wouldn't need them any more to quickly see the 3 sections.

-- 
bkw


More information about the Filepro-list mailing list