Alhadis / language-regexp

For those who're serious about writing regular expressions.
https://atom.io/packages/language-regexp
ISC License
6 stars 2 forks source link

Is it possible to recognise regex in bash conditional contexts? #5

Closed beingmrkenny closed 4 years ago

beingmrkenny commented 4 years ago

For example:

if [[ "$firstLine" =~ ^\[[A-Za-z]+-[0-9]+\][[:space:]]+(.*) ]]; then
    blurb=${BASH_REMATCH[1]};
fi

Currently the regex there isn't highlighted.

Alhadis commented 4 years ago

No, it's not (entirely) possible. Under normal circumstances, it would be; however, Atom now uses this annoying hybrid system where two partly-incompatible parsers are used to highlight source-code. Without going into specifics, there's a feature that both systems have that normally enables me to inject highlighting into unrelated grammars (that is, targeting files that aren't using the Regular Expression or Regular Expression (Extended) grammars). Since Atom introduced its new parsing system, however, that's no longer been an option.

I've added an injection for this, but you'll only see it if you disable Tree Sitter parsers:

Figure 1
(Under SettingsCore → Scroll to the bottom → Uncheck Use Tree Sitter Parsers)

😞 I apologise for the long-winded explanation, but there was no simple "yes/no" answer I could give that was completely accurate/honest.

EDIT: I should add that you may have to disable grammar-selector.hideDuplicateTextMateGrammars in order to select “legacy” grammars in the grammar selector:

Figure 2
(Found under SettingsPackages → Search for grammar-selectorSettings button)

beingmrkenny commented 4 years ago

Hey thanks for the detailed explanation! Can't tell you how many times the railroad diagram has found an error that would otherwise go unnoticed, so thanks :)