GithubHelp home page GithubHelp logo

bracket-matcher's Introduction

Atom and all repositories under Atom will be archived on December 15, 2022. Learn more in our official announcement

Bracket Matcher package

CI

Highlights and jumps between [], (), and {}. Also highlights matching XML and HTML tags.

Autocompletes [], (), {}, "", '', “”, ‘’, «», ‹›, and backticks by default.

Use ctrl-m to jump to the bracket matching the one adjacent to the cursor. It jumps to the nearest enclosing bracket when there's no adjacent bracket,

Use ctrl-cmd-m to select all the text inside the current brackets.

Use alt-cmd-. to close the current XML/HTML tag.


Configuration

Matching brackets and quotes are sensibly inserted for you. If you dislike this functionality, you can disable it from the Bracket Matcher section of the Settings View.

Custom Pairs

You can customize matching pairs in Bracket Matcher at any time. You can do so either globally via the Settings View or at the scope level via your config.cson. Changes take effect immediately.

  • Autocomplete Characters - Comma-separated pairs that the editor will treat as brackets / quotes. Entries in this field override the package defaults.

    • For example: <>, (), []
  • Pairs With Extra Newline - Comma-separated pairs that enhance the editor's auto indent feature. When used, a newline is automatically added between the pair when enter is pressed between them. Note: This feature is meant to be used in combination with brackets defined for indentation by the active language package (increaseIndentPattern / decreaseIndentPattern). Example:

fn main() {
    | <---- Cursor positioned at one indent level higher
}

Scoped settings

In addition to the global settings, you are also able to add scope-specific modifications to Atom in your config.cson. This is especially useful for editor rule changes specific to each language. Scope-specific settings override package defaults and global settings. Example:

".rust.source":
  "bracket-matcher":
    autocompleteCharacters: [
      "()"
      "[]"
      "{}"
      "<>"
      "\"\""
      "``"
    ]

bracket-matcher's People

Contributors

50wliu avatar as-cii avatar baldurh avatar ben3eee avatar benogle avatar binarymuse avatar boborbt avatar damieng avatar dmohs avatar fstiewitz avatar izuzak avatar jasonrudolph avatar kevinnathan avatar kevinsawicki avatar kuychaco avatar lee-dohm avatar maxbrunsfeld avatar mnquintana avatar moritzkn avatar mutle avatar nlbuescher avatar pcasaretto avatar potto007 avatar reujab avatar sadick254 avatar seattlevine avatar sirbrillig avatar smashwilson avatar teoric avatar zcbenz avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

bracket-matcher's Issues

`go-to-matching-bracket` behaves inconsistently for HTML

Thanks for the fixes for #60 and #61 @kevinsawicki 😄

I was testing it out and I noticed something else.

In that gif, I'm pressing ctrl-m each time I advance by a character. You can see that sometimes I'm able to jump to the matching tag, sometimes it doesn't work, and sometimes it jumps to the matching tag but in a strange position inside the tag name.

Sync edits between open and closing tags in HTML

Since bracket matcher is already finding and underlining the closing tag, it might make sense for it to actually sync up edits to the tag name. For example, if have <span>Some <span>text</span></span> and change the opening tag of the outermost element to div, the closing tag should change too.

Invalid Positioning after Resizing Text

If you zoom in or out the position of the bracket highlight doesn't update. The line stays where it was even though the bracket moves.

Before zoom (aligned):
screen shot 2014-02-28 at 1 13 24 pm

After zoom (misaligned):
screen shot 2014-02-28 at 1 13 39 pm

Python support

Similar to issue #6 regarding Ruby, but with Python indented blocks.

Add option to disable selection wraping

I very much dislike how bracket-matcher wraps selections in quotes/brackets when an opening quote/bracket is typed, but I love matching brace highlighting. I think it would be very useful to simply add an option to disable quote and bracket wrapping of selections, similar to how autocompleteBrackets works.

Also, there is no documentation that says bracket-matcher is the plugin responsible for wrapping selections in quotes. It took me forever to track this down!

context-aware bracket wrapping

It would be awesome if the bracket wrapping knew about where I was at the moment and was was acceptable. I super, super want to be in a double-quoted string in a language like Ruby, have something selected, hit # and see it wrapped correctly, like so:

  1. I'm in some code like var = "@something-name"
  2. I select @something
  3. I hit #
  4. I get var = "#{@something}-name"

Wrong Keybindings on Linux

Hi!

I'm using Atom atom -v 0.97.0-22b932e on Ubuntu 14.04 amd64.

On Linux Atom has the same shortcuts for Go To Matching Bracket and Select Inside Brackets.
When I'm hitting Ctrl+M Atom is always doing Go To Matching Bracket.

brackets

Highlighting feature request

