Code Monkey home page Code Monkey logo

rainbowbrackets's Introduction

RainbowBrackets

License Downloads

Introduction

RainbowBrackets uses the brackets and colors that you give in the settings file, searches and highlights brackets in file views. Brackets at different levels will be dyed with different colors according to the settings. Colors are gave in a list, and will be used repeatedly.

parentheses, braces, brackets are treated as brackets. brackets are configured in setting file, it means you can use OO as a opening bracket and CC as a close bracket. some characters will cause many match error, can't serve as brackets, such as <>.

Example

{ [ 【 OO OO 《《》OOxCC》 CC CC 】 ] }

Installation

Clone or download this repository to your Packages directory of Sublime Text. Note that the directory name should be the name of this repository.

If you have installed Package Control, press down ctrl+shift+p to get into the command palette, then, input the command pcip (Package Control: Install Package) and Enter to run it. Wait some time… After package infomations have been loaded remotely, input the name of this plugin RainbowBrackets, and press down Enter to install it.

Usage

Settings

Settings template

{
    "debug": false,

    "default_config": {
        "bracket_pairs": {
            "(": ")",
            "[": "]",
            "{": "}"
        },

        "coloring": false,

        "enabled": true,

        "ignored_scopes": [
            "comment",
            "string",
            "constant"
        ],

        "color.error": "#FF0000",

        "color.cycle": [
            "#FF0000", // level0
            "#FF6A00", // level1
            "#FFD800", // level2
            "#00FF00", // level3
            "#0094FF", // level4
            "#0041FF", // level5
            "#7D00E5"  // level6
        ],

    },

    "syntax_specific": {
        "Scheme": {
            "extensions": [".scm", ".ss"],

            "ignored_scopes": [
                "comment", "string", "constant", "symbol"
            ]
        },

        "JSON": {
            "bracket_pairs": {
                "{": "}",
                "[": "]"
            },

            "extensions": [
                ".json",
                ".sublime-build",
                ".sublime-color-scheme",
                ".sublime-commands",
                ".sublime-keymap",
                ".sublime-menu",
                ".sublime-settings",
                ".sublime-theme",
            ],

            "ignored_scopes": [
                "comment", "string"
            ]
        }
    }
}
  • ignored_scopes: to ignore brackets in some scopes(such as comment, string).

Commands

  • Preferences: RainbowBrackets Settings
  • RainbowBrackets: toggle debug
  • RainbowBrackets: make rainbow
  • RainbowBrackets: clear rainbow
  • RainbowBrackets: clear color schemes

Key bindings

RainbowBrackets support fast opreating brackets, including select, remove and transform.

Keys Description
ctrl+alt+9 Replace the brackets around the cursors with ()
ctrl+alt+0 Replace the brackets around the cursors with ()
ctrl+alt+[ Replace the brackets around the cursors with []
ctrl+alt+] Replace the brackets around the cursors with []
ctrl+alt+shift+[ Replace the brackets around the cursors with {}
ctrl+alt+shift+] Replace the brackets around the cursors with {}
ctrl+alt+r Remove the brackets around the cursors
ctrl+alt+. Remove the brackets around the cursors and select the text within the brackets
ctrl+alt+, Select the brackets around the cursors and the text within the brackets

Screenshots

  • Material color scheme, JSON file.
  • Material color scheme, Scheme language
  • Material lighter color scheme, Scheme language

rainbowbrackets's People

Contributors

absop 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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

rainbowbrackets's Issues

Allow for custom bracket pairs by scope

Currently, the bracket pair characters can only be changed on a per-filename basis. This is problematic for panels that display text, such as the LSP log panel, where I want triangle brackets ("<>") colored in my C++ source file but just curly brackets ("{}") in the LSP panel.

Error in loading settings

Hi, my plugin stopped working without any manual update. I removed and installed it again, but it still does not work.

I get the following error popup:

RainbowBrackets: error in loading settings.

Is there a good solution for it? Thank you in advance.

How to highlight brackets that aren't on the same visible line

Is it feasible to add an option that allows to only highlight a pair of brackets if they are on different visible lines (by visible I mean that line may have either soft or hard break)?
This plugin can greatly improve readability when dealing with nested brackets that appear on different lines, but if brackets are on the same line then making them rainbow just adds a color noise that rather distracts than helps.

Extension of current color scheme causes ST3's Git integration colors to shift

Before installing RainbowBrackets:
Screen Shot 2020-02-18 at 3 05 05 PM

After:
Screen Shot 2020-02-18 at 3 05 26 PM

(Both of these are with the default ST3 color scheme of Monokai active.)

Note the change in colors of Git icons in sidebar, and green diff market in the gutter.

ST3 documentation says

the color of the badges will…adapt to the closest hue in the active color scheme.

My guess is the logic is that there's some "canonical" color for these icons, and it does some color diffing algorithm to find the closest in the active theme. However, because of the way RainbowBrackets extends the active theme with rainbow colors (see Application Support/Sublime Text 3/Packages/User/Color Schemes/RainbowBracket/[NameOfCurrentTheme].sublime-color-scheme), it ends up selecting really garish bright colors for these git icons.

Is there any setting or way to have RainbowBrackets add the colors it needs for brackets, but have ST3 stick with the original color scheme's colors for git icons?

Updating file syntax doesn't refresh rainbows

It looks like the syntax of a given file is only read once when opening, and the plugin doesn't update if the syntax is changed. E.g. if I have a plain text file that I change to C++, I need to run RainbowBrackets: Close Plugin followed by RainbowBrackets: Setup Plugin on the file to refresh and apply my scheme-specific coloring.

Plugin loses brackets

Hi!

Nice plugin!
But this is what I get with my LaTeX macros.
I tried to delete/add characters but I have no idea why it is so.

изображение

\newcommand{\helpangles}[1]{
	\foreach \a in {0,5,...,355} \draw[help lines] (#1.center) -- (#1.\a) -- ++(\a:0.5) node[font=\tiny] {\a};
}

\tikzset{%
	show curve controls/.style={
		postaction={
			decoration={
				show path construction,
				curveto code={
					\draw [blue,very thin]
					(\tikzinputsegmentfirst) -- (\tikzinputsegmentsupporta)
					(\tikzinputsegmentlast) -- (\tikzinputsegmentsupportb);
					\fill [red, opacity=0.5]
					(\tikzinputsegmentsupporta) circle [radius=.5ex]
					(\tikzinputsegmentsupportb) circle [radius=.5ex];
				}
			},
			decorate
}}}

Plugin loading error (ST4 4169)

On startup, I get the following error in failing to load RainbowBrackets:

Exception in thread Thread-1:
Traceback (most recent call last):
  File "./python3.8/threading.py", line 932, in _bootstrap_inner
  File "C:\Users\pluto\AppData\Roaming\Sublime Text\Installed Packages\Package Control.sublime-package\package_control/package_cleanup.py", line 108, in run
  File "C:\Users\pluto\AppData\Roaming\Sublime Text\Installed Packages\Package Control.sublime-package\package_control/package_manager.py", line 1346, in cleanup_libraries
  File "C:\Users\pluto\AppData\Roaming\Sublime Text\Installed Packages\Package Control.sublime-package\package_control/package_manager.py", line 963, in find_orphaned_libraries
  File "C:\Users\pluto\AppData\Roaming\Sublime Text\Installed Packages\Package Control.sublime-package\package_control/library.py", line 155, in list_unmanaged
PermissionError: [Errno 13] Permission denied: '\\\\?\\C:\\Users\\pluto\\AppData\\Roaming\\Sublime Text\\Lib\\python33\\PyYAML-5.1.1.dist-info\\INSTALLER'
Traceback (most recent call last):
  File "C:\Program Files\Sublime Text 4\Lib\python38\sublime_plugin.py", line 975, in on_activated
    run_view_callbacks('on_activated', view_id)
  File "C:\Program Files\Sublime Text 4\Lib\python38\sublime_plugin.py", line 741, in run_view_callbacks
    callback(v, *args)
  File "C:\Program Files\Sublime Text 4\Lib\python38\sublime_plugin.py", line 162, in profiler
    return event_handler(*args)
  File "C:\Users\pluto\AppData\Roaming\Sublime Text\Installed Packages\RainbowBrackets.sublime-package\main.py", line 467, in on_activated
    self.check_view_load_listener(view)
  File "C:\Users\pluto\AppData\Roaming\Sublime Text\Installed Packages\RainbowBrackets.sublime-package\main.py", line 412, in check_view_load_listener
    listener = cls.check_view_add_listener(view)
  File "C:\Users\pluto\AppData\Roaming\Sublime Text\Installed Packages\RainbowBrackets.sublime-package\main.py", line 379, in check_view_add_listener
    syntax = cls.get_view_syntax(view) or "<default>"
  File "C:\Users\pluto\AppData\Roaming\Sublime Text\Installed Packages\RainbowBrackets.sublime-package\main.py", line 392, in get_view_syntax
    syntax = view.syntax().name
AttributeError: 'NoneType' object has no attribute 'name'
Traceback (most recent call last):
  File "C:\Program Files\Sublime Text 4\Lib\python38\sublime_plugin.py", line 975, in on_activated
    run_view_callbacks('on_activated', view_id)
  File "C:\Program Files\Sublime Text 4\Lib\python38\sublime_plugin.py", line 741, in run_view_callbacks
    callback(v, *args)
  File "C:\Program Files\Sublime Text 4\Lib\python38\sublime_plugin.py", line 162, in profiler
    return event_handler(*args)
  File "C:\Users\pluto\AppData\Roaming\Sublime Text\Installed Packages\RainbowBrackets.sublime-package\main.py", line 467, in on_activated
    self.check_view_load_listener(view)
  File "C:\Users\pluto\AppData\Roaming\Sublime Text\Installed Packages\RainbowBrackets.sublime-package\main.py", line 412, in check_view_load_listener
    listener = cls.check_view_add_listener(view)
  File "C:\Users\pluto\AppData\Roaming\Sublime Text\Installed Packages\RainbowBrackets.sublime-package\main.py", line 379, in check_view_add_listener
    syntax = cls.get_view_syntax(view) or "<default>"
  File "C:\Users\pluto\AppData\Roaming\Sublime Text\Installed Packages\RainbowBrackets.sublime-package\main.py", line 392, in get_view_syntax
    syntax = view.syntax().name
AttributeError: 'NoneType' object has no attribute 'name'

On looking at the sublime API reference, it seems the view.syntax() function can return None as well, which is not handled here

How to use for plain text?

Here is my RainbowBrackets.sublime-settings.
Files with extension ".cmd" are working ok, but no rainbow colors in .txt files.
How use this plugin for ascii files?

{
"languages": {
"plaintext": {
"extensions": ["txt"],
"mode":"all"
},
"dosbatch": {
"extensions": ["cmd"],
"mode": "all",
}
}
}

Less than and greater than signs not working as brakets

When adding < and > (as blow) to the settings file I get the following highlighting in python:

        "pairs": {
            "(": ")",
            "[": "]",
            "{": "}",
            "<": ">"
        },

            "python": {
                "opening": ["(", "[", "{", "<"],
                "ignored_scopes": [
                    "comment", "string"
                ]
            },

Screenshot 2021-05-05 101213

During upddate, possible conflict causes Color Scheme to change

Bug

I believe this is #21 again.

My Sublime Text color scheme keeps changing from whatever I've defined it to be during startup, and into Mariana. The color scheme (CS) only changes on a per buffer basis. Some keep my CS, others are in mariana.

Moreover, it causes ST4 to disable other packages I use on a regular basis which is even more annoying.
This may be conflict with A File Icon which updates on start, but I'm not sure, given this only updates once per day.

ST4 startup console log

Sublime Text v3 Plugin Load Problem

reloading plugin RainbowBrackets.main
Traceback (most recent call last):
File "C:\Program Files\Sublime Text 3\sublime_plugin.py", line 125, in reload_plugin
m = importlib.import_module(modulename)
File "./python3.3/importlib/init.py", line 90, in import_module
File "", line 1584, in _gcd_import
File "", line 1565, in _find_and_load
File "", line 1532, in _find_and_load_unlocked
File "C:\Program Files\Sublime Text 3\sublime_plugin.py", line 1199, in load_module
exec(compile(source, source_path, 'exec'), mod.dict)
File "C:\Users\Mehmet\AppData\Roaming\Sublime Text 3\Installed Packages\RainbowBrackets.sublime-package\main.py", line 199
f"loaded file: {(self.view.file_name() or 'untitled')}",
^
SyntaxError: invalid syntax

Wrong bracket matching

Hello,
I recently found this extension and its amasing. But i found one small issue in javascript.
As you can see on this screen

Here is my config for the language:

        "php-js": {
            "extensions": [
                "php",
                "js",
                "jsx"
            ],
            "mode": "all"
        },

Also, when I want to ignore the curly brackets "!brackets": ["("], i get this
Snímek z 2019-06-13 15-24-02

Am I doing something wrong?

Key binding for make rainbow

Hi, thanks for the very useful plugin. Is there a keyboard shortcut for make/clear rainbow? Or is is possible to add one to Sublime's key bindings? I couldn't work out how to do it.

Make Rainbow on each open file

It would be awesome that we would have an option to match brackets by default on open files and keep updating those matches on changes.

[Feature Request] start_level for coloring

Hi @absop, thanks for this sweet plugin :-)

Do you think it'd be possible to add an "nesting_level"/"start_level" for the rainbows?
I just ask since generally like the common syntax highlighting as it is not disruptive etc. But on nested brackets this plugin of course shows its strength. So, I'd like to keep it off for the first level but would like to see it starting with the second.

Thanks for any feedback on this. Cheers!

your plugin creates an ugly color-scheme that overrides my default one

i have one dark theme package installed, looks very good.

but when your plugin creates this file: ~/.config/sublime-text/Packages/User/Color Schemes/RainbowBrackets/One Dark.sublime-color-scheme

the default one dark color scheme is overridden with this file which looks like this:

{
    "name": "One Dark",
    "author": "https://github.com/absop/RainbowBrackets",
    "variables": {},
    "globals": {},
    "rules": [
        {
            "scope": "JSON.mismatch.rb",
            "foreground": "#FF0000",
            "background": "#282c34"
        },
        {
            "scope": "JSON.l0.rb",
            "foreground": "#FF0000",
            "background": "#282c35"
        },
        {
            "scope": "JSON.l1.rb",
            "foreground": "#FF6A00",
            "background": "#282c35"
        },
        {
            "scope": "JSON.l2.rb",
            "foreground": "#FFD800",
            "background": "#282c35"
        },
        {
            "scope": "JSON.l3.rb",
            "foreground": "#00FF00",
            "background": "#282c35"
        },
        {
            "scope": "JSON.l4.rb",
            "foreground": "#0094FF",
            "background": "#282c35"
        },
        {
            "scope": "JSON.l5.rb",
            "foreground": "#0041FF",
            "background": "#282c35"
        },
        {
            "scope": "JSON.l6.rb",
            "foreground": "#7D00E5",
            "background": "#282c35"
        },
        {
            "scope": "Scheme.mismatch.rb",
            "foreground": "#FF0000",
            "background": "#282c34"
        },
        {
            "scope": "Scheme.l0.rb",
            "foreground": "#FF0000",
            "background": "#282c35"
        },
        {
            "scope": "Scheme.l1.rb",
            "foreground": "#FF6A00",
            "background": "#282c35"
        },
        {
            "scope": "Scheme.l2.rb",
            "foreground": "#FFD800",
            "background": "#282c35"
        },
        {
            "scope": "Scheme.l3.rb",
            "foreground": "#00FF00",
            "background": "#282c35"
        },
        {
            "scope": "Scheme.l4.rb",
            "foreground": "#0094FF",
            "background": "#282c35"
        },
        {
            "scope": "Scheme.l5.rb",
            "foreground": "#0041FF",
            "background": "#282c35"
        },
        {
            "scope": "Scheme.l6.rb",
            "foreground": "#7D00E5",
            "background": "#282c35"
        },
        {
            "scope": "<default>.mismatch.rb",
            "foreground": "#FF0000",
            "background": "#282c34"
        },
        {
            "scope": "<default>.l0.rb",
            "foreground": "#FF0000",
            "background": "#282c35"
        },
        {
            "scope": "<default>.l1.rb",
            "foreground": "#FF6A00",
            "background": "#282c35"
        },
        {
            "scope": "<default>.l2.rb",
            "foreground": "#FFD800",
            "background": "#282c35"
        },
        {
            "scope": "<default>.l3.rb",
            "foreground": "#00FF00",
            "background": "#282c35"
        },
        {
            "scope": "<default>.l4.rb",
            "foreground": "#0094FF",
            "background": "#282c35"
        },
        {
            "scope": "<default>.l5.rb",
            "foreground": "#0041FF",
            "background": "#282c35"
        },
        {
            "scope": "<default>.l6.rb",
            "foreground": "#7D00E5",
            "background": "#282c35"
        }
    ]
}

