-
-
Notifications
You must be signed in to change notification settings - Fork 245
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow specification of arbitrary brackets #12
Comments
They are related in a way, but probably not enough algorithmically to fit in with the current implementation. There would be special considerations to take into account if this were implemented. I would need to allow for lists for each kind of syntax: ruby, c/c++, etc. to allow searching only for related blocks only in that language. We would want to limit the searching to the current syntax to limit the strain on the algorithm; the more searching that is allowed, the longer it would take. It is surely possible, but I fear that trying to squeeze it into the current BracketHighlighter frame work might be difficult to do well without bloating it. With that said, there is nothing saying I couldn't just write a specific plugin to do exactly this; I have often wanted such functionality in languages. Though I feel this is probably out of scope for this plugin, I will leave the issue open until I have some time to evaluate if I would like to try and squeeze this into this plugin, write a separate plugin, or pass altogether (this would be most likely if someone gets to it before me; I don't yet know when I would undertake this). |
Thanks for explaining your thoughts regarding this issue. After thinking about it a bit more, I also agree that it's most likely out of scope for the current plugin. Thanks again! |
I came to the repo looking for something similar. I use Markdown a lot and would like a way of including asterisks and underscores. Trouble with this is that the opening and closing tokens are the same, so I'm guessing that makes it harder to implement. |
Meh. Not necessarily more difficult to implement. I am highlighting quotes which are identical. In cases like this, using the underlying scope of the syntax highlighter can help. I am still on the fence about this though because the algorithm is streamlined to find very specific things fairly quickly. Implementing a bunch of different matches could bog things down if they are not restricted to certain file types. If I were to do something like this, I would also need to come up with a more generalized way to handle such things or the code could become a huge mess in a hurry. As mentioned earlier, this request is more than likely out of scope of bracket highlighter which really is mainly geared towards brackets and bracket related things (HTML tags leverage the angle bracket matching). Strings were also added so I could search for brackets within strings/regex. I haven't really sat down yet to fully think about this yet; I have been pretty busy with other stuff. I will update this issue when I have made a decision. |
I wonder, would it be easy enough for somebody to modify the package locally for something like this? I have a strange syntax to work with where lists start with a ` and end with a ' . Would I be able to replace something like angle-brackets, which I don't use, with these for my own use? Also, would this matching be likely to interfere with a single-quoted string match? Thanks so much! |
@askeeve you wouldn't need to replace angle. Since the starting character and ending character are different, you could probably easily add just another rule. Also, angle is needed for tag matching. in BracketHighlighter.py you could add a bracket type called
After that, you would just need to add all the settings in the settings file. So if there was a setting called You can replace the Brackets that have the opening the same as the closing are much different and require special handling. If one day I generalize the quote matching enough, I may be able to allow for simple addition of single character same brackets. Then I could just expose a setting allowing for defining bracket rules. Multi-character opening and closing brackets is much more difficult in the current algorithm and would require me shuffling a lot around. |
That seems to work fantastically! Thank you so much. One small issue (and On Mon, Jul 9, 2012 at 12:35 PM, Isaac Muse <
-Adam |
Tough to say without me playing with it. If you can fork BracketHighlighter and add your changes and maybe post an example file with your special syntax, I can play with it when I have time and maybe give you an answer/possible fix. Nothing comes to mind off the top of my head that would cause this; so I would have to play with it. |
Fair enough, I'll play around with it a little more and see about doing that if I can't figure it out. Thanks! |
@ryanlecompte This is in very, very early stages. I have been tinkering with it only for a little, and it has quite a bit until it can catch up feature wise. But if it goes well, something like this may appear in BH2. As originally requested...highlighting of ruby if|while|do etc. The method of detecting brackets is much different allowing me to grab multi char brackets (obviously using brackets loosely here). I haven't worked out how I will expose this functionality to the user, but I am hoping to abstract it enough to essentially allow for modules to be dropped in for whatever language quirks a user would like to add...we shall see though. @charlesroper I imagine there would be two kinds of bracket styles a user could define. One where end caps are specified, and one where the scope is the base...like strings is done, and how markdown bold, underline would be done. If you guys still have interest in this feature, when I get it more fleshed out (and if it doesn't to turn to crap on me), I may need some testers. |
Awesome work!!!!! On Oct 1, 2012, at 8:34 PM, Isaac Muse notifications@github.com wrote:
|
Sweet. Definitely interested in this. Also been doing some rst lately so it Thanks for doing into this - very much appreciated. |
@charlesroper Completely generalized. This is done simply by an entry in the settings file: {
"open": "(\\*|_)",
"close": "(\\*|_)",
"highlight_subgroup": [1, 1],
"name": "mditalic",
"color": "bracket.curly",
"language_filter": "whitelist",
"language_list": ["Markdown"],
"scopes": ["markup.italic"],
"style": "underline",
"icon": "dot",
"enabled": true
},
{
"open": "(\\*\\*|__)",
"close": "(\\*\\*|__)",
"highlight_subgroup": [1, 1],
"name": "mdbold",
"color": "keyword",
"language_filter": "whitelist",
"language_list": ["Markdown"],
"scopes": ["markup.bold"],
"style": "underline",
"icon": "dot",
"enabled": true
} Things are still subject to change, but right now I am thinking it might look something like that for people to create their own scope based brackets. Traditional brackets will be slightly different. Still working towards a testable alpha, but I am very pleased in the progress made so far. |
That, frankly, is music to my eyes. Nice one indeed, and sincere thanks. |
New algorithm seems to be faster as well. In retrospect this makes sense, but initially I though the inverse would be true. So this is looking like a win win re-write. This means thresholds can be extended further without slowing things down. |
I am thinking sometime next week I will have a testable branch. |
An early Alpha branch is up at https://github.com/facelessuser/BracketHighlighter/tree/BH2 I still need to add the bracket swapping and bracket removing plugin. There is no documentation right now so...you are on your own right now :). Feel free to ask questions, make suggestions, report bugs, and do let me know how it is performing for you. |
A couple of fixes since the initial Alpha post.
Make sure to restart ST2 after updating to this branch. |
Just wanted to let you know I'm chronically busy at the moment and won't have a chance to have a look-see for another week or so. Didn't want you to think I was unappreciative - on the contrary, I'm really looking forward to digging in. 😃 |
No worries, I've had a couple people over on the forums trying it out and giving some feedback. It helped getting feedback about ruby; I think ruby support is much better now. Also got some feedback on styling brackets and I am going to play around with that in the next number of days. Just let me know what you think whenever you get a chance. |
If you were using the alpha before now, I changed some important stuff in the settings file during the last commit that will require reconfiguring your personal settings again, but that should be last non-backwards compatible change hopefully. Also, shortcuts related to tags probably need to be reconfigured if you used those as well. See Example.sublime-keymap for examples. |
The official release of BracketHighlighter 2 is coming very soon. All planned features are in. I simply need to write up the documentation, and if there are no critical bugs, I will release it. Hopefully it will have a positive reception. I believe it should be capable of handling most everyone's bracket desires now. Now would probably be the time for anyone to file last minute issues or suggestions. |
BracketHighlighter 2 is now on the master branch. This issue is now solved. |
Thank you for your work on this Isaac, it's very much appreciated. Kudos.
|
I'm a Ruby developer and would love to be able to have "def" and "end" tags highlighted for method definitions to help see them aligned properly. Things like this:
if ...
end
def foo
end
while ...
end
until ..
end
Would this be possible with this plugin or is it out of scope?
Thanks!
The text was updated successfully, but these errors were encountered: