All Projects → luochen1990 → Rainbow

luochen1990 / Rainbow

Licence: apache-2.0
Rainbow Parentheses Improved, shorter code, no level limit, smooth and fast, powerful configuration.

Projects that are alternatives of or similar to Rainbow

Vim Yaml Folds
YAML, RAML, EYAML & SaltStack SLS folding for Vim
Stars: ✭ 59 (-95.54%)
Mutual labels:  vim-plugin
Fff.vim
A plugin for vim/neovim which allows you to use fff as a file opener.
Stars: ✭ 78 (-94.11%)
Mutual labels:  vim-plugin
Learn Vim
无废话极简版Vim学习笔记!文章按主题分拆为多个章节,并尽量控制每节的信息量;通过文字色彩和字体,将命令、快捷键突出显示;在每节结尾,提供一个命令列表,以便回顾文中介绍的重要命令。如果这些文章能对喜欢Vim的朋友有所益处,我将不胜荣幸。
Stars: ✭ 83 (-93.73%)
Mutual labels:  vim-plugin
Shirotelin
shirotelin is Ultimate standard light colorscheme for Vim and Neovim!
Stars: ✭ 69 (-94.79%)
Mutual labels:  vim-plugin
Fzf Filemru
File MRU with fzf.vim
Stars: ✭ 76 (-94.26%)
Mutual labels:  vim-plugin
Vim Airline Tomato
Pomodoro Technique
Stars: ✭ 79 (-94.03%)
Mutual labels:  vim-plugin
Vim Systemd Syntax
Syntax highlighting for systemd service files in Vim.
Stars: ✭ 57 (-95.69%)
Mutual labels:  vim-plugin
Vim Haskell Indent
If the plugin does not work for some syntax, feel free to report to the issue tracker!
Stars: ✭ 90 (-93.2%)
Mutual labels:  vim-plugin
Vim Litecorrect
Lightweight auto-correction for Vim
Stars: ✭ 77 (-94.18%)
Mutual labels:  vim-plugin
Incsearch Easymotion.vim
Stars: ✭ 82 (-93.81%)
Mutual labels:  vim-plugin
Tcomment vim
An extensible & universal comment vim-plugin that also handles embedded filetypes
Stars: ✭ 1,162 (-12.24%)
Mutual labels:  vim-plugin
Vim Pencil
Rethinking Vim as a tool for writing
Stars: ✭ 1,186 (-10.42%)
Mutual labels:  vim-plugin
Vista.vim
🌵 Viewer & Finder for LSP symbols and tags
Stars: ✭ 1,218 (-8.01%)
Mutual labels:  vim-plugin
Completor.vim
Async completion framework made ease.
Stars: ✭ 1,158 (-12.54%)
Mutual labels:  vim-plugin
Todoist.nvim
A todoist extension for neovim
Stars: ✭ 84 (-93.66%)
Mutual labels:  vim-plugin
Tabnine
AI Code Completions
Stars: ✭ 8,863 (+569.41%)
Mutual labels:  vim-plugin
Fzf Mru.vim
Vim plugin that is using fzf.vim to display your most recently used files.
Stars: ✭ 79 (-94.03%)
Mutual labels:  vim-plugin
Vim Which Key
🌷 Vim plugin that shows keybindings in popup
Stars: ✭ 1,310 (-1.06%)
Mutual labels:  vim-plugin
Vim Rfc
📓 Query RFC database and download RFCs from within Vim.
Stars: ✭ 88 (-93.35%)
Mutual labels:  vim-plugin
Vim Plugin Viewdoc
Vim plugin: flexible viewer for any documentation
Stars: ✭ 79 (-94.03%)
Mutual labels:  vim-plugin

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

install via Plug:

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

install manually:

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

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

     let g:rainbow_active = 1 "set to 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, add it to your vimrc and edit it as you wish (just keep the format).

Note: you can remove these lines safely since they are all included by the source code).