this file has horrible colors. i tried to remove the file 2 times in a row. its created automatically by the plugin ( i guess ).

why would make this?

how do i get rid of this?

Plugin doesn't appear to support SublimeText 4.

All,

I just installed this plugin for Sublime Text 4, and I cannot seem to get brackets brackets to show up. I tried with three different languages (Terraform, Groovy, and Rust) all of them don't seem to be working.

Here is an example of Terraform & Rust code without rainbow brackets.
no-rainbow-brackets-tf
no-rainbow-brackets-rust

  • Mike D.

Bad performance with SublimeREPL

I use the REPL a lot while coding, and I have found that after evaluating around ~10 forms on the REPL I start to get a lot of delay from the evaluation, whereas without this plugin there is no delay.

I haven't tried to dig for why that happens, just wanted to leave some feedback. The plugin works, and looks very good, but for those that need SublimeREPL it is unusable.

Cheers.

  • EDIT: I use it with Clojure, which means there are lots and lots of brackets to highlight.

Package index lacks Sublime Text compatibility annotations

Recent versions of RainbowBrackets don't work in ST3, since they rely on Python 3.8 features and new ST4 APIs. However, they aren't marked as being compatible only with ST 4.x in the package control index, so pcon will attempt to update to 4.2.0 even if you're running ST3, breaking the plugin.

You can still manually downgrade, but it would be better to properly annotate each release with the ST versions it supports so that pcon's auto-update doesn't install incompatible versions.

Suddenly high cpu usage

Thanks for creating such a nice plugin.
I have an issue. just a few minutes ago. my ST was using very high amount of cpu. i saw the ST console and saw rainbowbracket making color cahce from color scheme. i restarted ST then the issue was resolved.

Automatically apply rainbow on file open

Hi there. I could have sworn this package used to apply rainbow brackets when opening a file. Now it seems like I have to do it manually. Is there a way to get the bracket coloring to apply automatically again?

Screen.Recording.2021-05-07.at.10.30.18.am.mov

My config looks like this:

{
  "debug": true,
  "languages":
  {
    "javascript":
    {
      "extensions":
      [
        "js",
        "jsx"
      ],
      "mode": "all"
    }
  },
  "rainbow_colors":
  {
    "matched":
    [
      "#FE8F95",
      "#F9C189",
      "#C2ECA2",
      "#78E6F4",
      "#EAA1FE"
    ],
    "unmatched": "#CCCCCC"
  }
}

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.