Coder Social home page Coder Social logo

rainbow_parentheses.vim's Introduction

Better Much simpler Rainbow Parentheses

A heavily-rewritten fork of kien/rainbow_parentheses.vim.

  • Simpler commands and configuration
  • Automatic color extraction
  • Adjusts itself when color scheme is changed

Installation

Using vim-plug:

Plug 'junegunn/rainbow_parentheses.vim'

Commands

" Activate
:RainbowParentheses

" Deactivate
:RainbowParentheses!

" Toggle
:RainbowParentheses!!

" See the enabled colors
:RainbowParenthesesColors

" Activation based on file type
augroup rainbow_lisp
  autocmd!
  autocmd FileType lisp,clojure,scheme RainbowParentheses
augroup END

Customization

let g:rainbow#max_level = 16
let g:rainbow#pairs = [['(', ')'], ['[', ']']]

" List of colors that you do not want. ANSI code or #RRGGBB
let g:rainbow#blacklist = [233, 234]

rainbow_parentheses.vim's People

Contributors

diablo-d3 avatar junegunn avatar kien avatar thash avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

rainbow_parentheses.vim's Issues

Custom Rainbow Pairs breaks highlighting with Template literals in JSX with mxw/vim-jsx

Issue:

The combination of mxw/vim-jsx and junegunn/rainbow_parentheses.vim, with a custom g:rainbow#pairs list, breaks syntax highlighting.

Minimal .vimrc to replicate:

set nocompatible
filetype indent plugin on
syntax on

call plug#begin($VIM_PLUGINS_DIR)
    Plug 'pangloss/vim-javascript'
    Plug 'mxw/vim-jsx'
    Plug 'junegunn/rainbow_parentheses.vim' " Breaks highlighting for template
call plug#end()
let g:jsx_ext_required = 0
let g:rainbow#pairs = [['(', ')'], ['[', ']'], ['{', '}'], ['<', '>']]

and then call the command :RainbowParentheses after, to toggle.

Temporary Solution

Disable the custom g:rainbow#pairs line.

Enable globally?

Hi,

I'm using vim-plug and I want the rainbow_parentheses to be enabled for any kind of file without me manually invoking any command, is this somehow possible? What I'm currently doing is

call plug#load('rainbow_parentheses.vim')
call rainbow_parentheses#activate()

which seems hacky to say the least

Does not apply to braces

Add option to also apply to braces. This will be specially helpful for languages other than lisp family which rely more on {} than ()

Doesn't work for tex files

Inside

\begin{document}

\end{document}

this plugin doesn't seem to work, even with minimal vim. It does work outside of that, but that's not useful for tex. Could this plugin be updated/upgraded so that it works for tex files as expected?

Blacklist groups

Similar to the automatic blacklisting of the fg colors associated with the Normal highlight group, it would be great if there were a variable of blacklisted groups.
I felt a need for this when rainbow_parentheses.vim chose the fg color of comments for the parens, making it quite hard to see (with colorscheme base16-onedark).
I could add the color to the blacklisted ones, but I think an option that would work across colorschemes would be better.

RainbowParentheses in vimrc

When I put RainbowParentheses (same with Limelight) at the very end of my .vimrc after let g:limelight_conceal_ctermfg = 240 I get not an editor command for both at startup, while it works when vim is already open.
Why could this be?

Breaks PHP syntax highlighting

Test:

Create a large PHP file, a good example can be found here.
Open it with RainbowParentheses enabled.
And ensure that let g:rainbow#pairs = [['(', ')'], ['[', ']'], ['{', '}'], ['<', '>']] is present in vimrc.

Result:

Syntax highlighting doesn't work.

Fix:

Disable RainbowParentheses and syntax highlighting starts working again.

trying to toggle off only if the buffer is readonly

To avoid having the plug-in activated in all files except :help buffers or NERDTree I put this snippet in the .vimrc

augroup rainbow
  autocmd!
  autocmd FileType * if &readonly | RainbowParentheses | RainbowParentheses!
augroup END

Unfortunatly I'm not skilled with VimScript and it does not work. Could you please help me?

Doesn't work inside functions

Not sure if this is in conflict with another plugin, maybe with vscode color scheme, but for example writing react it stops working inside the component. Outside component, it works just fine

Only highlight surrounding parentheses?

emacs' highlight-parentheses (https://www.emacswiki.org/emacs/HighlightParentheses) only color-highlights all pairs of delimiters that are surrounding the current cursor position, using different colors for different levels. Would it be possible to provide a similar behavior in this plugin?

(As far as I can see there is no plugin that provides this behavior for vim right now; the closest I have found is https://github.com/justinmk/vim-matchparenalways, which only highlights the closest surrounding pair.)

Thanks in advance.

Error when opening Vim with no file

I just switched from kien's plugin and ran into a problem. When opening Vim without a file (i.e. empty buffer) the following error occurs.

Error detected while processing function rainbow_parentheses#activate..<SNR>55_extract_colors..<SNR>55_blacklist:
line    2:
E411: highlight group not found: Normal
Press ENTER or type command to continue

I can replicate the problem with a very minimal vimrc (just vim-plug and the following).

" Rainbow Parentheses
let g:rainbow#max_level=16
let g:rainbow#pairs=[ ['(', ')'], ['[', ']'], ['{', '}'] ]
autocmd VimEnter * RainbowParentheses

The offending line:

https://github.com/junegunn/rainbow_parentheses.vim/blob/master/autoload/rainbow_parentheses.vim#L97

Changing the silent call to silent! seems to fix the problem (or hides it) but I'm no vimscript expert and I don't know if that could possibly break other things.

Thanks for any help.

Using Rainbow Parenthesis

I hope you can add the usage of Rainbow Parenthesis in README.md.

And can I use call rainbowparenthesis to enable Rainbow Parenthesis in ~/.vimrc?

Curly braces ( { and } ) not working

Hi @junegunn! Love the plugin, but I can't seem to get curly braces to work. I currently have this in my vimrc:

let g:rainbow#pairs = [['(', ')'], ['[', ']'], ['{', '}']]

Is that the correct way to add a set of symbols?

Unhelpful default colors

Hi!

I was trying today the plugin, and found that for some reason, the default colors picked suck for the
base16-atelier-dune colorscheme. Most of them look basically the same as the default text.

Here a capture of :RainbowParenthesesColors output:

image

Also, I am using terminal vim on Windows Terminal, with a base16 colorscheme with:

set background=dark
let base16colorspace=256
colorscheme base16-atelier-dune  " Same issue with base16-default-dark

Error with .cfg file

When using a file with extension .cfg and neovim's default colorscheme I get the following error:

rainbow-error

Is there a way to avoid these errors?
A fallback to no color instead of a warning?

I was starting rainbow parentheses by using:

Plug 'junegunn/rainbow_parentheses.vim'
autocmd VimEnter * RainbowParentheses
let g:rainbow#pairs = [['(', ')'], ['[', ']']]

but now I have this to avoid it:

Plug 'junegunn/rainbow_parentheses.vim'
let rainbow_blacklist = ['cfg']
autocmd VimEnter * if index(rainbow_blacklist, &ft) < 0 | RainbowParentheses
let g:rainbow#pairs = [['(', ')'], ['[', ']']]

Thanks!

First parentheses' color

The outermost parentheses color can be sometimes very close to the color of the background when loading a new color scheme or when reloading a vim session.

designate my own set of colors

the blacklist does not work as it seems each time vim might pick up different color set for pairs, which render some pairs invisible for my colorscheme in use. can I set my own set of colors of choices? this way I can guarantee that they will work for my terminal colorscheme(and vim colorscheme).

Buffer local pairs?

For some filetypes, I don't want certain pairs to be colored, (e.g. in Rust I prefer to conceal curly braces entirely, but not in other languages). Is there a way to make it buffer local, or to add a feature like b:rainbow_pairs (that would be equal to g:rainbow_pairs by default?)

Colorization Does Not Work with Treesitter

Rainbow parentheses does not work with treesitter. Parentheses just appear gray:
image
Note that when in visual mode on the parentheses, colorization appears:
image
Is there any fix for this? Here is my treesitter configuration if it helps:

-- treesitter stuff
local configs = require("nvim-treesitter.configs")
configs.setup {
  ensure_installed = "all",
  sync_install = false, 
  ignore_install = { "" }, -- List of parsers to ignore installing
  highlight = {
    enable = true, -- false will disable the whole extension
    disable = { "" }, -- list of language that will be disabled
    additional_vim_regex_highlighting = true,

  },
  indent = { enable = true, disable = { "yaml" } },
}

Can't seem to get it working at all.

dude, all of your plugins are working prefect for me. However, I can't seem get this one working for some reasons. I have tried different file types, i.e. .js, .less ect.

Changing Colors

How would you change the colors used? Or rather, what values would you set g:rainbow#colors to change them?

Whitelist Option?

Example: If I only want to use 16 colors (in a term with 256) a whitelist would be much easier to configure rather than a blacklist...

Side question: Is it possible to supply a range of numbers in let g:rainbow#blacklist?

Thanks for the great plugins, Junegunn. I'm using several of them ๐Ÿ˜„ ๐Ÿ™

Golang doesn't seem to be supported[Bug]

Describe the bug
I installed this plugin vim on my Mac. My OS X version is 11.6.

To Reproduce
Steps to reproduce the behavior, Please provide a minimal piece of code to produce this issue, along with it's filename and it's filetype detected by vim (via :set ft?), a piece of text is better than a picture here. For example:

File: bug.js, filetype=javascript

var pair = {x: 1, y: 2}
Steps:

Open file via vim example.go
See the color of { and } around text {x: 1, y: 2} is not getting colored.
Expected behavior
A clear and concise description of what you expected to happen.
Brackets are supposed to be colored.

Screenshots
Provide a screenshot to describe what you got.
image

Additional context
Are you using some third-party syntax plugins? Add any other context about the problem here.
Additional plugins that I have installed in vim:

  - rainbow_parentheses.vim: Already installed                 |~
  - rainbow: Already installed                                 |~
  - vim-go: Already installed                                  |~
  - coc.nvim: Already installed                                |~

Incorrect highlight group for comments in SML files

I've noticed that if I enable rainbow_parentheses in SML files, the plugin messes up syntax highlight group for comments.

(* SML comments look like this. *)

The highlight group changes from smlComment to smlModPath.

Overwrite automatic colors with predefined ones

Hi,

great plugin! It is the only one which works with neovims true color mode and javascript syntax plugin!
I want to define colors for parentheses levels by hand, to make them more outstanding. Automatic colors makes parentheses look like other words, especially when using semantic highlight. My VimL is not good enough to check how to do this when looking into the plugin sources. I tried already to add hi rainbowParensShell1 guifg=#ff0000 to my .nvimrc but this didn't do the trick :(

Rainbow Parentheses disables folding in c

I do a ton of C development, and use folding fairly heavily.

When your rainbow_parentheses plugin is enable, vim report 'no fold found' when attempting to fold code.

It appears that the regions which are created using

`let cmd = 'syntax region rainbowParens%d matchgroup=rainbowParensShell%d start=/%s/ end=/%s/ contains=%s'`

simply override the regions defined in the syntax file;

`syn region cBlock      start="{" end="}" transparent fold`

Adding 'fold' to the end of the region command appears to have fixed this for now, but its a pretty naive solution.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.