sponsor Vim development Vim logo Vim Book Ad

rainbow_levels.vim : A different approach to code highlighting.

 script karma  Rating 10/6, Downloaded by 132    Comments, bugs, improvements  Vim wiki

created by
thiagoalessio
 
script type
indent
 
description
INTRODUCTION

This plugin highlights code by indentation level instead of language syntax.
It is specially useful when dealing with deeply nested code or callback hells.


USAGE

This plugin exposes three self-explanatory commands:

:RainbowLevelsOn
:RainbowLevelsOff
:RainbowLevelsToggle

And you can use them in a variety of ways, for example:

" Creating a mapping to turn it on and off:
map <leader>l :RainbowLevelsToggle<cr>

" Or automatically turning it on for certain file types:
au FileType javascript,python,php,xml,yaml :RainbowLevelsOn


CUSTOMIZATION

To customize the levels you just need to define highlight groups whith the
name RainbowLevelsN, where N is the number of the level.

By default this plugin defines 7 highlight groups, simply linking to common
existing highlight groups, in order to respect your colorscheme.

But you are free to define as many levels you wish. Check the examples below
and also the User-Contributed Themes page for inspiration.
https://github.com/thiagoalessio/rainbow_levels.vim/wiki/User-Contributed-Themes


EXAMPLE: Jellybeans Rainbow

Using groups defined by jellybeans colorscheme in a "rainbow" sequence.

hi! link RainbowLevel0 Constant
hi! link RainbowLevel1 Type
hi! link RainbowLevel2 Function
hi! link RainbowLevel3 String
hi! link RainbowLevel4 PreProc
hi! link RainbowLevel5 Statement
hi! link RainbowLevel6 Identifier
hi! link RainbowLevel7 Normal
hi! link RainbowLevel8 Comment


EXAMPLE: Background Only

Want to keep syntax highlight? No problem! You can change only the background
colors instead.

hi! RainbowLevel0 ctermbg=240 guibg=#585858
hi! RainbowLevel1 ctermbg=239 guibg=#4e4e4e
hi! RainbowLevel2 ctermbg=238 guibg=#444444
hi! RainbowLevel3 ctermbg=237 guibg=#3a3a3a
hi! RainbowLevel4 ctermbg=236 guibg=#303030
hi! RainbowLevel5 ctermbg=235 guibg=#262626
hi! RainbowLevel6 ctermbg=234 guibg=#1c1c1c
hi! RainbowLevel7 ctermbg=233 guibg=#121212
hi! RainbowLevel8 ctermbg=232 guibg=#080808


EXAMPLE: Cycle colors

Using a loop to automate the tedious work of defining all highlight groups.

for level in range(0, 10, 2)
exe 'hi! RainbowLevel'.level.' ctermfg=magenta'
exe 'hi! RainbowLevel'.(level+1).' ctermfg=cyan'
endfor


EXAMPLE: Level Alert

Nothing shows up until a certain threshold, warning you that the code is going
too deep.


hi! RainbowLevel0 ctermbg=none ctermfg=none cterm=none
hi! RainbowLevel2 ctermbg=none ctermfg=none cterm=none
hi! RainbowLevel3 ctermbg=none ctermfg=none cterm=none
hi! RainbowLevel4 ctermbg=none ctermfg=none cterm=none
hi! link RainbowLevel5 WarningMsg
for level in range(6, 10)
exe 'hi! link RainbowLevel'.level.' ErrorMsg'
endfor


SPECIAL THANKS

* Campbell Vertesi and Victor Schroeder for the idea to fade levels in shades
  of a single color.

* David De Sousa and Lucas Caton for the idea of highlighting only the
  background, to keep syntax highlight.

* Derek Shoemaker for creating the very first User-Contributed Theme with a
  different "rainbow" order, making a beautiful contrast between levels.

* Ingo Karkat for identifying and fixing several issues present on the initial
  implementation.


WHERE TO GET HELP

Join the chat at https://gitter.im/thiagoalessio/rainbow_levels.vim


BUGS

Please report any bugs you may find on the GitHub issue tracker:
http://github.com/thiagoalessio/rainbow_levels.vim/issues


LICENSE

rainbow_levels.vim is released under the MIT License.

------------------------------------------------------------------------------
                           Made with love in Berlin
 
install details
VUNDLE

Place this in your .vimrc:

Plugin 'thiagoalessio/rainbow_levels.vim'
then run the following in Vim:

:source %
:PluginInstall
For Vundle version < 0.10.2, replace Plugin with Bundle above.


NEOBUNDLE

Place this in your .vimrc:

NeoBundle 'thiagoalessio/rainbow_levels.vim'
then run the following in Vim:

:source %
:NeoBundleInstall


VIMPLUG

Place this in your .vimrc:

Plug 'thiagoalessio/rainbow_levels.vim'
then run the following in Vim:

:source %
:PlugInstall


PATHOGEN
Run the following in a terminal:

cd ~/.vim/bundle
git clone https://github.com/thiagoalessio/rainbow_levels.vim
 

rate this script Life Changing Helpful Unfulfilling 
script versions (upload new version)

Click on the package to download.

package script version date Vim version user release notes
rainbow_levels-0.6.0.zip 0.6.0 2018-04-18 7.0 thiagoalessio Simplified way to customize levels, without custom variable
rainbow_levels-0.5.0.zip 0.5.0 2017-12-23 7.0 thiagoalessio Allow use of same color for different levels
rainbow_levels-0.4.0.zip 0.4.0 2017-12-22 7.0 thiagoalessio Better support for softtabstop
rainbow_levels-0.3.0.zip 0.3.0 2017-12-21 7.0 thiagoalessio Correctly match levels with mixed tabs and spaces
rainbow_levels-0.2.0.zip 0.2.0 2017-12-20 7.0 thiagoalessio Fixes match priority and color override by loading sequence
rainbow_levels-0.1.0.zip 0.1.0 2017-12-18 7.0 thiagoalessio Initial upload
ip used for rating: 23.20.165.182

If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to the maillist. Help Bram help Uganda.
   
SourceForge.net Logo