First of all, thanks a lot for this really useful package. While using it for some time now, I've noticed that it would be nice to not only see a underline marking the matching bracket, but a "block hightlight", surrounding the whole bracket in a maybe yellowish color would be more noticeable.

Would it be possible to add some kind of switch in the package setings to switch between these two display types? Thanks again!

Select to matched bracket

Ctrl-M places the cursor to a bracket according to some rule. Ctrl-Shift-M should smartly† select from the current cursor position to the new one.

† This is very useful for indenting blocks, changing function arguments, modifying array/dict/hash indices or content... so best judgement must be used to set the selection properly. E.g calling it twice in a row from anywhere inside a bracketed array or parens should select whatever the inside of the brackets is. Calling it a third time could grow the selection to include the brackets.

Inspiration: vim's ci[/di[/ca[/da[

Always highlight parents brackets

I think it would be cool if the brackets wouldn't only be visible if my cursor is next to the bracket.

But rather more like this:

    var f = function (i) {    // ← highlighted bracket
        |                     // ← cursor
        if (i) {              
        }                     
    }                         // ← highlighted bracket
    var f = function (i) { 
        if (i) {              // ← highlighted bracket
            |                 // ← cursor
        }                     // ← highlighted bracket
    } 

Configure colour of underlining

Thanks for this great package. I noticed that the colour of the underline (lime) is hardcoded into the package css file. Do you think the colour should be defined by the syntax theme instead?

Bracket Matcher does not skip over brackets in snippets

It seems that the bracket-matcher stops keeping track of closing brackets in some situations, and does't skip them when ) is typed and the cursor is already at a closing bracket ).

For example, when expanding snippets:

baz

Also, after typing outside the bracket range, and coming back:

baz2

cc @Krajsnick (thanks for the report!)

TypeError: Cannot call method 'isEmpty' of undefined

From atom/atom#3180

After pressing Ctrl-+ I got the following error:

TypeError: Cannot call method 'isEmpty' of undefined
at BracketMatcherView.module.exports.BracketMatcherView.updateMatch (/usr/local/google/home/skainswo/Atom/resources/app/node_modules/bracket-matcher/lib/bracket-matcher-view.js:160:39)
at /usr/local/google/home/skainswo/Atom/resources/app/node_modules/bracket-matcher/lib/bracket-matcher-view.js:63:24
at /usr/local/google/home/skainswo/Atom/resources/app/src/config.js:220:20
at /usr/local/google/home/skainswo/Atom/resources/app/node_modules/emissary/lib/emitter.js:133:30
at Array.forEach (native)
at Config.module.exports.Emitter.emit (/usr/local/google/home/skainswo/Atom/resources/app/node_modules/emissary/lib/emitter.js:132:47)
at Config.module.exports.Config.loadUserConfig (/usr/local/google/home/skainswo/Atom/resources/app/src/config.js:80:21)
at PathWatcher. (/usr/local/google/home/skainswo/Atom/resources/app/src/config.js:93:26)
at HandleWatcher. (/usr/local/google/home/skainswo/Atom/resources/app/node_modules/pathwatcher/lib/main.js:132:26)
at HandleWatcher.EventEmitter.emit (events.js:112:17)
at HandleWatcher.onEvent (/usr/local/google/home/skainswo/Atom/resources/app/node_modules/pathwatcher/lib/main.js:60:23)
at /usr/local/google/home/skainswo/Atom/resources/app/node_modules/pathwatcher/lib/main.js:20:41
/usr/local/google/home/skainswo/Atom/resources/app/src/config.js:85
module.exports.Config.loadUserConfig

Preceded by 2 other errors:

