Skip to content

Commit

Permalink
Merge pull request sublimehq#8 from deathaxe/add_gitconfig_pkg
Browse files Browse the repository at this point in the history
Git Config: add fixes for embedded multiline shell scripts and indention rules
  • Loading branch information
Ryan Boehning authored Feb 8, 2018
2 parents 7c10705 + 065536f commit c2fee71
Show file tree
Hide file tree
Showing 3 changed files with 128 additions and 4 deletions.
16 changes: 16 additions & 0 deletions Config/Indentation Rules.tmPreferences
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<plist version="1.0">
<dict>
<key>name</key>
<string>Indentation Rules</string>
<key>scope</key>
<string>text.git.config</string>
<key>settings</key>
<dict>
<key>decreaseIndentPattern</key>
<string><![CDATA[^\s*\[.*$]]></string>
<key>increaseIndentPattern</key>
<string><![CDATA[^\s*\[.*$]]></string>
</dict>
</dict>
</plist>
4 changes: 2 additions & 2 deletions Git Files/Git Config.sublime-syntax
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ contexts:
captures:
1: string.quoted.double.git.config punctuation.definition.string.begin.git.config
2: keyword.control.import.shell.git.config
escape: \"(?=[^"]*(?:[#;]|$))
escape: (?<!\\)\"(?=\s*(?:#.*)?$)
escape_captures:
0: meta.mapping.value.git.config string.quoted.double.git.config punctuation.definition.string.end.git.config
embed: scope:source.shell
Expand Down Expand Up @@ -210,7 +210,7 @@ contexts:
pop: true

line-end:
- match: $
- match: $\n?
pop: true

expect-line-end:
Expand Down
112 changes: 110 additions & 2 deletions Git Files/syntax_test_git_config
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ stray-bracket]
# ^ keyword.operator.assignment
# ^ keyword.control.import.shell
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ source.shell
serve = "!git daemon --reuseaddr --verbose --base-path=. --export-all ./.git" # git "comment"
serve = "!git daemon --reuseaddr --verbose --base-path=. --export-all ./.git"
# <- meta.mapping
#^^ meta.mapping
# ^^^^^ meta.mapping.key
Expand All @@ -399,9 +399,117 @@ stray-bracket]
| xargs -0n1 git blame -w -C # shell comment
#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.mapping.value source.shell
impact = "!git ls-files -z \
| xargs -0n1 git blame -w -C" ; git "comment"
| xargs -0n1 git blame -w -C" # git "comment"
#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.mapping.value
#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ source.shell
# ^^^^^^^^^^^^^^^^^ - source.shell
# ^ punctuation.definition.comment
# ^^^^^^^^^^^^^^^ comment.line
# check shell script quotation handling
single_quote = "!echo 'This is fine';"
# ^^^^^^^^^^^^ meta.mapping.key
# ^^^ meta.mapping - meta.mapping.key - meta.mapping.value
# ^^^^^^^^^^^^^^^^^^^^^^^ meta.mapping.value
# ^ - meta.mapping
# ^^^^^^^^^^^^ variable.other.readwrite
# ^ keyword.operator.assignment
# ^ string.quoted.double punctuation.definition.string.begin
# ^ keyword.control.import.shell
# ^ - source.shell
# ^^^^^^^^^^^^^^^^^^^^ source.shell
# ^ - source.shell
# ^ string.quoted.double punctuation.definition.string.end
double_quote = "!echo "This is fine";"
# ^^^^^^^^^^^^ meta.mapping.key
# ^^^ meta.mapping - meta.mapping.key - meta.mapping.value
# ^^^^^^^^^^^^^^^^^^^^^^^ meta.mapping.value
# ^ - meta.mapping
# ^^^^^^^^^^^^ variable.other.readwrite
# ^ keyword.operator.assignment
# ^ string.quoted.double punctuation.definition.string.begin
# ^ keyword.control.import.shell
# ^ - source.shell
# ^^^^^^^^^^^^^^^^^^^^ source.shell
# ^ - source.shell
# ^ string.quoted.double punctuation.definition.string.end
# check unescaped double quotes within shell script followed by comment with double-quotes
double_quote = "!echo "This is fine";" # with quoted "comment"
# ^^^^^^^^^^^^ meta.mapping.key
# ^^^ meta.mapping - meta.mapping.key - meta.mapping.value
# ^^^^^^^^^^^^^^^^^^^^^^^ meta.mapping.value
# ^^^^^^^^^^^^ variable.other.readwrite
# ^ keyword.operator.assignment
# ^ string.quoted.double punctuation.definition.string.begin
# ^ keyword.control.import.shell
# ^ - source.shell
# ^^^^^^^^^^^^^^^^^^^^ source.shell
# ^ - source.shell
# ^ string.quoted.double punctuation.definition.string.end
# ^ punctuation.definition.comment
# ^^^^^^^^^^^^^^^^^^^^^^^ comment.line.git
# check escaped double quotes within shell script
double_quote = "!echo \"This is fine\";"
# ^^^^^^^^^^^^ meta.mapping.key
# ^^^ meta.mapping - meta.mapping.key - meta.mapping.value
# ^^^^^^^^^^^^^^^^^^^^^^^^^ meta.mapping.value
# ^^^^^^^^^^^^ variable.other.readwrite
# ^ keyword.operator.assignment
# ^ string.quoted.double punctuation.definition.string.begin
# ^ keyword.control.import.shell
# ^ - source.shell
# ^^^^^^^^^^^^^^^^^^^^^^ source.shell
# ^ - source.shell
# ^ string.quoted.double punctuation.definition.string.end
# check escaped double quotes within shell script followed by comment with double-quotes
double_quote = "!echo \"This is fine.\";" # with quoted "comment"
# ^^^^^^^^^^^^ meta.mapping.key
# ^^^ meta.mapping - meta.mapping.key - meta.mapping.value
# ^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.mapping.value
# ^^^^^^^^^^^^ variable.other.readwrite
# ^ keyword.operator.assignment
# ^ string.quoted.double punctuation.definition.string.begin
# ^ keyword.control.import.shell
# ^ - source.shell
# ^^^^^^^^^^^^^^^^^^^^^^^ source.shell
# ^ - source.shell
# ^ string.quoted.double punctuation.definition.string.end
# ^ punctuation.definition.comment
# ^^^^^^^^^^^^^^^^^^^^^^^ comment.line.git
double_quote = "!echo \"This is fine.\";
# ^^^^^^^^^^^^ meta.mapping.key
# ^^^ meta.mapping - meta.mapping.key - meta.mapping.value
# ^^^^^^^^^^^^^^^^^^^^^^^^^ meta.mapping.value
# ^^^^^^^^^^^^ variable.other.readwrite
# ^ keyword.operator.assignment
# ^ string.quoted.double punctuation.definition.string.begin
# ^ keyword.control.import.shell
# ^ - source.shell
# ^^^^^^^^^^^^^^^^^^^^^^^ source.shell
echo \"This is fine.\";" # with quoted "comment"
# <- meta.mapping.value
#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.mapping.value
# <- source.shell
#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ source.shell
# ^ - source.shell
# ^ string.quoted.double punctuation.definition.string.end
# ^ punctuation.definition.comment
# ^^^^^^^^^^^^^^^^^^^^^^^ comment.line.git
double_quote = "!echo "This is fine." ;
# ^^^^^^^^^^^^ meta.mapping.key
# ^^^ meta.mapping - meta.mapping.key - meta.mapping.value
# ^^^^^^^^^^^^^^^^^^^^^^^^ meta.mapping.value
# ^^^^^^^^^^^^ variable.other.readwrite
# ^ keyword.operator.assignment
# ^ string.quoted.double punctuation.definition.string.begin
# ^ keyword.control.import.shell
# ^ - source.shell
# ^^^^^^^^^^^^^^^^^^^^^^ source.shell
echo "This is fine.";" # with quoted "comment"
# <- meta.mapping.value
#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.mapping.value
# <- source.shell
#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ source.shell
# ^ - source.shell
# ^ string.quoted.double punctuation.definition.string.end
# ^ punctuation.definition.comment
# ^^^^^^^^^^^^^^^^^^^^^^^ comment.line.git

0 comments on commit c2fee71

Please sign in to comment.