You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Rainbow was highlighting all of my code block in white. This is mostly because
the 'contains_prefix' in the plugin is 'TOP'. Is there a way to change this? I don't
know but I did come up with a hack/solution.
Example hugo html code block.
{{$folders := (where .Pages ".IsPage" false)}}
In the hugo syntax that I created I need to contain everything like this or else
it will appear everywhere in my markdown documents. This is because I include a lot
of syntax when documenting code.
Hugo syntax, must have contained.
synkeywordhugoKeywords if define else end block partial range template where with containedin=hugoCodeBlockcontained
Solution
I need to know how to remove TOP and add my own contains. I want TOP for
vim files and custom contains for my html files.
Add a contains or contains_prefix in separately entry to override this
'cointains_prefix': '@hugoLang',
Do what I did which is a temp hack. This is only temporary so it can work properly in vim files
and html files.
diff --git a/autoload/rainbow.vim b/autoload/rainbow.vim
index 10551c5..a5ff02a 100644
--- a/autoload/rainbow.vim+++ b/autoload/rainbow.vim@@ -67,8 +67,9 @@ fun rainbow#syn(config)
let real_contained = (lv == 0)? (contained? 'contained ' : '') : 'contained '
let real_containedin = (lv == 0)? s:concat([containedin, '@'.gid2]) : '@'.gid2
- let real_contains = s:concat([contains_prefix, contains])- exe 'syn region '.rid.' matchgroup='.pid.' '.real_contained.'containedin='.real_containedin.' contains='.real_contains.' '.paren+ "let real_contains = s:concat([contains_prefix, contains])+ let real_contains = &ft =~ 'html' ? '@hugo' : 'TOP'+ exe 'syn region '.rid.' matchgroup='.pid.' '.real_contained.'containedin='.real_containedin.' contains='.real_contains.' '.paren.' '
endfor
endfor
for lv in range(cycle)
The text was updated successfully, but these errors were encountered:
letg:rainbow_conf= #{
\ separately: #{
\ html: #{
\ contains_prefix: '',
\ parentheses: [
"\ The default config of HTML should be copied too with contains=TOP appended if HTML tags"\ still need to be highlighted by rainbow\ 'start=/(/ end=/)/ contained containedin=@hugoCode contains=@hugoCode',
\ ],
\ },
\ },
\ }
And bundle the things of hugo in a syntax cluster named hugoCode:
However, in current version of rainbow, setting contains_prefix to empty may raise an warning about empty contains list in syntax rule declaration. Following patch may fix this:
From f45569a7ac6d9da72eb06962d0d1d32034219884 Mon Sep 1700:00:002001
From: Virginia Senioria <[email protected]>
Date: Sun, 5 Dec 202111:01:35+0800
Subject: [PATCH] fix: fixed empty contains list when contains isempty---
autoload/rainbow.vim | 3++-1file changed, 2insertions(+), 1deletion(-)
diff--git a/autoload/rainbow.vimb/autoload/rainbow.vimindex10551c5..c60cdee 100644---a/autoload/rainbow.vim+++b/autoload/rainbow.vim@@-68,7+68,8@@funrainbow#syn(config)
let real_contained = (lv==0)? (contained? 'contained ' : '') : 'contained 'let real_containedin = (lv==0)? s:concat([containedin, '@'.gid2]) : '@'.gid2
let real_contains =s:concat([contains_prefix, contains])
-exe'syn region '.rid.' matchgroup='.pid.''.real_contained.'containedin='.real_containedin.' contains='.real_contains.''.paren
+let real_contains = real_contains =='' ? '' : ' contains='.real_contains
+exe'syn region '.rid.' matchgroup='.pid.''.real_contained.'containedin='.real_containedin.real_contains.''.paren
endforendforforlvinrange(cycle)
--2.34.1
BTW, this fix is included in Senioriae fork... ><
And there wouldn't be the same issue for containedin, since it's always not empty.
Problem
Rainbow was highlighting all of my code block in white. This is mostly because
the 'contains_prefix' in the plugin is 'TOP'. Is there a way to change this? I don't
know but I did come up with a hack/solution.
Example hugo html code block.
In the hugo syntax that I created I need to contain everything like this or else
it will appear everywhere in my markdown documents. This is because I include a lot
of syntax when documenting code.
Hugo syntax, must have contained.
Solution
I need to know how to remove TOP and add my own contains. I want TOP for
vim files and custom contains for my html files.
Add a contains or contains_prefix in separately entry to override this
and html files.
The text was updated successfully, but these errors were encountered: