I just found out about this option in vim !!!

let g:lisp_rainbow = 1

It's pretty exciting to learn something so useful. I can't figure out how to customize it though. Specially, I want to expel the prominent red colored parenthesis out of the available options.

I know I can do it with some plugins. But there are so many, and few (two actually) of which I tried did not work as expected. Bear in mind, I don't particularly want this rainbow parenthesis functionality for any other filetypes except lisp. So, I would be happy with stock options, no plugin.

So, how do I customize this option in [neo]vim.


I assume when you say "customize" you don't mean anything besides changing the parentheses colors. Look in $VIMRUNTIME/syntax/lisp.vim and search for "lisp_rainbow" and you'll find this

   if &bg == "dark"
    hi def hlLevel0 ctermfg=red         guifg=red1
    hi def hlLevel1 ctermfg=yellow      guifg=orange1
    hi def hlLevel2 ctermfg=green       guifg=yellow1
    hi def hlLevel3 ctermfg=cyan        guifg=greenyellow
    hi def hlLevel4 ctermfg=magenta     guifg=green1
    hi def hlLevel5 ctermfg=red         guifg=springgreen1
    hi def hlLevel6 ctermfg=yellow      guifg=cyan1
    hi def hlLevel7 ctermfg=green       guifg=slateblue1
    hi def hlLevel8 ctermfg=cyan        guifg=magenta1
    hi def hlLevel9 ctermfg=magenta     guifg=purple1
    hi def hlLevel0 ctermfg=red         guifg=red3
    hi def hlLevel1 ctermfg=darkyellow  guifg=orangered3
    hi def hlLevel2 ctermfg=darkgreen   guifg=orange2
    hi def hlLevel3 ctermfg=blue        guifg=yellow3
    hi def hlLevel4 ctermfg=darkmagenta guifg=olivedrab4
    hi def hlLevel5 ctermfg=red         guifg=green4
    hi def hlLevel6 ctermfg=darkyellow  guifg=paleturquoise3
    hi def hlLevel7 ctermfg=darkgreen   guifg=deepskyblue4
    hi def hlLevel8 ctermfg=blue        guifg=darkslateblue
    hi def hlLevel9 ctermfg=darkmagenta guifg=darkviolet

So just override whatever colors you want. This command will change the first level of red to blue:

:hi hlLevel0 ctermfg=blue guifg=blue

Don't know if you can just put this line in your vimrc...it may depend on what order things are loaded, when/where you set g:lisp_rainbow, etc. Worse comes to worst, you could add an autocommand for filetype lisp in vimrc and add your overrides to that.

  • Awesome, I should've looked myself, don't know why didn't think of that. But thankyou. And for you question, if you can put it in your vimrc, I just put it after loading my colorscheme. – klaus Apr 19 '18 at 5:46
  • You're welcome. So vim foo.lisp is a straightforward case but what if you are opening different file types in addition to .lisp, jumping between them, changing color scheme on the fly, etc. Does it seem pretty stable with simple override in vimrc? – B Layer Apr 19 '18 at 16:16
  • When opening *.java, *.cpp along with *.elisp files, the customization holds, but I don't know about changing colorschemes on the fly. I don't think that's very important, somehow. – klaus Apr 20 '18 at 11:38

I have to suggest this plugin for you, it is Highly configurable, to just enable rainbow parentheses for lisp, you can configure it like following:

let g:rainbow_conf = {
\   'separately': {
\       '*': 0,
\       'lisp': {
\           'guifgs': ['royalblue3', 'darkorange3', 'seagreen3', 'darkorchid3'],
\       }
\   }

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.