Sublime Forum

BracketHighlighter

#165

Tag support for experimental outside adjacent is in.

0 Likes

#166

Thanks! I had 3 hours of hell without that! :smiley:

About different highlight: my idea was only in case is an easy thing to do and it aims at certain situations like this:

There are some (probably) rare cases where highlight adjacent it may stay in your way. The idea is to highlight adjacent slightly different AND highlight regular brackets. So in the case i presented in the screenshots, outside brackets should be green, inside brackets should be dark (or light) green (or pink, or whatever i set in the colorscheme). Make sense?

0 Likes

#167

That just means you now appreciate me more :smile:.

Let me think about it. I don’t actually track whether I am catching an adjacent match currently. I inject some stuff to conditionally alter the algorithm to work in these adjacent cases, but it is rarely aware that the final matched brackets are in fact adjacent.

Right now, I am just happy I got it in. I have been putting it off for over a year because I just didn’t want to add more complexity to an already complex system. It really wasn’t as bad as I thought (once I finally spent real time analyzing what would need to be done). I know people have been wanting it though, so hopefully it works well, I figure with enough guinea pigs testing this out, we should hopefully find any overlooked problems.

0 Likes

#168

ST2 Experimental outside adjacent matching has been merged in.

Side note, I may add an additional option to have some bh_plugins ignore the “outside adjacent” setting. Things like pressing select and having it expand does not work with adjacent; instead, it just expands and shrinks over and over :smile:.

0 Likes

#169

Yay! Awesome thanks a lot, much appreciated. At first insight seems to work great, and looks mixed with inside adjacent which is handy. I’ll report back any oddities; I’ve a feature request, (that I have no idea if is complicated or not.)

When I put the cursor in
});|
It would be nice to skip the character “;” and highlight the bracket “)” this is handy for JavaScript. It would be also nice, something similar with “},|” skipping the “,”. But the comma should not be skipped for example with quotes as “aasdasd”,|

Thanks! :slight_smile:

0 Likes

#170

Please do. I am kind of relying on the community to find the issues with this…cause I’m lazy :smile:.

[quote=“tito”]When I put the cursor in
});|
It would be nice to skip the character “;” and highlight the bracket “)” this is handy for JavaScript. It would be also nice, something similar with “},|” skipping the “,”. But the comma should not be skipped for example with quotes as “aasdasd”,|
[/quote]

Its a cool idea, but I will be honest. When I rewrote BH1 to BH2, I did so vowing not to place language specific code in the core code. BH is surprisingly complex (and also something I need to cleanup as it has become pretty complex). The idea was always to allow the definitions to be exposed to the user and expose some kind of plugin system to do bracket manipulation if desired. I did this to take the burden off of me as I was becoming bogged down with language requests and the BH1’s code base just couldn’t handle it, so I threw away pyparadigm’s original code started from scratch and built BH2.

What you suggest can probably be done for javascript in your user folder by excluding the current “)” in javascript and writing a rule like: open = “(()” and close="()(?:;|,)?)" and then run that through a “post_match” event in a bh_plugin adjusting the selection to not include the “;” or “,” if present. This is basically what tags does. Tags just does a simple match for “<” and “>” and then runs it through “post_match” event in the “tag” bh_plugin which determines it is a tag and finds the corresponding open or close matching tag. So, theoretically doable.

0 Likes

#171

Thanks for the information, I’m a little lost on how to configure it to get that behaviour. :blush:, have been trying and watching the settings with no suscess, I also have some fear to break the current behaviour, my settings are just:

{ // Character threshold to search "search_threshold": 50000, "bracket_outside_adjacent": true, "no_multi_select_icons": true, "bracket_styles": { "tag": { "icon": "tag", // "color": "brackethighlighter.tag", "style": "underline" } } }

Oh, another request I just reminded, more important than the previous request; When a tag is outlined, it currently outlines the complete tag. For XML/RDF/XUL files this is somewhat distracting, for example currently the following between brackets is outlined:

<dcterms:identifier rdf:datatype="http://www.w3.org/2001/XMLSchema#anyURI">]http://url.tld/N</dcterms:identifier>] It would be nice to just highlitgh the tag name, as

<[dcterms:identifier] rdf:datatype="http://www.w3.org/2001/XMLSchema#anyURI">http://url.tld/N</[dcterms:identifier]>
I known( really ??) this may be complicated for the self-closing case ?

<[dcterms:identifier] rdf:resource="http://url.tld"/]>
There are also these infinite opening tags… and that /really/ disturbs