let g:rainbow_conf = {
\	'guifgs': ['royalblue3', 'darkorange3', 'seagreen3', 'firebrick'],
\	'ctermfgs': ['lightblue', 'lightyellow', 'lightcyan', 'lightmagenta'],
\	'guis': [''],
\	'cterms': [''],
\	'operators': '_,_',
\	'parentheses': ['start=/(/ end=/)/ fold', 'start=/\[/ end=/\]/ fold', 'start=/{/ end=/}/ fold'],
\	'separately': {
\		'*': {},
\		'markdown': {
\			'parentheses_options': 'containedin=markdownCode contained', "enable rainbow for code blocks only
\		},
\		'lisp': {
\			'guifgs': ['royalblue3', 'darkorange3', 'seagreen3', 'firebrick', 'darkorchid3'], "lisp needs more colors for parentheses :)
\		},
\		'haskell': {
\			'parentheses': ['start=/(/ end=/)/ fold', 'start=/\[/ end=/\]/ fold', 'start=/\v\{\ze[^-]/ end=/}/ fold'], "the haskell lang pragmas should be excluded
\		},
\		'vim': {
\			'parentheses_options': 'containedin=vimFuncBody', "enable rainbow inside vim function body
\		},
\		'perl': {
\			'syn_name_prefix': 'perlBlockFoldRainbow', "solve the [perl indent-depending-on-syntax problem](https://github.com/luochen1990/rainbow/issues/20)
\		},
\		'stylus': {
\			'parentheses': ['start=/{/ end=/}/ fold [email protected]'], "[vim css color](https://github.com/ap/vim-css-color) compatibility
\		},
\		'css': 0, "disable this plugin for css files
\	}
\}
  • '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). note that this option will be overwritten by the step part of parentheses.
  • 'parentheses': a list of parentheses definitions, a parentheses definition contains parts like start=/(/, step=/,/, stop=/)/, fold, contained, containedin=someSynNames, [email protected], see :h syntax for more details. notice that the step part is defined by this plugin so it is not described by the official vim doc.
  • 'parentheses_options': parentheses options shared between different parentheses, things like containedin=xxxFuncBody, [email protected] (or '[email protected]') often appears here. this option is often used to solve 3rd-party-plugin-compatibility problems.
  • '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).
  • 'syn_name_prefix': add a prefix to name of the syntax definition, this option is often used to solve 3rd-party-plugin-compatibility problems.
  • 'after': execute some vim commands after the rainbow syntax rules is defined. it is often used like ['syn clear xxx'] to solve 3rd-party-plugin-compatibility problems.
  • keep a field empty to use the default setting.

To get more advanced config examples, try to search throught this tag.

User Command

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

3rd Party Plugin Compatibility

You should notice that this plugin is very special, Vim plugins is expected to provide syntax definitions vertically, i.e. one filetype, one syntax definition set:

----------------------------------------------------
|      cpp       |      java       |    python     |
|                |                 |               |
| syn cppKeyword | syn javaKeyword | syn pyKeyword |
| syn cppFunc    | syn javaFunc    | syn pyLambda  |
| syn cppParen   | syn javaParen   | syn pyParen   |
| ...            | ...             | ...           |
----------------------------------------------------

But this plugin provide syntax definitions horizontally, i.e. parentheses syntax for all filetypes:

----------------------------------------------------
|      cpp       |      java       |    python     |
|                |                 |               |
| syn cppKeyword | syn javaKeyword | syn pyKeyword |
| syn cppFunc    | syn javaFunc    | syn pyLambda  |
| ...            | ...             | ...           |
----------------------------------------------------
|                     rainbow                      |
|                                                  |
| syn cppRainbow   syn javaRainbow   syn pyRainbow |
----------------------------------------------------

You can notice that, to provide rainbow parentheses, this plugin have to define it's own syntax rules, and these rules will overwrite the parentheses syntax provided by the filetype plugin.

It works well at most of the time, but in some special cases, when the parentheses syntax rule is depended somewhere else (e.g. indent, spell checking, nested syntax rules), the things depend on the original syntax rules will be broken.

This plugin has provide some mechanisms to solve the compatibility problems, and have provided default configurations to solve compatibility problems with the default vim syntax files.

But if this plugin is conflicted with some other plugins, you will probably have to solve them by yourself. First, you can search on this issue tag to find whether there is somebody else had the same problem and solved it. Second, you can read the following content about troubleshooting.

Troubleshooting

  • rainbow doesn't work at all: find out the current parentheses syntax name, and use the after mechanism to clear these syntax.
  • rainbow doesn't work inside some structure: find out the syntax region name, and use the parentheses_options mechanism like 'containedin=xxx'.
  • spell checking doesn't work inside parentheses: use the parentheses_options mechanism like '[email protected]'.
  • spell checking works inside parentheses but you don't want it: use the parentheses_options mechanism like '[email protected]'.
  • indent not works correctly: check the indent script you are using and search synID inside it to find which syntax name prefix it depends on, and use the syn_name_prefix mechanism to solve it.

The following keymappings will help you to check the syntax name and definitions under the cursor, add them to your vimrc and restart vim:

nnoremap <f1> :echo synIDattr(synID(line('.'), col('.'), 0), 'name')<cr>
nnoremap <f2> :echo ("hi<" . synIDattr(synID(line("."),col("."),1),"name") . '> trans<'
\ . synIDattr(synID(line("."),col("."),0),"name") . "> lo<"
\ . synIDattr(synIDtrans(synID(line("."),col("."),1)),"name") . ">")<cr>
nnoremap <f3> :echo map(synstack(line('.'), col('.')), 'synIDattr(v:val, "name")')<cr>
nnoremap <f4> :exec 'syn list '.synIDattr(synID(line('.'), col('.'), 0), 'name')<cr>

Move your cursor to a parentheses and press the keys to use them.


**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**

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].