Uncaught TypeError: Cannot call method 'isEmpty' of undefined /usr/local/google/home/skainswo/Atom/resources/app/node_modules/bracket-matcher/lib/bracket-matcher…:160
module.exports.BracketMatcherView.updateMatch /usr/local/google/home/skainswo/Atom/resources/app/node_modules/bracket-matcher/lib/bracket-matcher…:160
(anonymous function) /usr/local/google/home/skainswo/Atom/resources/app/node_modules/bracket-matcher/lib/bracket-matcher…:63
(anonymous function) /usr/local/google/home/skainswo/Atom/resources/app/src/config.js:220
(anonymous function) /usr/local/google/home/skainswo/Atom/resources/app/node_modules/emissary/lib/emitter.js:133
module.exports.Emitter.emit /usr/local/google/home/skainswo/Atom/resources/app/node_modules/emissary/lib/emitter.js:132
module.exports.Config.update /usr/local/google/home/skainswo/Atom/resources/app/src/config.js:243
module.exports.Config.set /usr/local/google/home/skainswo/Atom/resources/app/src/config.js:155
module.exports.Workspace.increaseFontSize /usr/local/google/home/skainswo/Atom/resources/app/src/workspace.js:348
_results.push._this.(anonymous function) /usr/local/google/home/skainswo/Atom/resources/app/node_modules/delegato/lib/delegator.js:67
(anonymous function) /usr/local/google/home/skainswo/Atom/resources/app/src/workspace-view.js:234
jQuery.event.dispatch /usr/local/google/home/skainswo/Atom/resources/app/node_modules/space-pen/vendor/jquery.js:4676
elemData.handle /usr/local/google/home/skainswo/Atom/resources/app/node_modules/space-pen/vendor/jquery.js:4360
module.exports.KeymapManager.dispatchCommandEvent /usr/local/google/home/skainswo/Atom/resources/app/node_modules/atom-keymap/lib/keymap-manager.js:400
module.exports.KeymapManager.handleKeyboardEvent /usr/local/google/home/skainswo/Atom/resources/app/node_modules/atom-keymap/lib/keymap-manager.js:181
(anonymous function) /usr/local/google/home/skainswo/Atom/resources/app/src/window-event-handler.js:90
jQuery.event.dispatch /usr/local/google/home/skainswo/Atom/resources/app/node_modules/space-pen/vendor/jquery.js:4676
elemData.handle /usr/local/google/home/skainswo/Atom/resources/app/node_modules/space-pen/vendor/jquery.js:4360
Failed to load user config '/usr/local/google/home/skainswo/.atom/config.cson' Cannot call method 'isEmpty' of undefined /usr/local/google/home/skainswo/Atom/resources/app/src/config.js:84
module.exports.Config.loadUserConfig /usr/local/google/home/skainswo/Atom/resources/app/src/config.js:84
(anonymous function) /usr/local/google/home/skainswo/Atom/resources/app/src/config.js:93
(anonymous function) /usr/local/google/home/skainswo/Atom/resources/app/node_modules/pathwatcher/lib/main.js:132
EventEmitter.emit events.js:112
HandleWatcher.onEvent /usr/local/google/home/skainswo/Atom/resources/app/node_modules/pathwatcher/lib/main.js:60
(anonymous function) /usr/local/google/home/skainswo/Atom/resources/app/node_modules/pathwatcher/lib/main.js:20

Add support for ruby

Add support for rubys "brackets" like

def foo(ary)
  ary.each do |i|
    # ...
  end
end

If I'm inside the inner block it should highlight the regarding do and end. Outside of that block it should highlight the def and end.

Bracket matcher doesn't match html tags

I ❤️ this feature, but it doesn't seem to work for html tags. Since html can get so terribly noisy, I often find myself wishing this worked. I fill my markup with things like <!-- /.my-tag -> but that gets ugly after a while.

Can't write symbol ">"

When I try to write the symbol ">" using Ctrl-Alt-. it closes the tag without writing the symbol, like this:

<div class="container"</div>

Will auto indent even if "auto indent" is turned off

Even if the global setting "auto indent" is turned off, it will still auto indent in some cases.

How to reproduce:

Select the file type as CoffeeScript, then type:

a = {}

Then move the cursor to between "{" and "}". Then press enter.

It will not auto indent only if bracket matcher is disabled. So I think it may be a bug of bracket matcher.

Multi column select doesn't wrap

If i have a multi column selection going on. And hit a bracket, it replaces with what you typed instead of surrounding with the bracket.

Expose (or document) some API

It's not really an issue, more a request for hints.

I'd like to use bracket matcher functionality in my package. Speciffically I'd like to get text inside brackets around cursor.

I've seen specs, and that I can use something like:

EditorView.trigger "bracket-matcher:select-inside-brackets"
text = Editor.getSelectedText()

This however doesn't seem to be a very elegant approach. First of all I wouldn't like to mess with cursor position and selections. I'd rather get a Range, and then read text from it.

So, is there any good way to do that?

I'd be happy to write some docs, once I get my head around this.

Faulty Brackets match wrong

 allow(Redis).to receive(:get).with("APPSdownload_DESC_android").and_return(
      [{name: "Puzzle", category_id: "puzzle_ios", download: 6},
       {name: "Adventure", category_id: "Adventure_ios", download: 5},
       {name: "Entertainment", category_id: "Entertainment_ios", download: 1}]))

The last bracket has no corresponding bracket, but is matched to the first in the block.

Maches wrong also when the bracket is commented out.

Folded Code Misaligns "Match" Underlines

Atom underlines matching brackets and HTML tags with a bright green dotted line. I like that.

But if there is a code block folded somewhere on the page, matched bracket underlines below it don't align properly, ending up a little too high and overwriting the text.

And it gets worse with more folded code.

This example has two folded blocks. Now the underlines are more like strikethroughs! And the cursor has ended up off line, too. It's the white vertical stroke above the d in the last <div.

screen2

This happens with the default editor, not React.

Problems with Lazily-Composed keyboard layouts

(e.g. US International – PC)

