Sublime Forum

ST3: BracketHighlighter 2

#1

I now have a fully working BH2 branch for ST3

github.com/facelessuser/Bracket … ree/BH2ST3

Documentation for BracketHighlighter is sparse at most. There are no keybindings, but I provide an example keybinding file to help. You can access most of the special bracket plugins without keymaps through the menu: Tools->Packages->BracketHighlighter or through the command palette. Though I recommend creating some keymaps for things you use a lot.

If you are trying to create your own custom brackets for BH2 (which is now allowed), remember that the opening and closing regex can only have ONE capturing group.

Enjoy.

1 Like

#2

Pretty cool! Good to see the “essentials” coming to ST 3 so soon. :smile:

0 Likes

#3

I just can’t get this to work even on a new installation of sublime text 3.

0 Likes

#4

Please answer the following questions:
Did you restart after installing? (For really complex plugins, usually a good restart is required to get the plugin going.)
How did you install it?
Where did you install it? (must be in Packages/BracketHighlighter)
What Platform are you on (Mac\Linux\Windows)?
Do you see errors in Sublime Console and can you share those if so?

0 Likes

#5

Sorry my mistake, when I downloaded it - it came with BracketHighlighter-BH2ST3 … so I changed it to BracketHighlighter and it works fine.

Thanks.

0 Likes

#6

There is a way of toggling quotes types? Like, let’s say, press ctrl+shift+’ and change " to ', press again change it back to " ?

Thanks!

0 Likes

#7

Look under Tools->Pakckages->BracketHighlighter->Swap Quotes

Also, you can look in the Command Palette by simply typing “BracketHighlighter” to get a list of BracketHighlighter commands.

If you want a shortcut, simply look at the example shortcut file I provide, and copy the swap quotes one using the the actual key combination you would like.

0 Likes

#8

In theory, what’s in theory should work in practice. In practice… it doesn’t. :mrgreen:

(http://img.iamntz.com/jing/video_46.mp4)

0 Likes

#9

Well, lets peek behind the current and see whats going on.

  1. BH quote swapping is scope based.
  2. JSON has one valid string type, double quotes (single quotes are not valid strings in JSON; therefore, they won’t be of string scope type)

BracketHighlighter’s special plugins trigger off of matched brackets. Since double quotes are valid in JSON, swap quotes works just fine because BH reports the brackets. Single quotes are not valid brackets in JSON (they are not valid string tokens); therefore, BH finds no brackets to report and swap quotes never gets called.

0 Likes

#10

Hmm, you are right! Thanks for explanation. I was only tried to change quotes in keymap file and… it didn’t worked and i removed the key.

Tried right now on another file and works just fine.
Thanks again! :geek:

0 Likes

#11

No problem. It all stems from the issue of trying to match an opening and closing bracket that have no differences (like with quotes). How do you know you are between the quotes and not outside the quotes without parsing the syntax of the entire file? You could assume that if the user is calling the plugin, that they must be between two quotes, and then you just look for the first unescaped quote and look for its pair. But with bracket highlighter, I can’t be that sloppy (maybe for a plugin that did nothing but swap quotes it would be okay). So BH relies on the fact that Sublime Text has already parsed the file and reports where the strings are. That is why BH does scope based quote swapping (quotes are most reliably found by looking for where the string scopes are). The most important functionality is to accurately match brackets/quotes/etc., all else comes secondary and is leveraged off of the matching.

0 Likes

#12

BracketHighlighter will not work proper if you are installing from the new Package Control for ST3. Since Package Control installs it as a sublime-package archive opposed to unpacking it, everything kind of breaks.

Good news is that I think I know how to run the bracket plugins from inside the archive. I will have to unpack the gutter icons though. I will see if Jon will consider loading gutter icons form archives as well.

I will update when I think I have a solution.

0 Likes

#13

BracketHighlighter can now be run from a sublime-package archive. BracketHighlighter now always creates a plugin folder “Theme - BracketHighlighter” where icons will be unpacked to. If BH is not in an archive, icons are still copied to “Theme - BracketHighlighter”.

All bracket plugins should still run okay from inside the archive.

You must be on build 3013 or higher for BH to run on ST3 now.

Please report any bugs you find here.

0 Likes

#14

If you have been using ST3 with the Python3 branch of Package Control and have installed BracketHighlighter via Package Control by adding the ST3 repo for BracketHighlighter. I have resolved one more issue with Windows systems and bracket plugins not loading. BH2 should now run fine from the archive no matter what system you are using.

0 Likes

#15

I downloaded BracketHighlighter-BH2ST3.zip from github and can’t get it to work with ST3. If I put the files in SublimeText\Data\Packages\BracketHighlighter, then I get error in console:

[quote]Traceback (most recent call last):
File “D:\PortableApps\SublimeText\sublime_plugin.py”, line 147, in on_api_ready
m.plugin_loaded()
File “D:\PortableApps\SublimeText\Data\Packages\BracketHighlighter\bh_core.py”, line 1422, in plugin_loaded
init_icons()
File “D:\PortableApps\SublimeText\Data\Packages\BracketHighlighter\bh_core.py”, line 1380, in init_icons
version = sublime.load_resource(“Packages/BracketHighlighter/icons/icon_version.json”)
AttributeError: ‘module’ object has no attribute ‘load_resource’[/quote]

If I put the files in SublimeText\Data\Packages\User\BracketHighlighter, then I get no errors in the console. But then if I go to Preferences > Package Settings > Bracket Settings - Default, I get an empty file because it loads SublimeText\Data\Packages\BracketHighlighter\bh_core.sublime-settings.

So either way it is not fully working. Perhaps this is relevant: Data\Packages\User is a cryptic nested dir structure.

0 Likes

#16

You must be on build 3013 or higher for BH to run on ST3 now. Earlier versions of ST3 do not have access to load_resource API calls.

Dev build containing build 3013 is here: sublimetext.com/3dev

0 Likes

#17

Since last update (i’m not sure if it’s either the ST or BH update!) i can’t see the gutter icons anymore

Theme - BracketHighlighter directory it’s created and sublimeLinter add it’s icons in gutter

(since package control doesn’t work anymore i suspect is something wrong with latest build)

Btw, i’m not sure how this sublime package thing works. Who create the package? How? Where can I download it?

0 Likes

#18

Hang tight. Recent update broke some stuff. I should have a fix soonish.

0 Likes

#19
  • Support icons inside archive with 3014 API
  • Support changes for new add_region features
  • Add highlight styles: thin_underline, squiggly, stippled

ST3 BracketHighlighter 2 now requires 3014 to work. New highlight styles for brackets are listed above. Enjoy.

You can delete the Theme - BracketHighlighter folder now; it is no longer needed thanks to Jons new changes.

0 Likes

#20

Nothing works for me.

Installed the repository/branch for st 3 (github.com/facelessuser/Bracket … ree/BH2ST3) on my machine in the Packages folder.

It appears to be the only brackethighlighter installed (e.g., nothing from ST2 and no package).

Then, went to install it via package control, which was supposed to use the existing repository. ST3 said it was installed.

Close and restart sublime 3 (build 3017).

Nothing.

We better control of this packages thing. Every package developer can’t have their own way to install packages. That’s chaos. If we don’t get back to one way, then not many of the packages will get tested with sublime text 3 and will have few working packages by the time it ships.

0 Likes