mirror of
https://github.com/kennethreitz-archive/kJS.tmbundle.git
synced 2026-06-05 23:50:19 +00:00
NEW Advanced Folding and Indent patterns!
Added switch…case tests
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>name</key>
|
||||
<string>Indent</string>
|
||||
<key>scope</key>
|
||||
<string>source.js</string>
|
||||
<key>settings</key>
|
||||
<dict>
|
||||
<key>decreaseIndentPattern</key>
|
||||
<string>(?x)^ \s* (?!//|/\*)
|
||||
# (nothing | ( string | no parens )+ | (no parens? (nested parens ) no parens?)+ ) Close
|
||||
( (?: | ( (?<str> '(\\'|[^'])*+' | "(\\"|[^"])*+" | /(\\/|[^/])*+/) | (?<noR>[^\[\]'"/]++) )++ | (\g<noR>? (?<round> \[ (?: \g<str> | \g<noR> | \g<round> )* \] ) \g<noR>? )++ ) \]
|
||||
| (?: | ( \g<str> | (?<noS>[^\(\)'"/]++) )++ | (\g<noS>? (?<squar> \( (?: \g<str> | \g<noS> | \g<squar> )* \) ) \g<noS>? )++ ) \)
|
||||
| (?: | ( \g<str> | (?<noC>[^\{\}'"/]++) )++ | (\g<noC>? (?<curly> \{ (?: \g<str> | \g<noC> | \g<curly> )* \} ) \g<noC>? )++ ) \}
|
||||
| \b(?:case|default)\b .*$# [^;]*$
|
||||
)</string>
|
||||
<key>increaseIndentPattern</key>
|
||||
<string>(?x)^ \s* (?!//|/\*)([^\s].*)?
|
||||
# Open (nothing | ( string | no parens )+ | (no parens? (nested parens ) no parens?)+ )
|
||||
( \[ (?: | ( (?<str> '(\\'|[^'])*+' | "(\\"|[^"])*+" | /(\\/|[^/])*+/) | (?<noR>[^\[\]'"/]++) )++ | (\g<noR>? (?<round> \[ (?: \g<str> | \g<noR> | \g<round> )* \] ) \g<noR>? )++ )
|
||||
| \( (?: | ( \g<str> | (?<noS>[^\(\)'"/]++) )++ | (\g<noS>? (?<squar> \( (?: \g<str> | \g<noS> | \g<squar> )* \) ) \g<noS>? )++ )
|
||||
| \{ (?: | ( \g<str> | (?<noC>[^\{\}'"/]++) )++ | (\g<noC>? (?<curly> \{ (?: \g<str> | \g<noC> | \g<curly> )* \} ) \g<noC>? )++ )
|
||||
| \b(?:case|default)\b .*# [^;]*
|
||||
)$</string>
|
||||
<key>indentNextLinePattern</key>
|
||||
<string>^\s*((if|while|for|switch|else if).*[)]|else)\s*$</string>
|
||||
<key>unIndentedLinePattern</key>
|
||||
<string>^\s*((/\*|\*/\s*$|\ \*).*)?$</string>
|
||||
</dict>
|
||||
<key>uuid</key>
|
||||
<string>BC062860-3346-4D3B-8421-C5543F83D11F</string>
|
||||
</dict>
|
||||
</plist>
|
||||
@@ -1,21 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>name</key>
|
||||
<string>JavaScript Indent</string>
|
||||
<key>scope</key>
|
||||
<string>source.js</string>
|
||||
<key>settings</key>
|
||||
<dict>
|
||||
<key>decreaseIndentPattern</key>
|
||||
<string>^((.*\*/)?\s*(\}|\))([^{]*\{)?([;,]?\s*|\.[^{]*|\s*\)[;\s]*)$|\s*[}]while.*$)</string>
|
||||
<key>increaseIndentPattern</key>
|
||||
<string>^(\/(?!\/)|[^\/])*((\{[^}"']*|\([^)"']*)|\=\s*)$</string>
|
||||
<key>indentNextLinePattern</key>
|
||||
<string>^\s*((if|while|for|switch|else if).*[)]|else)\s*$</string>
|
||||
</dict>
|
||||
<key>uuid</key>
|
||||
<string>BC062860-3346-4D3B-8421-C5543F83D11F</string>
|
||||
</dict>
|
||||
</plist>
|
||||
@@ -11,18 +11,18 @@
|
||||
<string>jsx</string>
|
||||
</array>
|
||||
<key>foldingStartMarker</key>
|
||||
<string>(?x)^ \s* ([^\s].*)?
|
||||
# Open (nothing | no parens | (no parens? (nested parens ) no parens?)+ )
|
||||
( \[ (?: | (?<noR>[^\[\]]++) | (\g<noR>? (?<round> \[ (?: \g<noR> | \g<round> )* \] ) \g<noR>? )++ )
|
||||
| \( (?: | (?<noS>[^\(\)]++) | (\g<noS>? (?<squar> \( (?: \g<noS> | \g<squar> )* \) ) \g<noS>? )++ )
|
||||
| \{ (?: | (?<noC>[^\{\}]++) | (\g<noC>? (?<curly> \{ (?: \g<noC> | \g<curly> )* \} ) \g<noC>? )++ )
|
||||
<string>(?x)^ \s* (?!//|/\*)([^\s].*)?
|
||||
# Open (nothing | ( string | no parens )+ | (no parens? (nested parens ) no parens?)+ )
|
||||
( \[ (?: | ( (?<str> '(\\'|[^'])*+' | "(\\"|[^"])*+" | /(\\/|[^/])*+/) | (?<noR>[^\[\]'"/]++) )++ | (\g<noR>? (?<round> \[ (?: \g<str> | \g<noR> | \g<round> )* \] ) \g<noR>? )++ )
|
||||
| \( (?: | ( \g<str> | (?<noS>[^\(\)'"/]++) )++ | (\g<noS>? (?<squar> \( (?: \g<str> | \g<noS> | \g<squar> )* \) ) \g<noS>? )++ )
|
||||
| \{ (?: | ( \g<str> | (?<noC>[^\{\}'"/]++) )++ | (\g<noC>? (?<curly> \{ (?: \g<str> | \g<noC> | \g<curly> )* \} ) \g<noC>? )++ )
|
||||
)$</string>
|
||||
<key>foldingStopMarker</key>
|
||||
<string>(?x)^ \s*
|
||||
# (nothing | no parens | (no parens? (nested parens ) no parens?)+ ) Close
|
||||
( (?: | (?<noR>[^\[\]]++) | (\g<noR>? (?<round> \[ (?: \g<noR> | \g<round> )* \] ) \g<noR>? )++ ) \]
|
||||
| (?: | (?<noS>[^\(\)]++) | (\g<noS>? (?<squar> \( (?: \g<noS> | \g<squar> )* \) ) \g<noS>? )++ ) \)
|
||||
| (?: | (?<noC>[^\{\}]++) | (\g<noC>? (?<curly> \{ (?: \g<noC> | \g<curly> )* \} ) \g<noC>? )++ ) \}
|
||||
<string>(?x)^ \s* (?!//|/\*)
|
||||
# (nothing | ( string | no parens )+ | (no parens? (nested parens ) no parens?)+ ) Close
|
||||
( (?: | ( (?<str> '(\\'|[^'])*+' | "(\\"|[^"])*+" | /(\\/|[^/])*+/) | (?<noR>[^\[\]'"/]++) )++ | (\g<noR>? (?<round> \[ (?: \g<str> | \g<noR> | \g<round> )* \] ) \g<noR>? )++ ) \]
|
||||
| (?: | ( \g<str> | (?<noS>[^\(\)'"/]++) )++ | (\g<noS>? (?<squar> \( (?: \g<str> | \g<noS> | \g<squar> )* \) ) \g<noS>? )++ ) \)
|
||||
| (?: | ( \g<str> | (?<noC>[^\{\}'"/]++) )++ | (\g<noC>? (?<curly> \{ (?: \g<str> | \g<noC> | \g<curly> )* \} ) \g<noC>? )++ ) \}
|
||||
)</string>
|
||||
<key>keyEquivalent</key>
|
||||
<string>^~J</string>
|
||||
|
||||
@@ -26,6 +26,7 @@ Documentation Comment (idiom)
|
||||
* officia deserunt mollit anim id est laborum.
|
||||
*/
|
||||
|
||||
|
||||
// nothing
|
||||
|
||||
[1,2,3]
|
||||
@@ -325,35 +326,45 @@ function(){ function(){ statement }; function(){ statement };
|
||||
myFunction()
|
||||
|
||||
myFunction(
|
||||
// Fold; Indent
|
||||
);myFunction
|
||||
|
||||
myFunction((0)
|
||||
// Fold; Indent
|
||||
);myFunction
|
||||
|
||||
myFunction(something()
|
||||
// Fold; Indent
|
||||
)
|
||||
|
||||
myFunction(()something
|
||||
// Fold; Indent
|
||||
)
|
||||
|
||||
myFunction((something)
|
||||
// Fold; Indent
|
||||
)
|
||||
|
||||
myFunction(something(something)something
|
||||
// Fold; Indent
|
||||
something(something)something)
|
||||
|
||||
|
||||
|
||||
myFunction(something()()
|
||||
// Fold; Indent
|
||||
)
|
||||
|
||||
myFunction(()something()
|
||||
// Fold; Indent
|
||||
)
|
||||
|
||||
myFunction((something)()
|
||||
// Fold; Indent
|
||||
)
|
||||
|
||||
myFunction(()something()(something)()something()
|
||||
// Fold; Indent
|
||||
)
|
||||
|
||||
|
||||
@@ -362,6 +373,22 @@ myFunction(()something()(something)()something()
|
||||
// = Special =
|
||||
// ===========
|
||||
switch (statement){
|
||||
case 'label':
|
||||
statement;
|
||||
break;
|
||||
case 'label':
|
||||
statement;
|
||||
break;
|
||||
case 'label':
|
||||
statement;
|
||||
break;
|
||||
default:
|
||||
statement;
|
||||
}
|
||||
|
||||
function(){
|
||||
|
||||
switch (statement){
|
||||
case 'label':
|
||||
statement;
|
||||
break;
|
||||
@@ -373,8 +400,20 @@ switch (statement){
|
||||
break;
|
||||
default:
|
||||
statement;
|
||||
}
|
||||
|
||||
switch (statement){
|
||||
case 'label': statement; break;
|
||||
case 'label': statement; break;
|
||||
case 'label': statement; break;
|
||||
default: statement;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// No fold
|
||||
if (statement) statement;
|
||||
|
||||
@@ -382,13 +421,26 @@ if (statement)
|
||||
statement;
|
||||
|
||||
if (statement){
|
||||
statement;}
|
||||
statement;}
|
||||
|
||||
// Fold
|
||||
if (statement){
|
||||
statement;
|
||||
}
|
||||
|
||||
if ()
|
||||
statement;
|
||||
else if ()
|
||||
statement;
|
||||
else
|
||||
statement;
|
||||
while ()
|
||||
statement;
|
||||
for ()
|
||||
statement;
|
||||
switch ()
|
||||
statement;
|
||||
|
||||
|
||||
// ===========
|
||||
// = Strings =
|
||||
@@ -396,75 +448,75 @@ if (statement){
|
||||
|
||||
// No Fold; No Indent
|
||||
myFunction(")"
|
||||
// Fold; Indent
|
||||
statement; // Fold; Indent
|
||||
"(")
|
||||
// No Fold; No Indent
|
||||
myArray = ["]",
|
||||
// Fold; Indent
|
||||
statement; // Fold; Indent
|
||||
"["]
|
||||
// No Fold; No Indent
|
||||
function(){"}"
|
||||
// Fold; Indent
|
||||
statement; // Fold; Indent
|
||||
"{"}
|
||||
// No Fold; No Indent
|
||||
myFunction("\")"
|
||||
// Fold; Indent
|
||||
statement; // Fold; Indent
|
||||
"\"(")
|
||||
// No Fold; No Indent
|
||||
myArray = ["\"]",
|
||||
// Fold; Indent
|
||||
statement; // Fold; Indent
|
||||
"\"["]
|
||||
// No Fold; No Indent
|
||||
function(){"\"}"
|
||||
// Fold; Indent
|
||||
statement; // Fold; Indent
|
||||
"\"{"}
|
||||
// No Fold; No Indent
|
||||
myFunction(')'
|
||||
// Fold; Indent
|
||||
statement; // Fold; Indent
|
||||
'(')
|
||||
// No Fold; No Indent
|
||||
myArray = [']',
|
||||
// Fold; Indent
|
||||
statement; // Fold; Indent
|
||||
'[']
|
||||
// No Fold; No Indent
|
||||
function(){'}'
|
||||
// Fold; Indent
|
||||
statement; // Fold; Indent
|
||||
'{'}
|
||||
// No Fold; No Indent
|
||||
myFunction('\')'
|
||||
// Fold; Indent
|
||||
statement; // Fold; Indent
|
||||
'\'(')
|
||||
// No Fold; No Indent
|
||||
myArray = ['\']',
|
||||
// Fold; Indent
|
||||
statement; // Fold; Indent
|
||||
'\'[']
|
||||
// No Fold; No Indent
|
||||
function(){'\'}'
|
||||
// Fold; Indent
|
||||
statement; // Fold; Indent
|
||||
'\'{'}
|
||||
// No Fold; No Indent
|
||||
myFunction(/)/
|
||||
// Fold; Indent
|
||||
statement; // Fold; Indent
|
||||
/(/)
|
||||
// No Fold; No Indent
|
||||
myArray = [/]/,
|
||||
// Fold; Indent
|
||||
statement; // Fold; Indent
|
||||
/[/]
|
||||
// No Fold; No Indent
|
||||
function(){/}/
|
||||
// Fold; Indent
|
||||
statement; // Fold; Indent
|
||||
/{/}
|
||||
// No Fold; No Indent
|
||||
myFunction(/\/)/
|
||||
// Fold; Indent
|
||||
statement; // Fold; Indent
|
||||
/\/(/)
|
||||
// No Fold; No Indent
|
||||
myArray = [/\/]/,
|
||||
// Fold; Indent
|
||||
statement; // Fold; Indent
|
||||
/\/[/]
|
||||
// No Fold; No Indent
|
||||
function(){/\/}/
|
||||
// Fold; Indent
|
||||
statement; // Fold; Indent
|
||||
/\/{/}
|
||||
|
||||
// No Fold; No Indent
|
||||
@@ -506,3 +558,36 @@ myFunction('\' ) ')
|
||||
myFunction(/ \) /)
|
||||
myFunction(/\/\) /)
|
||||
|
||||
|
||||
// ============
|
||||
// = Comments =
|
||||
// ============
|
||||
|
||||
// myFunction(
|
||||
// No Fold; No Indent
|
||||
// )
|
||||
// myArray = [
|
||||
// No Fold; No Indent
|
||||
// ]
|
||||
// function(){
|
||||
// No Fold; No Indent
|
||||
// }
|
||||
|
||||
|
||||
function(){
|
||||
some_function();
|
||||
|
||||
/* ignore_first();
|
||||
ignore_second();
|
||||
*/
|
||||
|
||||
more_functions();
|
||||
}
|
||||
|
||||
|
||||
""
|
||||
''
|
||||
()
|
||||
[]
|
||||
{}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user