mirror of
https://github.com/kennethreitz-archive/kJS.tmbundle.git
synced 2026-06-05 23:50:19 +00:00
MUCH simpler and more bulletproof regex for indent and folding with tests
This commit is contained in:
@@ -11,19 +11,19 @@
|
||||
<string>jsx</string>
|
||||
</array>
|
||||
<key>foldingStartMarker</key>
|
||||
<string>(?x)^ \s* (?!//|/\*)([^\s].*)?
|
||||
# Open (nothing |( string | no parens/string )++ | (no parens? (nested parens ) no parens?)+ )
|
||||
( \[ (?: |( (?<str> (?<!\\)'(\\'|[^'])*+' | (?<!\\)"(\\"|[^"])*+" | (?<!\\)/(\\/|[^/])*+/) | (?<noS>[^\[\]'"/]++) )++ | (\g<noS>? (?<squar> \[ (?: \g<str> | \g<noS> | \g<squar> )* \] ) \g<noS>? )++ )
|
||||
| \( (?: |( \g<str> | (?<noR>[^\(\)'"/]++) )++ | (\g<noR>? (?<round> \( (?: \g<str> | \g<noR> | \g<round> )* \) ) \g<noR>? )++ )
|
||||
| \{ (?: |( \g<str> | (?<noC>[^\{\}'"/]++) )++ | (\g<noC>? (?<curly> \{ (?: \g<str> | \g<noC> | \g<curly> )* \} ) \g<noC>? )++ )
|
||||
<string>(?x)^
|
||||
# Yes *+ Open ( Blank |Comments | (No Paren | String) | String | (Nested Parens ) )*+
|
||||
(?> \g<yesS>*+ \[ (?<yesS> (?!.) |//.*+|/\*((?!\*/).)++(\*/|$)|(^)((?!/\*).)*(\*/)| (?<noS>[^\[\]'"/]) | (?<str> '(\\'|[^'])*+' | "(\\"|[^"])*+" | /(\\/|[^/])*+/) | (?<squar> \[ \g<yesS>*+ \] ) )*+
|
||||
| \g<yesR>*+ \( (?<yesR> (?!.) |//.*+|/\*((?!\*/).)++(\*/|$)|(^)((?!/\*).)*(\*/)| (?<noR>[^\(\)'"/]) | \g<str> | (?<round> \( \g<yesR>*+ \) ) )*+
|
||||
| \g<yesC>*+ \{ (?<yesC> (?!.) |//.*+|/\*((?!\*/).)++(\*/|$)|(^)((?!/\*).)*(\*/)| (?<noC>[^\{\}'"/]) | \g<str> | (?<curly> \{ \g<yesC>*+ \} ) )*+
|
||||
)$</string>
|
||||
<key>foldingStopMarker</key>
|
||||
<string>(?x)^ \s* (?!//|/\*)
|
||||
# (nothing |( string | no parens/string )++ | (no parens? (nested parens ) no parens?)+ ) Close
|
||||
( (?: |( (?<str> (?<!\\)'(\\'|[^'])*+' | (?<!\\)"(\\"|[^"])*+" | (?<!\\)/(\\/|[^/])*+/) | (?<noS>[^\[\]'"/]++) )++ | (\g<noS>? (?<squar> \[ (?: \g<str> | \g<noS> | \g<squar> )* \] ) \g<noS>? )++ ) \]
|
||||
| (?: |( \g<str> | (?<noR>[^\(\)'"/]++) )++ | (\g<noR>? (?<round> \( (?: \g<str> | \g<noR> | \g<round> )* \) ) \g<noR>? )++ ) \)
|
||||
| (?: |( \g<str> | (?<noC>[^\{\}'"/]++) )++ | (\g<noC>? (?<curly> \{ (?: \g<str> | \g<noC> | \g<curly> )* \} ) \g<noC>? )++ ) \}
|
||||
)</string>
|
||||
<string>(?x)^
|
||||
# ( Blank |Comments | (No Paren | String) | String | (Nested Parens ) )*+ Close Yes *+
|
||||
(?> (?<yesS> (?!.) |//.*+|/\*((?!\*/).)++(\*/|$)|(^)((?!/\*).)*(\*/)| (?<noS>[^\[\]'"/]) | (?<str> '(\\'|[^'])*+' | "(\\"|[^"])*+" | /(\\/|[^/])*+/) | (?<squar> \[ \g<yesS>*+ \] ) )*+ \] \g<yesS>*+
|
||||
| (?<yesR> (?!.) |//.*+|/\*((?!\*/).)++(\*/|$)|(^)((?!/\*).)*(\*/)| (?<noR>[^\(\)'"/]) | \g<str> | (?<round> \( \g<yesR>*+ \) ) )*+ \) \g<yesR>*+
|
||||
| (?<yesC> (?!.) |//.*+|/\*((?!\*/).)++(\*/|$)|(^)((?!/\*).)*(\*/)| (?<noC>[^\{\}'"/]) | \g<str> | (?<curly> \{ \g<yesC>*+ \} ) )*+ \} \g<yesC>*+
|
||||
)$</string>
|
||||
<key>keyEquivalent</key>
|
||||
<string>^~J</string>
|
||||
<key>name</key>
|
||||
|
||||
Reference in New Issue
Block a user