Sublime Forum

Integrating a plugin with Bracket Highlighter

#1

Hi,

Does anyone have any experience of integrating with the awesome BracketHighlighter plugin or know of any packages that do so?

There are two things I want to achieve:

  1. I have created a package that contains a language syntax for RichTextFormat (rtf), in which only curly braces have any importance. I would like to ship something with my package that will ensure that BracketHighlighter doesn’t get confused when normal parenthesis are used in such a way that they don’t line up with the braces, for example, here you can see the ? shows that BH doesn’t understand what should match with what:

  2. The other thing I want to achieve is for the xpath plugin. It works by parsing the open document with an XML parser and storing the location of all the tags. I was wondering if there was a way to get BH to use this information, to save it from having to duplicate the work (with it’s regular expressions), and at the same time, overcome the “max distance between tags” that it highlights, so that even for large files, it will show the opening and closing tags without any performance penalty.

I have seen the documentation about customizing the way the bracket matching works and it seems that I could create a plugin for BH, but I’d really like to see some examples of it in use, or for someone to help me work out what I need to do. I am worried that the way I choose to do it will be more complicated than is really necessary… How would BH/Sublime/Python know to read my package’s files to see if there is a plugin for BH amongst them?

Thanks for your time,
Keith

0 Likes

#2

I guess that one solution to my number 1 above would be to update the user’s BH preferences file when my plugin gets installed, but I don’t really think that is ideal :wink:

0 Likes

#3

No, you shouldn’t update settings like that. You should most likely make a pull request on BH’s repo to add support.

0 Likes

#4

Thanks, that makes sense - I have since read http://facelessuser.github.io/BracketHighlighter/contributing/ and at least have an idea how to get started now :slightly_smiling:

It looks like ‘Definition Plugins’ will help me with number 1, I just need to create a plugin in the bh_modules folder and reference it from bh_core.sublime-settings in the brackets section.

I will work on this for now and come back to number 2 when I have a bit more experience with BH :slightly_smiling:

0 Likes

#5

As I am not entirely sure of all the details of what you are trying to do, I can’t yet say, but one thing that strikes me is that you will have to disable round and square brackets for your syntax if all you want is curly. That can be done without a bh_plugin; you just need to exclude your syntax source from those rules. As for curly, it may be that you need to exclude the default curly and just create a special curly rule for your current syntax that only executes on your curly scopes.

Again, I am not 100% sure what your requirements are, and I may have interpreted them wrong, but anyway, if you have any questions, just create an issue on the repo and I can answer your questions.

0 Likes