If I put this in a foo.vim file:
----
highlight Comment guifg=White guibg=Black
function! Foo()
highlight Comment guifg=White guibg=Black
endfunction
----
The first "highlight" line is highlighted, but not the second one. It
seems that's because it's inside a function. Is it intended, or is
this a bug in the vim syntax file?
You get the same color highlighting inside and outside the function?
For me the highlighting works inside functions for most statements,
but not for the 'highlight' statement itself (see attached
screenshot).
> Do you call the function?
> If you only define a function on foo.vim, this only will be defined. Try
> append a follow line in a foo.vim: call Foo()
This doesn't make a difference. Actually, I'm not sure the syntax file
checks that functions are called to highlight them.
I should add that I'm using Vim 7.2.26, compiled by myself using the
sources from the CVS, so I guess the syntax file also comes from the
CVS. I get the same result when using Vim -u NONE -U NONE, and
enabling only syntax highlighting after that.
Yeah, looks like the syntax/vim.vim script doesn't recognise the same
syntax groups for some statements when they are inside a function. With
the default GUI colours, here's what I see:
line
word isolated (=> links to) inside func (=> links to)
highlight Comment guifg=white guibg=black
highlight vimHighlight => Statement vimIsCommand
Comment vimHiGroup => Type vimIsCommand
guifg vimHiGuiFgBg => Type vimIsCommand
= vimHiKeyList vimOper => Statement
white vimHiGroup => Type vimIsCommand
guibg vimHiGuiFgBg => Type vimIsCommand
= vimHiKeyList vimOper => Statement
black vimHiGroup => Type vimIsCommand
syn sync fromstart
syn vimSyntax => Statement vimIsCommand
sync vimSynType => Type vimIsCommand
fromstart vimSyncC => Type vimIsCommand
filetype plugin indent on
filetype vimFTCmd => Statement vimCommand => Statement
plugin vimFTOption => Type vimIsCommand
indent vimFTOption => Type vimIsCommand
on vimFTOption => Type vimCommand => Statement
The other ones that I tried were highlighted identically inside
functions and out of them.
I found this out by means of the following command (which gives four
replies but 1 and 3 are equal, and so are 2 and 4, AFAICT):
command -nargs=0 -bar WhatSyntax echomsg
synIDattr(synID(line("."),col("."),0),"name")
synIDattr(synIDtrans(synID(line("."),col("."),0)),"name")
synIDattr(synID(line("."),col("."),1),"name")
synIDattr(synIDtrans(synID(line("."),col("."),1)),"name")
Notice the many instances of various syntax groups becoming vimIsCommand
(which has no highlights defined) when inside a function block.
Maybe contains=TOP should be added to the definition of the vimFuncBody
syntax group? Dr.Chip, what do you think?
Best regards,
Tony.
--
I've given up reading books; I find it takes my mind off myself.
> ... so I guess the syntax file also
> comes from the CVS. ...
Unfortunately, it is not true. At least for SVN, (and I suspect
that for CVS it is as well the case) there are recent versions of
the runtime files (don't ask me why, for me it is also _very_
confusing). Anyway, to get recent runtime files, please use
rsync, as described on Tony's howto [1] about compiling vim.
--
Anton
[1] Tony's how to for VIM compilation
UNIX:
http://users.skynet.be/antoine.mechelynck/vim/compunix.htm
WINDOWS:
http://users.skynet.be/antoine.mechelynck/vim/compile.htm
Sorry for small typo.
--
Anton
2008/11/9, Anton Sharonov <anton.s...@gmail.com>:
Thanks for pointing this. I've updated my runtime files, but the
highlight problem is nevertheless still there.
No news on this issue?
Regards,
Chip Campbell
Thanks, it's fine now.