Sublime Forum

BracketHighlighter

#81

When you know the code well, stuff like this is trivial.

I agree though that it doesn’t look good. At least not to me.

0 Likes

#82

Though it was a fun exercise, I think I will hold off on adding the line between brackets. I can add it without affecting people that don’t like it, but it does seem unneeded with the current ST2 indentation highlight option. Notepad++ only does the line on foldable regions, and the indentation option in ST2 does the same. So I think what was being asked here is already accomplished in ST2.

I would have to get a lot of people asking for this to support such an option.

0 Likes

#83

i have question regarding tag matching.
does it make sense to you to match tags when the cursor is between tags?
like:
<> |


| |
<> |

currently div tags are matched when cursor is within either one of the opening/closing tags
<>| <div | >
<>|
0 Likes

#84

[quote=“vitaLee”]i have question regarding tag matching.
does it make sense to you to match tags when the cursor is between tags?
like:
<> |


| |
<> |

currently div tags are matched when cursor is within either one of the opening/closing tags
<>| <div | >
<>| [/quote]

+1

0 Likes

#85

[quote=“vitaLee”]i have question regarding tag matching.
does it make sense to you to match tags when the cursor is between tags?
like:
<> |


| |
<> |

currently div tags are matched when cursor is within either one of the opening/closing tags
<>| <div | >
<>| [/quote]

It makes since, but it is not as easily done. I am kind of doing what I believe ST2 does, first I use the angle bracket matching to find a potential tag, then I see if it is a tag (opening or closing) and then I look for the pair if it is a tag. If you put a cursor in here:

(\w-]+)\s(:)\s**

Do you match the bracket or the tag?

If I added something like this I might take this approach if I find a bracket match before I find a tag, don’t search for tag, if I find a tag before I find a bracket match, then highlight the tags. That way in the above example, if I were inside the brackets, the tag does not get matched, but if I am outside the brackets, then the tags would get matched.

Let me play around with this.

0 Likes

#86

i was thinking the same.
match the first bracket you find in either direction, that’s why it’s called BracketHighlighter :smile:

0 Likes

#87

[quote=“vitaLee”]i was thinking the same.
match the first bracket you find in either direction, that’s why it’s called BracketHighlighter :smile:[/quote]

Its just fitting it into the algorithm is a little tricky. It was streamlined to do it one way, but to do it the way you are suggesting may take me a while to do well (if I get it working good at all). Also, it is not on the top of my list of things to do since it would also be big headache to make happen.

What I plan to do in the next week is to resolve my current issue with strings:

  • I don’t like that I am wasting time detecting regex conventions for different languages in strings, and I think it is silly I am highlighting “/” in regex strings. So I am thinking I want to only highlight quoted strings, but still allow the searching for and highlighting of internal string brackets in any non-quoted strings. If no brakcets are found in a non-quoted string, I want to ignore the string and find the next parent bracket. It would be a more generic support for brackets inside any string, and it would support more languages.
  • This could also apply to people who don’t want to highlight quotes, but still like to highlight brackets inside strings.
0 Likes

#88

Version 1.7

  • Hide parent quote highlighting when child quotes are highlighted
  • Allow the searching for brackets in non-quoted code scoped as strings (like regex)
  • Add setting “highlight_string_brackets_only” which allows never highlighting quotes but leaves internal string bracket highlighting on
  • deprecate “enable_forward_slash_regex_strings” in favor of “find_brackets_in any_strings”

Hopefully that all makes sense, basically I just made some tweaks to string highlighting and allow for string bracket highlighting now to occur in any string scope.

0 Likes

#89

Forgive me if this has been mentioned, but I’d find it epically cool and useful to have multiple bracket types highlighted at once (with only one insertion point) like this:

http://puu.sh/mBWQ

0 Likes

#90

[quote=“peppy”]Forgive me if this has been mentioned, but I’d find it epically cool and useful to have multiple bracket types highlighted at once (with only one insertion point) like this:

http://puu.sh/mBWQ[/quote]

The problem is, BracketHighlighter is designed to minimize how much time it is searching to give you pretty instant highlighting without bogging down your editor. By doing what you suggest, you would have to keep crawling back looking for even more brackets; this would take more time on every search.

Also, I think it would make things more cluttered. The point of BracketHighlighter is to quickly show you what block you are in, but if all the blocks get highlighted, it is not nearly as effective at quickly showing you were you are.

Though opinion may differ on this point, I do not foresee this becoming an addition to BracketHighlighter, but thanks for your interest.

0 Likes

#91

I figured that might be the case. If I get the time I might fork and give it a go to see how it handles performance-wise. I think it is be a matter of personal opinion whether such an addition makes things cluttered or more usable :smile:.

0 Likes

#92

Yeah, I understand. Another problem is, it won’t be a simple addition. Everything is streamlined to do it the current way. Anyways, good luck.

0 Likes

#93

Version 1.8.0

  • Add new commands: “Show Bracket String Escape Mode” and “Toggle Bracket String Escape Mode”. Default is “regex”

Small update to allow you to toggle the string escape mode for string brackets. There are two modes “regex” and “string”:

string escape: \{
regex escape: {

I was kind of annoyed today when I was trying to modify some regex in a string in a JSON file, and BracketHighlighter was getting matches wrong. The current method works great when you are in something like Javascript/Perl regex etc., but not a normal string that is to be converted into regex. So now you can simply toggle to a different escape mode if you need to.

0 Likes

#94

Thanks for this great plugin, it’s very useful.

I was wondering if you had any plans to add support for Ruby, particularly the matching of Ruby’s method and block syntax? I noticed you mentioned you weren’t a Ruby developer, so here’s a quick example:

def my_function(things)
  things.each do |thing|
    ...
  end
end

In this example, there would be two pairs of “braces”:

  1. “def” would match the final “end”.
  2. “do” would match the other “end”.

I had a quick look at implementing this myself in the hope it was a quick change, but didn’t get too far with my limited Python experience.

0 Likes

#95

[quote=“Acciaccatura”]Thanks for this great plugin, it’s very useful.

I was wondering if you had any plans to add support for Ruby, particularly the matching of Ruby’s method and block syntax? I noticed you mentioned you weren’t a Ruby developer, so here’s a quick example:

def my_function(things)
  things.each do |thing|
    ...
  end
end

In this example, there would be two pairs of “braces”:

  1. “def” would match the final “end”.
  2. “do” would match the other “end”.

I had a quick look at implementing this myself in the hope it was a quick change, but didn’t get too far with my limited Python experience.[/quote]

The functionality you are looking for is the same as highlighting brackets, but the code to highlight these keywords like brackets don’t fit in the algorithm at all.

You are not the first to ask this, and I have not yet decided if I want to pursue this yet. I will consider it, but I will not make any promises.

0 Likes

#96

[quote=“facelessuser”]
The functionality you are looking for is the same as highlighting brackets, but the code to highlight these keywords like brackets don’t fit in the algorithm at all.

You are not the first to ask this, and I have not yet decided if I want to pursue this yet. I will consider it, but I will not make any promises.[/quote]

Thanks for replying; I figured I wouldn’t be the only one interested in this feature. Fingers crossed this gets onto the roadmap :smile:

0 Likes

#97

I have a (hopefully) quick question about the margin bracket symbols. I like them a lot and they look very good in Soda Theme (light grey without coloring). However, for markdown files I use MarkdownEditing and the margin brackets are colored in an ugly green. I tried to fix it by adding the code below (and more) to the .tmTheme file but it doesn’t change anything. Any ideas?

Also about markdown: ` brackets are not supported, right?

Thanks for the great plugin!

github.com/ttscoff/MarkdownEditing

<dict> <key>name</key> <string>Bracket Tag</string> <key>scope</key> <string>bracket.tag</string> <key>settings</key> <dict> <key>foreground</key> <string>#FD971F</string> </dict> </dict>

0 Likes

#98

Then you have to tell BracketHighlighter to use that scope in the user preferences. Go to Preferences > Package Settings > Bracket Highlighter > Settings - User and add the following:

{ "quote_scope" : "bracket.quote", "curly_scope" : "bracket.curly", "round_scope" : "bracket.round", "square_scope": "bracket.square", "angle_scope" : "bracket.angle", "tag_scope" : "bracket.tag", }

0 Likes

#99

i noticed several things when i tried swap quotes plugin
quoted text at column 1 doesnt trigger bracket highlights.
that’s not what initially caught my attention but i think it may be related to the next thing.
having delcaration like this

a = 'bc'

when i try “swap quotes” i get

a = "b"'

notice that in its initial state the line ends with the closing quote.
if you add whatever character at the end of the line, then it works as expected

a = 'bc';
a = "bc";
0 Likes

#100

[quote=“vitaLee”]i noticed several things when i tried swap quotes plugin
quoted text at column 1 doesnt trigger bracket highlights.
[/quote]

Can you elaborate because I do not understand what problem you are describing.

[quote=“vitaLee”]
that’s not what initially caught my attention but i think it may be related to the next thing.
having delcaration like this

a = 'bc'

when i try “swap quotes” i get

a = "b"'

notice that in its initial state the line ends with the closing quote.
if you add whatever character at the end of the line, then it works as expected

a = 'bc'; a = "bc"; [/quote]

I know what this is. I will have it fixed sometime soon.

0 Likes