Thursday, June 5, 2014

Re: How can a highlight group combine custom attributes and a link?

On 04/06/14 17:19, boss@airbladesoftware.com wrote:
> Hello!
>
> I am aware of one way for a highlight group to contain both custom attributes and a link to another group:
>
> :hi Foo guifg=red
> :hi! link Foo Comment
>
> :hi Foo
> Foo xxx guifg=red
> links to Comment
>
> Are there any other ways to do this?
>
> The context is I have a plugin which defines a default highlight group:
>
> :hi default link Foo Comment
>
> In a user's vimrc, they specify the attributes they actually want:
>
> :hi Foo guifg=red
>
> However instead of seeing this:
>
> :hi Foo
> Foo xxx guifg=red
>
> ...they see this:
>
> :hi Foo
> Foo xxx guifg=red
> links to Comment
>
> And I cannot figure out why this is happening. (https://github.com/airblade/vim-gitgutter/issues/176)
>
> Thanks in advance!
>
> Yours,
> Andy Stewart
>

I think it is a minor bug. You didn't say if the highlight definition
for "Comment" is actually "guifg=red" in the colorscheme you're using,
but if it isn't you could check what happens.

I *think* that using ":hi! link" with a bang on a from-group which
already exists (as in your first example) should undo the preexisting
definition and replace it with the link, while using ":hi default link"
on a from-group which already exists (as in your second example, since
plugins are processed after the vimrc) should completey ignore the link
(and keep the preexisting definition).

If the actual color for the Foo group is the same as for Comment in the
first case but is red (and Comment is not red) in the second example,
then highlight groups are created properly, it's just the display which
is wrong; but how two different situations can be displayed identically
in this "list groups" variant of the command beats me.

If in both cases the highlight for Foo is the same, either red both
times or the same as Comment both times, then either there is a bug or I
have misunderstood the workings of either the exclamation mark or the
"default" argument in the :highlight command.

In any case Bram knows it better than I do, and that's why I'm adding
him to the Cc list, though I think he would have got this mesage anyway.


Best regards,
Tony.
--
The man with the best job in the country is the Vice President. All he has
to do is get up every morning and say, "How's the President?"
-- Will Rogers

The vice-presidency ain't worth a pitcher of warm spit.
-- Vice President John Nance Garner

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments: