Is there a configuration option to highlight angle bracket pairs?


#1

I would like to get angle brackets to be treated the same as parens/brackets/braces with regards to highlighting the matching open/close counterpart of a pair. This is a crucial convenience for the language that I am writing. In sublime text the configuration command key is “match_brackets_angle”.

Is there a similar configuration option in atom? If not, would it be possible to achieve this with a package? I’m willing to go down a medium-sized rabbit hole to get this working, if somebody could point me in the right direction.

Thanks!


#2

The bracket matching functionality is provided by the Bracket Matcher package. If you want angle brackets added to the list, this is where you would need to look.


#3

thanks; at first i thought that bracket-matcher was a third party package.

i have forked bracket-matcher and made some preliminary changes; what is the most sensible workflow for loading my fork into atom and testing it?


#4

You should:

  1. Clone your fork to your machine wherever you normally put your projects
  2. Change into that directory
  3. Execute apm install to install any dependencies of the package
  4. Execute apm link --dev to link that package into ~/.atom/dev/packages
  5. Launch Atom with the development version of the package loaded by executing atom --dev

I don’t normally recommend cloning directly into a directory under ~/.atom/dev/packages because if you end up working on multiple packages it’s much easier to do apm unlink --all and then link the one you want to work on at the moment.


#5

thanks for the tips, they were extremely helpful.

i was able to add a new setting, ‘bracket-matcher.matchAngleBrackets’. here is the patch: https://github.com/gwk/bracket-matcher/commit/0891ce5a94b2423027aa66f6227bddef2bccd62e

however i don’t think this is generally useful unless it can be enabled on a per-language basis. i see https://atom.io/packages/syntax-settings, but it doesn’t seem appropriate for an option in bracket-matcher to depend on a third-party package. has there been any more progress on the per-language/per-project configuration question?

also, i wonder how much more needs to be done to make this patch into an acceptable pull request. aside from tests, documentation, etc, do i need to add similar logic to bracket-matcher.coffee to make this palatable?


#6

My general thoughts on pull requests is to submit it as a pull request even if it isn’t ready to be merged so that you can get feedback from the repo owner or other people interested in the project. You can always close it if you get feedback that says you’re going down the wrong path. Coders communicate best in code after all.

As far as what the “best” solution is … personally, I feel that the set of “brackets” to be matched should be governed by the grammar that is in effect in a given editor. The default set can be used if none are specified in the grammar for backwards compatibility. There is already precedent for this in the grammar specifications. For example, see commentStart, increaseIndentPattern and decreaseIndentPattern here in the Ruby grammar:

https://github.com/atom/language-ruby/blob/master/scoped-properties/language-ruby.cson#L5

But that might be a bit bigger change than you’re prepared to put the effort into :smile:


#7

This might do what you want.
atom-like-brackets-editor