<input onsomething1="yaydaydya1()" onsomething2="yaydaydya2()" onsomething2="yaydaydya3()" onsomething3="yaydaydya4()" onsomething4="yaydaydya5()" onsomething4="yaydaydya6()" onsomething5="yaydaydya7()" onsomething6="yaydaydya8()" onsomething7="yaydaydya9()" />

Could be easily tweaked? I guess you are aware of this

0 Likes

#172

[quote=“tito”]Thanks for the information, I’m a little lost on how to configure it to get that behaviour. , have been trying and watching the settings with no suscess, I also have some fear to break the current behaviour, my settings are just:
CODE: SELECT ALL
{
// Character threshold to search
“search_threshold”: 50000,
“bracket_outside_adjacent”: true,
“no_multi_select_icons”: true,
“bracket_styles”: {
“tag”: {
“icon”: “tag”,
// “color”: “brackethighlighter.tag”,
“style”: “underline”
}
}
}
[/quote]

Lol, yeah, I understand that. It is one of those things that I wanted to be super simple, but it is so configurable that setting it up can be complicated. If I get some time in the next week, I may PM you with the basic idea.

In BH1 I used to have a low profile tag highlight mode

<]input ... />]
<]dcterms:identifier rdf:datatype="http://www.w3.org/2001/XMLSchema#anyURI">]http://url.tld/N<]/dcterms:identifier>]

I can probably add that back in again pretty easily. Create an issue, and I will look into exposing a tag plugin setting to do this.

0 Likes

#173

Issue added thanks for consideration

0 Likes

#174

Thanks, it may be a bit before I get to it. Not sure yet how much would need to be changed to make this happened (hopefully not too much, but I never know till I get into it). It was straight forward in BH1, but BH1 was less complicated times.

0 Likes

#175

New Feature to help with defining custom rules added (ST3 ONLY).

One of the slightly annoying things about BH is that if you want to try out a custom rule, or modify an existing one, you need to copy the whole default set of rules. If you do this in your User folder, new updates to BH rules will not be picked up until you rebase your rules.

Well, I set out to fix that with some new changes I will outline below:

Let’s say you have a custom language you want to have on your machine. Now, you can simply add it to one of the two settings arrays: “user_scope_brackets” and “user_brackets”:

[pre=#232628] “user_scope_brackets”: ],
“user_brackets”:
{
“name”: “mylang”,
“open”: “^\s*\b(if|subr|bytemap|enum|command|for|while|macro|do)\b”,
“close”: “\b(e(?:if|subr|bytemap|enum|command|for|while|macro)|until)\b”,
“style”: “default”,
“scope_exclude”: “string”, “comment”],
“plugin_library”: “User.bh_modules.mylangkeywords”,
“language_filter”: “whitelist”,
“language_list”: “mylang”],
“enabled”: true
}
],[/pre]

Let’s say you want to modify an existing rule, maybe just tweak the language list, all you have to do is use the same name and the item you want to change. Only that attribute will be overridden:
[pre=#232628] “user_brackets”:
// Angle
{
“name”: “angle”,
“language_list”:
“HTML”, “HTML 5”, “XML”, “PHP”, “HTML (Rails)”,
“HTML (Jinja Templates)”, “HTML (Twig)”, “HTML+CFML”,
“ColdFusion”, “ColdFusionCFC”, “laravel-blade”,
“Handlebars”, “AngularJS”,
“SomeNewLanguage” // <— New language
]
}
],[/pre]

Let’s say I want to insert a new rule between two rules. I can turn on debug mode and call the BracketHighlighter: (Debug) Filter Rules by Key then select position to see the current rule order and their postion index:

[pre=#232628]

    {"name": "curly", "position": 0},
    {"name": "round", "position": 1},
    {"name": "square", "position": 2},
    {"name": "html", "position": 3},
    {"name": "cfml", "position": 4},
    {"name": "php_angle", "position": 5},
    {"name": "angle", "position": 6},
    {"name": "cssedit_groups", "position": 7},
    {"name": "ruby_embedded_html", "position": 8},
    {"name": "ruby", "position": 9},
    {"name": "c_compile_switch", "position": 10},
    {"name": "php_keywords", "position": 11},
    {"name": "erlang", "position": 12},
    {"name": "bash", "position": 13},
    {"name": "fish", "position": 14},
    {"name": "mylang", "position": 15}
],

    {"name": "py_single_quote", "position": 0},
    {"name": "py_double_quote", "position": 1},
    {"name": "single_quote", "position": 2},
    {"name": "double_quote", "position": 3},
    {"name": "jsregex", "position": 4},
    {"name": "perlregex", "position": 5},
    {"name": "rubyregex", "position": 6},
    {"name": "mditalic", "position": 7},
    {"name": "mdbold", "position": 8}
]

][/pre]

Then you can specify the position you want to insert at:

[pre=#232628] “user_scope_brackets”: ],
“user_brackets”:
{
“name”: “mylang”,
“position”: 4, // <-- New position
“open”: “^\s*\b(if|subr|bytemap|enum|command|for|while|macro|do)\b”,
“close”: “\b(e(?:if|subr|bytemap|enum|command|for|while|macro)|until)\b”,
“style”: “default”,
“scope_exclude”: “string”, “comment”],
“plugin_library”: “User.bh_modules.mylangkeywords”,
“language_filter”: “whitelist”,
“language_list”: “mylang”],
“enabled”: true
}
],[/pre]

And if you run the debug command again, you will see that the position has changed:

[pre=#232628] {“name”: “curly”, “position”: 0},
{“name”: “round”, “position”: 1},
{“name”: “square”, “position”: 2},
{“name”: “html”, “position”: 3},
{“name”: “trex”, “position”: 4}, // <-- New position
{“name”: “cfml”, “position”: 5},
{“name”: “php_angle”, “position”: 6},[/pre]

This can be used to adjust the position of default rules from your user settings as well as shown by overrides above.

So, unless you are forking BH to pull request a change to the default rules, you can now modify the rules all in these two settings without copying or touching the default rules:

[pre=#232628] “user_scope_brackets”: ],
“user_brackets”: ],[/pre]

This will allow you to make changes, but still receive new updated rules.

**Debug mode is a setting in the settings file. Toggling debug mode via command palette only changes the settings in memory, so when you save the settings file, it reverts back to the original. I choose not to save it automatically to the settings file so as not to regenerate the settings file and erase all the comments in the settings file. If you want to put the plugin in a more “hard” debug mode, set “debug” to “true” manually in your settings file.

0 Likes

#176

Hello!

Sorry if this is the wrong place to ask for this.

I love this plugin, but I lack, err, the artistic eye (reason I don’t do website design) so am having a hard time making visually appealing colour choices
and highlighting styles for myself. If anyone could share their relevant settings for a dark backgrounds I’d appreciate it. :smile:

Sorry for the inconvenience. :blush:

0 Likes

#177

A couple of new additions (ST3 Only):

Content Bar
This is an experimental content bar. This is a feature that has been requested a number of times, but I have held off due to Sublime’s limitations. I have added recently only as an experiment, but I may keep it around. This is experimental and not guaranteed to stick around and its features/behavior are subject to change. The future of this feature depends on the feedback I get, so please do give feedback: negative or positive.

So This experimental feature exists in two forms. The first can be seen by enabling the new “content_highlight_bar” setting. This will draw a line highlighting a brackets content at the start of the line. This has the lowest overhead and works with monospace fonts and proportional fonts.

So the second form has a bit more overhead and probably only works well on monospace fonts. This form draws the content bar at the brackets indentation level. It can not draw the line across empty spaces, and I currently do not draw the line if text comes before the line (this is illustrated in the first example below). Feature requires “content_highight_bar” and “align_content_highlight_bar” to be set to true.

Toggle Brackets
This feature is made possible by some changes made to the “bracketselect” bh_plugin. By setting up the selection key binding as shown below, instead of jumping through nested brackets in just one direction, this binding will toggle between the opening and closing of the current bracket only:

[pre=#232628] {
“keys”: “ctrl+m”],
“command”: “bh_key”,
“args”:
{
“no_outside_adj”: true,
“lines” : true,
“plugin”:
{
“type”: “all”],
“command”: “bh_modules.bracketselect”,
“args”: {“select”: “right”, “alternate”: true}
}
}
},[/pre]

Anyways hope you enjoy, and please leave feedback about the experimental content bar feature.

0 Likes

#178

Hi, Im just wondering if the brackets(open n close) is not highlighted does that mean that there is something wrong with the codes in the brackets? because i have something like this:

if()
{
  if()
  {
     
  }
  else
  {

  }
}

the second ifs curly brackets and else are highlighted but the first ifs curly bracket doesnt get highlighted.

0 Likes

#179

You need to be a bit more specific on your scenario. Where are your cursors? BH highlights the immediate brackets enclosing the cursor. It does not show all nested brackets, just eh immediate brackets around the cursor.

0 Likes

#180

Great package, has been a real time saver for me.

I have a question though. I cannot get curly bracket icon to show in same color as bracket highlight; it just shows in black which is really hard to see. You have to look really closely to see at all.

Tried everything; can you suggest how I can change this please?

Screenshot:

When setting the color options what are the difference between the foreground and background please?

0 Likes

#181

@kmm2908, please post your settings rule and your color-scheme configured rule that goes along with it so I can understand what you are doing.

0 Likes

#182

[quote=“facelessuser”]A couple of new additions (ST3 Only):

Content Bar … [/quote]

Many thanks, facelessuser.
This is definately a useful feature!

0 Likes

#183

[quote=“jfcherng”]Many thanks, facelessuser.
This is definately a useful feature![/quote]

Your welcome :wink:.

0 Likes

#184

The custom color is working on the bracket highlight, it is just the icon in the gutter that is black and hard to see.

Settings:

“curly”: {
“icon”: “curly_bracket”,
“color”: “brackethighlighter.curly”,
“style”: “outline”
},
“round”: {
“icon”: “round_bracket”,
“color”: “brackethighlighter.round”
// “style”: “underline”
},
“square”: {
“icon”: “square_bracket”,
“color”: “brackethighlighter.square”
// “style”: “underline”
},
“angle”: {
“icon”: “angle_bracket”,
“color”: “brackethighlighter.angle”
// “style”: “underline”
},
“tag”: {
“icon”: “tag”,
// “endpoints”: true,
“color”: “brackethighlighter.tag”,
“style”: “outline”
},
“c_define”: {
“icon”: “hash”
// “color”: “brackethighlighter.c_define”,
// “style”: “underline”
},
“single_quote”: {
“icon”: “single_quote”,
“color”: “brackethighlighter.quote”
// “style”: “underline”
},
“double_quote”: {
“icon”: “double_quote”,
“color”: “brackethighlighter.quote”
// “style”: “underline”
},
“regex”: {
“icon”: “regex”,
“color”: “brackethighlighter.quote”
// “style”: “underline”
}

Color entries in theme file:

// custom colors for brackethighlighter.

name
Bracket quote
scope
brackethighlighter.quote
settings

background
#F00
foreground
#FFF



name
Bracket curly
scope
brackethighlighter.curly
settings

background
#0F0
foreground
#FFF



name
Bracket round
scope
brackethighlighter.round
settings

background
#00F
foreground
#FFF



name
Bracket square
scope
brackethighlighter.square
settings

background
#FF0
foreground
#FFF



name
Bracket angle
scope
brackethighlighter.angle
settings

background
#0FF
foreground
#FFF



name
Bracket tag
scope
brackethighlighter.tag
settings

background
#FFF

Let me know if I need to post anything else.

Thanks for quick reply.

0 Likes