Atom correctly handles composed characters in the general case by subscribing to the composition(start|update|end) events emitted by the DOM. However, the event being subscribed to by the autopairing code in this plugin seems to be firing just after the compositionstartevent (and well before any textInputevent). I suspect that this plugin should firing based on textInput rather than insertText, since we're actually interested in pairing a quotation mark once it falls out of the "compose" state.

(As an aside, the _.adviseBefore method used here doesn't seem to be used anywhere else. This might be an opportunity to push an 'insertText:before' onto the EditorView.)

Related discussion: http://discuss.atom.io/t/trouble-inserting-quotation-marks/249

Bracket Matcher, move through existing parentheses

When there is an existing set of opening and closing parentheses like so:
tell_someone_that(empty($var))

and the cursor is just after $var, Atom knows the following closing parenthesis matches the third opening parenthesis (the one of the 'empty' call), it also knows the second closing parenthesis matches the one of the 'tell_someone_that'-call.

One of Netbeans' most wonderful features to date, in my opinion, is that when my cursor is right after $var and I type a closing parenthesis, it just moves the cursor one position to the right, when I type another closing parenthesis the cursor moves one position to the right again.. This is continued like so, as long as the closing parenthesis match an existing opening parenthesis, otherwise a closing parenthesis is inserted at the position of the cursor.

In Atom though, a new closing parenthesis is always inserted at the cursor's position.

It would be a great feature if the cursor would move just one position per closing parenthesis entered as long as it matches an opening one.

schermafbeelding 2014-06-30 om 17 10 07

Mac OS X 10.8.5
Atom Version 0.106.0 (0.106.0)

Copy of: atom/atom#2774

Clashes with Auto-indent

bad_brace_behavior

Auto-indent only works when line ends in open curly-brane, which is checked before the event mutates the text. At that time, the pesky close brace is in the way.

Qt Creator, for example, does not automatically add curly braces. Instead, it appears to check for a carrier return pressed right after an open curly brace and, in that case, it adds the matching close brace at the right place. That seems like a saner piece of behavior.

(I first filed this under general Atom feedback, but now I think this might be better off done here. Sorry for the noise.)

Fails in atom 0.123.0

This plugin no longer works, and atom gives:

Bracket Matcher 0.54.0
Listed below are the incompatible native modules that this package depends on.

[email protected]
Error message: Module did not self-register.

Document quote functionality.

I searched my Atom plugins to determine what was automatically completing single- and double-quoted strings (to hopefully disable it: decades of muscle memory doesn't allow me to use the feature effectively.)

The plugin description mentions (), {} and [], but not the quote characters. I went through the source of the most likely candidate and found bracket-matcher. It'd be nice if the blurb mentioned that it has this functionality.

The description also leads me to believe that bracket-matcher's sole responsibility is highlighting/moving between bracket pairs, instead of also completing bracket pairs.

I'd submit a PR, but I'm confident the maintainers could word this more accurately and succinctly than I.

Thanks.

add support for `backticks`

If we could treat backticks the same way that we treat quotes, that would be great (especially when editing markdown where they are used for inline code).

Highlight the background between brackets?

I don't know how easy or difficult this would be, but instead of underlining the bracket I'd like to highlight/change the background color between brackets. Would this be possible?

should ignore strings, regex and comments

var a = 2 * ("abc(".length + 1);

This is a valid statement, but the ending ")" incorrectly matches the "(" in "abc(".

I think Bracket Matcher should ignore characters in strings, regex and comments, like Sublime Text 2.

Bracket removal

Hey,

TM2 has a useful feature that allows removing any kind of bracket from a selection.
For example, if I have the text ("some string") and I activate the command twice I end up with some string.
By default it is mapped to ].
Do you think this would fit nicely here? I'd be happy to take a shot at it and send a PR.

Auto-pairing for asterisk

I think it would be cool if the core of Atom itself supports auto-pairing for asterisk for selected text, just like the one we have right now with brackets.

asterisk2

As for asterisk, the wrapped text is completely replaced with 1 asterisk.

asterisk

smart quotes: allow turning off / non-English quotes

I love automatic closing of parentheses; thanks for this package!

However, in multilingual text, the smart quote feature can be a nuisance rather than help: e.g., the English opening quotation mark is the German closing quotation mark; Polish uses the same opening quotation mark as German, but different closing; etc.

It would be nice if (a) if the smart quote feature could be disabled, and potentially (b) the set of quotes were configurable. Configurability of smart quotes will be quite difficult to implement well, especially for writing multilingual documents.

Add class to brackets for styling

One of the coolest features of atom is being able to customize things using stylesheets. However, it seems you can't style matching brackets because bracket-matcher only inserts DOM into the under layer. I'd like to be able to style matching brackets, for example:

.matching-bracket {
  text-shadow: 2px 2px #ff0000;
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.