Skip to content

Commit

Permalink
Merge pull request #970 from savetheclocktower/comment-delimiter-meta…
Browse files Browse the repository at this point in the history
…data

Add a `TextEditor` method for retrieving comment delimiters…
  • Loading branch information
savetheclocktower authored Apr 10, 2024
2 parents ace4180 + 8145f06 commit f7dbe73
Show file tree
Hide file tree
Showing 39 changed files with 870 additions and 177 deletions.
8 changes: 8 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,14 @@ module.exports = {
asyncArrow: "always",
named: "never"
}],
"no-constant-condition": "off",
"no-unused-vars": [
"warn",
{
varsIgnorePattern: '^_',
argsIgnorePattern: '^_'
}
],
"node/no-missing-require": [
"error",
{
Expand Down
5 changes: 5 additions & 0 deletions packages/language-c/settings/language-c.cson
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
'.source.c, .source.cpp, .source.objc, .source.objcpp':
'editor':
'commentStart': '// '
# Technically, line comments aren't universally valid in C, but all modern
# C compilers support them.
'commentDelimiters':
'block': ['/*', '*/']
'line': '//'
'increaseIndentPattern': '(?x)
^ .* \\{ [^}"\']* $
|^ .* \\( [^\\)"\']* $
Expand Down
2 changes: 2 additions & 0 deletions packages/language-clojure/settings/language-clojure.cson
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
'.source.clojure':
'editor':
'commentStart': '; '
'commentDelimiters':
'line': ';'
'autocomplete':
'extraWordCharacters': '-'
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
'.source.coffee, .source.litcoffee, .source.coffee.md':
'editor':
'commentStart': '# '
'commentDelimiters':
'line': '#'
'.source.coffee':
'editor':
'autoIndentOnPaste': false
Expand Down
3 changes: 3 additions & 0 deletions packages/language-csharp/settings/language-csharp.cson
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
'.source.cs':
'editor':
'commentStart': '// '
'commentDelimiters':
'line': '//'
'block': ['/*', '*/']
'increaseIndentPattern': '(?x)\n\t\t^ .* \\{ [^}"\']* $\n\t| ^ \\s* \\{ \\} $\n\t'
'decreaseIndentPattern': '(?x)\n\t\t^ (.*\\*/)? \\s* \\} ( [^}{"\']* \\{ | \\s* while \\s* \\( .* )? [;\\s]* (//.*|/\\*.*\\*/\\s*)? $\n\t'
2 changes: 2 additions & 0 deletions packages/language-css/settings/language-css.cson
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
'editor':
'commentStart': '/*'
'commentEnd': '*/'
'commentDelimiters':
'block': ['/*', '*/']
'foldEndPattern': '(?<!\\*)\\*\\*/|^\\s*\\}|\\/*\\s*@end\\s*\\*\\/'
'autocomplete':
'extraWordCharacters': '-'
Expand Down
2 changes: 2 additions & 0 deletions packages/language-gfm/settings/gfm.cson
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@
'softWrap': true
'commentStart': '<!-- '
'commentEnd': ' -->'
'commentDelimiters':
'block': ['<!--', '-->']
3 changes: 3 additions & 0 deletions packages/language-go/settings/language-go.cson
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
'.source.go':
'editor':
'commentStart': '// '
'commentDelimiters':
'block': ['/*', '*/']
'line': '//'
'increaseIndentPattern': '^.*(\\bcase\\b.*:|\\bdefault\\b:|(\\b(func|if|else|switch|select|for|struct)\\b.*)?{[^}]*|\\([^)]*)$'
'decreaseIndentPattern': '^\\s*(\\bcase\\b.*:|\\bdefault\\b:|}[),]?|\\)[,]?)$'
'decreaseNextIndentPattern': '^\\s*[^\\s()}]+(?<m>[^()]*\\((?:\\g<m>[^()]*|[^()]*)\\))*[^()]*\\)[,]?$'
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,4 @@ fileTypes: [
comments:
start: '<!-- '
end: ' -->'
block: ['<!--', '-->']
2 changes: 2 additions & 0 deletions packages/language-html/settings/language-html.cson
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
'editor':
'commentStart': '<!-- '
'commentEnd': ' -->'
'commentDelimiters':
'block': ['<!--', '-->']
'foldEndPattern': '(?x)\n\t\t(</(?i:head|body|table|thead|tbody|tfoot|tr|div|select|fieldset|style|script|ul|ol|li|form|dl|section|article|header|footer|nav|aside)>\n\t\t|^(?!.*?<!--).*?--\\s*>\n\t\t|^<!--\\ end\\ tminclude\\ -->$\n\t\t|<\\?(?:php)?.*\\bend(if|for(each)?|while)\\b\n\t\t|\\{\\{?/(if|foreach|capture|literal|foreach|php|section|strip)\n\t\t|^[^{]*\\}\n\t\t|^\\s*\\)[,;]\n\t\t)'
'increaseIndentPattern': '''(?x)
<(?!\\?|(?:area|base|br|col|frame|hr|html|img|input|link|meta|param)\\b|[^>]*/>)
Expand Down
7 changes: 7 additions & 0 deletions packages/language-java/settings/language-java.cson
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
'.source.java':
'editor':
'commentStart': '// '
'commentDelimiters':
'block': ['/*', '*/']
'line': '//'
'foldEndPattern': '^\\s*(\\}|// \\}\\}\\}$)'
'increaseIndentPattern': '^.*\\{(\\}|[^}"\']*)$|^\\s*(public|private|protected):\\s*$'
'decreaseIndentPattern': '^(.*\\*/)?\\s*\\}|^\\s*(public|private|protected):\\s*$'
Expand All @@ -9,6 +12,8 @@
'foldEndPattern': '\\*\\*/|^\\s*\\}'
'commentStart': '<%-- '
'commentEnd': ' --%>'
'commentDelimiters':
'block': ['<%--', '-->']
'increaseIndentPattern': '^\\s*<(([^!/?]|%)(?!.+?([/%]>|</.+?>))|[%!]--\\s*$)'
'decreaseIndentPattern': '^\\s*(</[^>]+>|-->|--%>)'
'.text.junit-test-report':
Expand All @@ -17,6 +22,8 @@
'.source.java-properties':
'editor':
'commentStart': '# '
'commentDelimiters':
'line': '#'
'.keyword.other.documentation.javadoc.java':
'editor':
'completions': [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,5 @@ fileTypes: [

comments:
start: '// '
block: ['/*', '*/']
line: '//'
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
'editor':
'nonWordCharacters': '/\\()"\':,.;<>~!#@%^&*|+=[]{}`?-…'
'commentStart': '// '
'commentDelimiters':
'block': ['/*', '*/']
'line': '//'
'foldEndPattern': '^\\s*\\}|^\\s*\\]|^\\s*\\)'
'increaseIndentPattern': '(?x)
\\{ [^}"\']*(//.*)? $
Expand All @@ -16,8 +19,12 @@
'editor':
'commentStart': '{/*'
'commentEnd': '*/}'
'commentDelimiters':
'block': ['{/*', '*/}']

'.source.js .meta.jsx.inside-tag.js':
'editor':
'commentStart': '{/*'
'commentEnd': '*/}'
'commentDelimiters':
'block': ['{/*', '*/}']
3 changes: 3 additions & 0 deletions packages/language-less/settings/language-less.cson
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
".source.css.less":
editor:
commentStart: "// "
commentDelimiters:
line: '//'
block: ['/*', '*/']
autocomplete:
extraWordCharacters: '-'
symbols:
Expand Down
2 changes: 2 additions & 0 deletions packages/language-make/settings/language-make.cson
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,6 @@
'editor':
'increaseIndentPattern': '^[^\\t ]+:'
'commentStart': '# '
'commentDelimiters':
'line': '#'
'tabType': 'hard'
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
'NSMutableString'
'NSString'
]
# Comment settings are specified in the `language-c` package.
'.source.objcpp, .source.objc':
'editor':
'foldEndPattern': '(?<!\\*)\\*\\*/|^\\s*\\}|^@end\\b'
4 changes: 4 additions & 0 deletions packages/language-perl/settings/language-perl.cson
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,15 @@
'increaseIndentPattern': '^.*\\{\\}?\\s*$'
'decreaseIndentPattern': '^\\s*\\}'
'commentStart': '# '
'commentDelimiters':
'line': '#'
'nonWordCharacters': '/\\()"\':,.;<>~!#^&*|+=[]{}`?-'
'.source.perl6':
'editor':
'foldEndPattern': '(\\*/|^\\s*(\\}|\\]|\\)))'
'increaseIndentPattern': '^.*\\{\\}?\\s*$'
'decreaseIndentPattern': '^\\s*\\}'
'commentStart': '# '
'commentDelimiters':
'line': '#'
'nonWordCharacters': '/\\()"\':,.;<>~!#^&*|+=[]{}`?-'
3 changes: 3 additions & 0 deletions packages/language-php/settings/language-php.cson
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
'.source.php':
'editor':
'commentStart': '// '
'commentDelimiters':
'line': '//'
'block': ['/*', '*/']
'completions': [
'APCIterator'
'AppendIterator'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
'.source.plist':
'editor':
'commentStart': '// '
'commentDelimiters':
'line': '//'
'foldEndPattern': '^\\s*(\\}|\\))'
'increaseIndentPattern': '^\\s*(([a-zA-Z_-]+|"[^"]+"|\'[^\']+\')\\s+=\\s+)?[{(](?!.*[)}][;,]?\\s*$)'
'decreaseIndentPattern': '^\\s*(\\}|\\))'
2 changes: 2 additions & 0 deletions packages/language-python/settings/language-python.cson
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
'softTabs': true
'tabLength': 4
'commentStart': '# '
'commentDelimiters':
'line': '#'
'foldEndPattern': '^\\s*[}\\])]'
'increaseIndentPattern': '^\\s*(class|def|elif|else|except|finally|for|if|try|with|while|async\\s+(def|for|with))\\b.*:\\s*$'
'decreaseIndentPattern': '^\\s*(elif|else|except|finally)\\b.*:\\s*$'
2 changes: 2 additions & 0 deletions packages/language-ruby/settings/language-ruby.cson
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
'.source.ruby':
'editor':
'commentStart': '# '
'commentDelimiters':
'line': '#'
'increaseIndentPattern': '(?x)^\n (\\s*\n (module|class|(private\\s+)?def\n |unless|if|else|elsif\n |case|when\n |begin|rescue|ensure\n |for|while|until\n |(?= .*? \\b(do|begin|case|if|unless)\\b )\n # the look-ahead above is to quickly discard non-candidates\n ( "(\\\\.|[^\\\\"])*+" # eat a double quoted string\n | \'(\\\\.|[^\\\\\'])*+\' # eat a single quoted string\n | [^#"\'] # eat all but comments and strings\n )*\n ( \\s (do|begin|case)\n | [-+=&|*/~%^<>~](?<!\\$.) \\s*+ (if|unless)\n )\n )\\b\n (?! [^;]*+ ; .*? \\bend\\b )\n |( "(\\\\.|[^\\\\"])*+" # eat a double quoted string\n | \'(\\\\.|[^\\\\\'])*+\' # eat a single quoted string\n | [^#"\'] # eat all but comments and strings\n )*\n (\\( (?! [^\\)]*+ \\) )\n | \\{ (?! [^}]*+ \\} )\n | \\[ (?! [^\\]]*+ \\] )\n )\n ).*$'
'decreaseIndentPattern': '^\\s*([}\\]\\)](,?\\s*(#|$)|\\.[a-zA-Z_]\\w*\\b)|(end|rescue|ensure|else|elsif|when)\\b)'
'.text.html.erb':
Expand Down
3 changes: 3 additions & 0 deletions packages/language-rust-bundled/settings/rust.cson
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
'.source.rust':
'editor':
'commentStart': '// '
'commentDelimiters':
'line': '//'
'block': ['/*', '*/']
'increaseIndentPattern': '(?x)
^ .* \\{ [^}"\']* $
|^ .* \\( [^\\)"\']* $
Expand Down
3 changes: 3 additions & 0 deletions packages/language-sass/settings/language-sass.cson
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@
'editor':
'nonWordCharacters': '/\\()"\':,.;<>~!#%^&*|+=[]{}`?…'
'commentStart': '// '
'commentDelimiters':
'line': '//'
'block': ['/*', '*/']
'autocomplete':
'symbols':
'mixin':
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
'.source.shell':
'editor':
'commentStart': '# '
'commentDelimiters':
'line': '#'
'foldEndPattern': '^\\s*(\\}|(done|fi|esac)\\b)'
'increaseIndentPattern': '^\\s*(else|case)\\b|^.*(\\{|\\b(then|do)\\b)$'
'decreaseIndentPattern': '^\\s*(\\}|(elif|else|fi|esac|done)\\b)'
2 changes: 2 additions & 0 deletions packages/language-sql/settings/language-sql.cson
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
'.source.sql':
'editor':
'commentStart': '-- '
'commentDelimiters':
'line': '--'
'foldEndPattern': '^\\s*\\)'
'increaseIndentPattern': '^\\s*(create|grant|insert|delete|update)\\b|\\((?!.*\\))'
'decreaseIndentPattern': '^\\s*\\)(?!=.*\\()'
2 changes: 2 additions & 0 deletions packages/language-toml/settings/language-toml.cson
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'.source.toml':
'editor':
'commentStart': '# '
'commentDelimiters':
'line': '#'
3 changes: 3 additions & 0 deletions packages/language-typescript/settings/TypeScript.cson
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
'.source.ts':
'editor':
'commentStart': '// '
'commentDelimiters':
'line': '//'
'block': ['/*', '*/']
'foldEndPattern': '^\\s*\\}|^\\s*\\]|^\\s*\\)'
'increaseIndentPattern': '(?x)
\\{ [^}"\']* $
Expand Down
5 changes: 5 additions & 0 deletions packages/language-typescript/settings/TypeScriptReact.cson
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
'.source.tsx':
'editor':
'commentStart': '// '
'commentDelimiters':
'line': '//'
'block': ['/*', '*/']
'foldEndPattern': '^\\s*\\}|^\\s*\\]|^\\s*\\)'
'increaseIndentPattern': '(?x)
\\{ [^}"\']* $
Expand All @@ -15,6 +18,8 @@
'editor':
'commentStart': '{/* ',
'commentEnd': ' */}',
'commentDelimiters':
'block': ['{/*', '*/}']
'increaseIndentPattern': "{[^}\"']*$|\\[[^\\]\"']*$|\\([^)\"']*$|<[a-zA-Z][^/]*$|^\\s*>$",
'decreaseIndentPattern': "^\\s*(\\s*/[*].*[*]/\\s*)*[}\\])]|^\\s*(</|/>)"

Expand Down
2 changes: 2 additions & 0 deletions packages/language-xml/settings/language-xml.cson
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
'editor':
'commentStart': '<!-- '
'commentEnd': ' -->'
'commentDelimiters':
'block': ['<!--', '-->']
'foldEndPattern': '^\\s*(</[^>]+>|[/%]>|-->)\\s*$'
'increaseIndentPattern': '^\\s*<(([^!/?]|%)(?!.+?([/%]>|</.+?>))|[%!]--\\s*$)'
'decreaseIndentPattern': '^\\s*(</[^>]+>|-->|--%>)'
2 changes: 2 additions & 0 deletions packages/language-yaml/settings/language-yaml.cson
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
'editor':
'autoIndentOnPaste': false
'commentStart': '# '
'commentDelimiters':
'line': '#'
'foldEndPattern': '^\\s*$|^\\s*\\}|^\\s*\\]|^\\s*\\)'
'increaseIndentPattern': '^\\s*.*(:|-) ?(&\\w+)?(\\{[^}"\']*|\\([^)"\']*)?$'
'decreaseIndentPattern': '^\\s+\\}$'
Expand Down
Loading

0 comments on commit f7dbe73

Please sign in to comment.