luochen1990/rainbow

Rainbow Parentheses Improved

help you read complex code by showing diff level of parentheses in diff color !!

Description (这里有中文版)

As everyone knows, the most complex codes were composed of a mass of different kinds of parentheses (typically: lisp). This plugin will help you read these codes by showing different levels of parentheses in different colors. You can also find this plugin in www.vim.org.

lisp

lisp

html

html

more

What is improved ?

  • no limit of parentheses levels.
  • separately edit guifgs and ctermfgs (the colors used for highlighting).
  • now you can design your own parentheses such as 'begin' and 'end'.
  • you can also configure anything separately for different types of files.
  • now you can even decide to let some operators (like + - * / , ==) highlighted with the parentheses together.
  • dot separated combined filetype support (:h ft).
  • json style configuration used, more understandable and readable, easier for advanced configuration.
  • the code is shorter and easier to read now.
  • smoother and faster.
  • the Chinese document is added.

Referenced:

Install:

via Vundle:

Plugin 'luochen1990/rainbow'
let g:rainbow_active = 1 "0 if you want to enable it later via :RainbowToggle

Manually:

  • first, execute the following commands (for windows users, use ~/vimfiles instead of ~/.vim)

     git clone https://github.com/luochen1990/rainbow.git
     cd rainbow
     cp plugin/* ~/.vim/plugin
     cp autoload/* ~/.vim/autoload
  • second, add the follow sentences to your .vimrc or _vimrc :

     let g:rainbow_active = 1 "0 if you want to enable it later via :RainbowToggle
  • third, restart your vim and enjoy coding.

Configure:

There is an example for advanced configuration (which I'm using), add it to your vimrc and edit it as you wish (just keep the format).

	let g:rainbow_conf = {
	\	'guifgs': ['royalblue3', 'darkorange3', 'seagreen3', 'firebrick'],
	\	'ctermfgs': ['lightblue', 'lightyellow', 'lightcyan', 'lightmagenta'],
	\	'operators': '_,_',
	\	'parentheses': ['start=/(/ end=/)/ fold', 'start=/\[/ end=/\]/ fold', 'start=/{/ end=/}/ fold'],
	\	'separately': {
	\		'*': {},
	\		'tex': {
	\			'parentheses': ['start=/(/ end=/)/', 'start=/\[/ end=/\]/'],
	\		},
	\		'lisp': {
	\			'guifgs': ['royalblue3', 'darkorange3', 'seagreen3', 'firebrick', 'darkorchid3'],
	\		},
	\		'vim': {
	\			'parentheses': ['start=/(/ end=/)/', 'start=/\[/ end=/\]/', 'start=/{/ end=/}/ fold', 'start=/(/ end=/)/ containedin=vimFuncBody', 'start=/\[/ end=/\]/ containedin=vimFuncBody', 'start=/{/ end=/}/ fold containedin=vimFuncBody'],
	\		},
	\		'html': {
	\			'parentheses': ['start=/\v\<((area|base|br|col|embed|hr|img|input|keygen|link|menuitem|meta|param|source|track|wbr)[ >])@!\z([-_:a-zA-Z0-9]+)(\s+[-_:a-zA-Z0-9]+(\=("[^"]*"|'."'".'[^'."'".']*'."'".'|[^ '."'".'"><=`]*))?)*\>/ end=#</\z1># fold'],
	\		},
	\		'css': 0,
	\	}
	\}
  • 'guifgs': a list of guifg (:h highlight-guifg), i.e. colors for gui interface, will be used in order
  • 'guis': a list of gui (:h highlight-gui), will be used in order
  • 'ctermfgs': a list of ctermfg (:h highlight-ctermfg)
  • 'cterms': a list of cterm (:h highlight-cterm)
  • 'operators': describe the operators you want to highlight (note: be careful about special characters which needs escaping, you can find more examples here, and you can also read the vim help about syn-pattern).
  • 'parentheses': a list of parentheses definitions, a parentheses definition contains parts like start=/(/, step=/,/, stop=/)/, fold, contained, containedin=someSynNames, contains=@Spell, see :h syntax for more details.
  • 'parentheses_options': parentheses options shared between different parentheses, things like containedin=xxxFuncBody, contains=@Spell (or 'contains=@NoSpell') often appears here.
  • 'separately': configure for specific filetypes (decided by &ft), key * for filetypes without separate configuration, value 0 means disable rainbow only for this type of files, value "default" means keep the default shim for this filetype (notice: the default shim config will change between plugin version).
  • keep a field empty to use the default setting.

User Command:

  • :RainbowToggle --you can use it to toggle this plugin.

**Rate this script if you like it, and I'll appreciate it and improve this plugin for you because of your support!

Just go to this page and choose Life Changing and click rate**

luochen1990/rainbow
See more ...