Question

I'm trying to do this on my .vimrc:

hi link SyntasticErrorLine SignColumn
hi link SyntasticErrorSign SignColumn
hi SyntasticErrorSign guifg=red ctermfg=red

What I want is to have the SyntasticErrorSign highlighting group with the same background as SignColumn but with custom foreground colors.

Vim docs says:

- As soon as you use a ":highlight" command for a linked group, the link is removed.

So, the way I'm doing it won't work anyway, is there a way to achieve that?

Était-ce utile?

La solution 2

@Kent answer was good, but it seems there's a problem with synIDattr when one doesn't pass the mode argument, it fails to return the attribute in GUI mode (gvim). I've learned this from vim-arline plugin sources.

I've solved my problem with:

hi link SyntasticErrorLine SignColumn

exec 'hi SyntasticErrorSign guifg=red ctermfg=red' .
            \' guibg=' . synIDattr(synIDtrans(hlID('SignColumn')), 'bg', 'gui') .
            \' ctermbg=' . synIDattr(synIDtrans(hlID('SignColumn')), 'bg', 'cterm')

Autres conseils

If you want to "steal" some hl-attribute value from other group, you don't have to link, you just get the value for your own usage.

For your problem, try to add this line into your .vimrc file.

exec 'hi SyntasticErrorSign guifg=red ctermfg=red ' . (has("gui_running")? 'guibg=':'ctermbg=') . synIDattr(hlID('SignColumn'),'bg')

The line sets fg(gui and cterm) of SyntasticErrorSign group as red, and uses the same bg color of group SignColumn, depends on you are in gvim or vim. I think it should be what you are looking for.

For those functions, you could just :h xxx() to get detailed information.

This does what you want:

hi SyntasticErrorSign guifg=red ctermfg=red
hi! link SyntasticErrorSign SignColumn

The ! forces the link even though you already have attributes set on the highlight group.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top