2

I'm trying to create a new custom colorscheme and syntax highlighting. I have copied some examples into ~/.vim/colors/ and ~/.vim/syntax with new names inside for the scheme.

All the basics work fine, so happy with the files.

I am trying to get some custom colour comments working, rather than just a single one, so something similar to

# = Normal comment
##1 = Red
##2 = Dark Red

In my colorscheme I have (that I can't get working)

hi Comment term=bold ctermfg=4 guifg=#406090
hi Comment1 term=bold ctermfg=4 guifg=#a00000
hi Comment2 term=bold ctermfg=4 guifg=#800000
"" I want to reference these

In my syntax file I have...

HiLink perlComment            Comment
HiLink perlComment1           Conditional
HiLink perlComment2           String


syn match  perlComment          "#.*" contains=perlTodo
syn match  perlComment1         "##1.*" contains=perlTodo
syn match  perlComment2         "##2.*" contains=perlTodo

This partly works, in that I can get the unique comment highlighting working, but ONLY if I match it to a String/Conditional/Comment, i.e an already established 'keyword' or colorshceme or something (not sure what the term is here).

So I was thinking I could do something like...

HiLink perlComment2 Comment2 

To match the earlier colorscheme settings (but this doesn't work, I can't seem to reflect changes from the colorscheme file), so I'm likely misunderstanding what's happening.

Is there a way to create a custom term like String/Conditional that would match in the colorscheme ? I think I'm missing a link somewhere.

  • I'm not sure I understand where the problem is with what you've tried so far. Does HiLink perlComment2 Comment2 not work? – Rich Mar 22 '18 at 11:50
  • Hi Rich, no, it feels like it's ignoring anything anything I set in the colorscheme (but it recognises the colorscheme file when I switch to it). But I can't seem to reference that properly, or I'm missing something. – Ian Mar 22 '18 at 11:55
  • 1
    What's the output of :verbose hi Comment2 ? – Rich Mar 22 '18 at 12:17
  • Comment2 xxx term=bold ctermfg=4 Last set from ~/.vim/colors/mycolorscheme.vim – Ian Mar 22 '18 at 12:23
  • 1
    How about :verbose hi perlComment2? And :syntax list perlComment2 – Rich Mar 22 '18 at 12:31
0

I was an idiot thinking that the colorscheme was using guifg, when in my case it was using ctermfg, so when I started changing that in the colorscheme, all worked fine. So I just needed...

hi Comment1 term=bold cterm=bold ctermfg=205

As an example, the rest was fine.

Thanks to Rich for the help in getting there.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.