Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Git Files] Add Git Files package #1126

Merged
merged 106 commits into from
Mar 20, 2018
Merged
Show file tree
Hide file tree
Changes from 32 commits
Commits
Show all changes
106 commits
Select commit Hold shift + click to select a range
b44fe8f
Add git package
ryboe Aug 27, 2017
d802d3a
[Git] Commit: rename source.gitcommit to source.git.commit
deathaxe Sep 16, 2017
9ad0f06
[Git] Commit: Sort blocks by top-down
deathaxe Sep 17, 2017
ea2ac5a
[Git] Commit: Refactor commit message
deathaxe Sep 17, 2017
f257c68
[Git] Commit: Refactor changed files list
deathaxe Sep 17, 2017
43e11f3
[Git] Commit: Refactor branch-line
deathaxe Sep 17, 2017
d97a1ab
[Git] Commit: Refactor date line
deathaxe Sep 17, 2017
9404e60
[Git] Commit: Add scopes for username and issue references
deathaxe Sep 17, 2017
d01adf5
[Git] Commit: scope email addresses
deathaxe Sep 17, 2017
2a119a9
[Git] Link: Add syntax for .git files
deathaxe Sep 17, 2017
f938bd1
[Git] Link: rename syntax file to achieve unique names
deathaxe Sep 17, 2017
ec509be
[Git] Commit: rename syntax file to achieve unique names
deathaxe Sep 17, 2017
16cf43b
[Git] Commit: fix syntax_test file headers
deathaxe Sep 18, 2017
bff54a5
[Git] Rebase: Rename .gitrebase top-level scope to .git.rebase
deathaxe Sep 18, 2017
9dc50fb
[Git] Rebase: Add illegal syntax check to commit command lines
deathaxe Sep 18, 2017
98116c9
[Git] Rebase: Update rebase message to highlight commands
deathaxe Sep 18, 2017
3863bf2
[Git] Rebase: Resort rebase code to put associated blocks together
deathaxe Sep 18, 2017
27363ca
[Git] Rebase: Scope some rebase comment lines as headlines
deathaxe Sep 18, 2017
1e6d44d
[Git] Rebase: Match comments at line start only
deathaxe Sep 18, 2017
13897a1
[Git] Rebase: rename syntax file to achieve unique names
deathaxe Sep 18, 2017
2ecbf9e
[Git] Rebase: Add issue/user/email reference highlighting
deathaxe Sep 18, 2017
4752d69
[Git] Commit: Add support for git translations
deathaxe Sep 19, 2017
28d8bb2
Add git package
ryboe Aug 27, 2017
a69b86d
Refactor [section] contexts
ryboe Sep 16, 2017
cacce71
[Git] Commit: Fix syntax tests to match translations
deathaxe Sep 19, 2017
4d7b60e
[Git] Commit: Rename source.git.commit to text.git.commit
deathaxe Sep 19, 2017
92763c4
[Git] Rebase: Rename source.git.rebase to text.git.rebase
deathaxe Sep 19, 2017
52343d1
[Git] Link: Rename source.git.link to text.git.link
deathaxe Sep 19, 2017
f35380e
[Git] Commit: Remove text.plain.message scope
deathaxe Sep 20, 2017
9596e7c
Refactor and simplify commit syntax
ryboe Sep 20, 2017
86efdd6
[Git] Config: Sort sections from top-to down
deathaxe Sep 21, 2017
940d1bf
[Git] Config: Merge some unique atomic sections with their parents
deathaxe Sep 21, 2017
c4d6758
[Git] Config: Disallow any string after section header
deathaxe Sep 21, 2017
16fb208
[Git] Config: Reduce pattern repetitions
deathaxe Sep 21, 2017
a8be2f0
[Git] Config: Simplify constant patterns
deathaxe Sep 21, 2017
0f5fd79
[Git] Commit: Add support for squashed commit messages.
deathaxe Sep 22, 2017
9b22879
Refactor and simplify commit syntax
ryboe Sep 20, 2017
9c6f12a
[Git] Commit: Rename syntax definition file
deathaxe Sep 23, 2017
f952391
[Git] Link: Rename git link.sublime-syntax to gitlink.sublime-syntax
deathaxe Sep 23, 2017
99da69a
[Git] Rebase: rename git rebase.sublime-syntax to gitrebase.sublime-s…
deathaxe Sep 23, 2017
937c7de
[Git] Commit: Add general purpose headline
deathaxe Sep 23, 2017
d4d952d
[Git] Commit: Merge squash into commit syntax tests
deathaxe Sep 23, 2017
83f303b
[Git] Commit: Highlight recent commands in rebase commits
deathaxe Sep 23, 2017
3cc7a7b
Merge branch 'pr/git-commit' into add_gitconfig_pkg
deathaxe Sep 23, 2017
161b6a7
[Git] Rebase: Extend syntax name
deathaxe Sep 23, 2017
437c532
[Git] Rebase: Simplify scopes of command help
deathaxe Sep 24, 2017
dda56a0
[Git] Commit: Update reference scope names
deathaxe Sep 24, 2017
ec25ba2
[Git] Commit: Remove path from SYNTAX TEST header
deathaxe Sep 24, 2017
918e1de
[Git] Commit: Add Signed-off-by keyword and fix email-reference
deathaxe Sep 24, 2017
01320be
[Git] Commit: Use entity.name.reference for references
deathaxe Sep 24, 2017
ce37d63
[Git] Commit: Less strict empty 2nd line checks
deathaxe Sep 24, 2017
a4d64f3
[Git] Commit: Improve re-usability
deathaxe Sep 24, 2017
09c90ce
[Git] Commit: Support git diff
deathaxe Sep 24, 2017
d068d7d
Merge pull request #2 from deathaxe/pr/git-commit
Sep 25, 2017
4195122
[Git] Rebase: Reduce comment stack push/pops
deathaxe Sep 25, 2017
d1d2dd7
[Git] Rebase: Prepare for common reference scopes
deathaxe Sep 25, 2017
bf92620
[Git] Rebase: Use meta.subject to identify commit subject
deathaxe Sep 25, 2017
cbfbe7e
[Git] Rebase: Remove path from SYNTAX TEST header
deathaxe Sep 25, 2017
cc7df2f
Merge branch 'pr/git-rebase' into add_gitconfig_pkg
deathaxe Sep 25, 2017
c6a2a70
Merge pull request #1 from deathaxe/pr/git
Sep 30, 2017
b901cc8
[Git] Config: Highlight invalid escapes in section names
deathaxe Oct 1, 2017
a81f4e3
[Git] Rename git config base scope
deathaxe Sep 26, 2017
25b3658
Resolve conflicts with add_gitconfig_pkg
deathaxe Oct 1, 2017
1d17e49
Merge pull request #3 from deathaxe/pr/gitlink
Oct 12, 2017
689b737
Merge pull request #4 from deathaxe/pr/git-config
Oct 15, 2017
23e9200
[Git] Rename files to satisfy ST naming conventions
deathaxe Sep 25, 2017
bf103aa
[Git] Fix some scopes to satisfy new file names
deathaxe Sep 26, 2017
1a920e1
[Git] Create a hidden file with common scopes
deathaxe Sep 25, 2017
92dff27
[Git] Add Git Log syntax highlighting
deathaxe Sep 25, 2017
f97ebd3
[Git] Add .gitignore and .gitattributes syntax highlighting
deathaxe Oct 1, 2017
1a077a3
[Git] Link: Tweak path scoping along the lines of fnmatch
deathaxe Oct 10, 2017
942d62e
[Git] Config: Fix section snippet
deathaxe Oct 16, 2017
462873a
[Git] Config: Rename Symbol List
deathaxe Oct 21, 2017
7e2fd09
[Git] Rebase: Update comments
deathaxe Oct 21, 2017
2d9b9f9
[Git] Rebase: Use common line-end rule
deathaxe Oct 21, 2017
20445ee
[Git] Highlight fully qualified rebase message only
deathaxe Oct 21, 2017
aeb786b
[Git] Rebase: Rename commit-message to commit-section
deathaxe Oct 21, 2017
965b015
[Git] Commit: Add some comments as separators
deathaxe Oct 21, 2017
4896438
[Git] Commit: Typo
deathaxe Oct 21, 2017
b19e70c
[Git] Config: Don't mix escapes and trailing-slash
deathaxe Oct 21, 2017
9a78289
[Git] Config: Use escaped quotation marks
deathaxe Oct 21, 2017
ed8c6e7
[Git] Config: Udate/fix some syntax tests
deathaxe Oct 21, 2017
6bd9ada
Merge pull request #5 from deathaxe/pr/add_git_files
Oct 21, 2017
731e25f
[Git] Config: Remove format-escapes
deathaxe Nov 1, 2017
d30a0aa
Merge pull request #6 from deathaxe/pr/add_git_files
Nov 6, 2017
c8d8dee
[Git Files] Config: Allow single quoted value strings
deathaxe Dec 18, 2017
7e41d5b
[Git Files] Config: embed ShellScript
deathaxe Dec 18, 2017
0bcb500
[Git Files] Rebase: Scope all commit operations separately
deathaxe Dec 18, 2017
26f8095
[Git Files] Config: Remove single-quoted strings
deathaxe Jan 2, 2018
1701313
[Git Files] Config: Fix section header must not span multiple rows
deathaxe Jan 2, 2018
a8d5928
[Git Files] Config: Add support for legacy section headers
deathaxe Jan 2, 2018
6af5bfe
[Git Files] Config: Flatten section header rules
deathaxe Jan 2, 2018
0485882
[Git Files] Config: Add some divider comments
deathaxe Jan 2, 2018
c783cc9
[Git Files] Config: Increase performance by 13%
deathaxe Jan 2, 2018
85116e0
[Git Files] Config: Simplify 'escape' rule
deathaxe Jan 2, 2018
a987aff
[Git Files] Config: Improve meta.mapping scopes
deathaxe Jan 2, 2018
7aa5ffc
[Git Files] Config: Respect shellscript's line continuation
deathaxe Jan 2, 2018
b38ad96
[Git Files] Config: Hardening quoted shell script escape
deathaxe Jan 3, 2018
4de96c7
[Git Files] Config: Fix typo
deathaxe Jan 3, 2018
7c10705
Merge pull request #7 from deathaxe/add_gitconfig_pkg
Jan 4, 2018
00e10a8
[Git Files] Config: Capture eol if available
deathaxe Jan 21, 2018
bcd2798
[Git Files] Config: Add indention rules
deathaxe Jan 21, 2018
065536f
[Git Files] Config: Fix multiline shellscript with double quotes
deathaxe Feb 5, 2018
c2fee71
Merge pull request #8 from deathaxe/add_gitconfig_pkg
Feb 8, 2018
a255364
[Git Files] Config: Move Indention Rules to correct path
deathaxe Feb 10, 2018
758cc44
Merge pull request #9 from deathaxe/add_gitconfig_pkg
Feb 11, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions Git/Comments.tmPreferences
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="UTF-8"?>
<plist version="1.0">
<dict>
<key>name</key>
<string>Comments</string>
<key>scope</key>
<string>source.gitcommit, source.gitconfig, source.gitrebase</string>
<key>settings</key>
<dict>
<key>shellVariables</key>
<array>
<dict>
<key>name</key>
<string>TM_COMMENT_START</string>
<key>value</key>
<string># </string>
</dict>
</array>
</dict>
</dict>
</plist>
9 changes: 9 additions & 0 deletions Git/Snippets/section.sublime-snippet
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<snippet>
<content><![CDATA[
[${1:section}]
$0
]]></content>
<tabTrigger>section</tabTrigger>
<scope>source.gitconfig</scope>
<description>[section]</description>
</snippet>
14 changes: 14 additions & 0 deletions Git/Symbol List.tmPreferences
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<plist version="1.0">
<dict>
<key>name</key>
<string>Symbol List</string>
<key>scope</key>
<string>meta.brackets.gitconfig</string>
<key>settings</key>
<dict>
<key>showInSymbolList</key>
<integer>1</integer>
</dict>
</dict>
</plist>
204 changes: 204 additions & 0 deletions Git/gitcommit.sublime-syntax
Original file line number Diff line number Diff line change
@@ -0,0 +1,204 @@
%YAML 1.2
---
# Highlight regular git commits, merge commits, and tags.

name: Git Commit
file_extensions:
- COMMIT_EDITMSG
- MERGE_MSG
- TAG_EDITMSG
scope: text.git.commit

variables:
hash: \b\h{7,}\b
# Rebase operations
shortcut: '[defprsx]'
operator: \b(?:drop|edit|exec|fixup|pick|reword|squash|{{shortcut}})\b
# The following variables are required to support highlighting of special phrases
# in the git commit messages for all supported languages.
# Source: https://github.com/git/git/tree/master/po
# Languages: bg,ca,de,fr,is,it,ko,pt_PT,ru,sv,vi,zh_CH
on_branch: On branch|На клон|En la branca|Auf Branch|Sur la branche|Sul branch|현재 브랜치|No ramo|На ветке|På grenen|Trên nhánh|位于分支
date: Date|Дата|Data|Datum|Date|@is.po|@it.po|시각|Data|Дата|Datum|Ngày tháng|日期
# file state variables
# - @it.po , @is.po means no translation in the file found
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't those be removed from the variables below? Since they are the same for all the "sections", you can't differentiate between them.

Otoh, they probably won't be used and instead the original english text is shown, so it's not like it will hurt.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Those @it.po won't be added to a git generated comment and will therefore be ignored. We can use different placeholders if there are concerns about @ being used as username reference, but I didn't see such in comments. too.

Each variable has the same amount of "columns". Each column references a language / po-file. By removing those values we will loose this reference. If a single translation changes, you'll have to go through all translations and built up the list again. At the moment you now, bg.po belongs to the second column and so on. There are even duplicates in the columns, which I did not eliminate in order to keep this reference.

We can't use (?x) to split up in multiple lines and add a comment to each translation without adding dozens of[ ] for whitespace and bloat the lists.

# - the order is used from the *.po files for easy multi cursor copy & paste
both_deleted: both deleted|изтрити в двата случая|suprimit per ambdós|beide gelöscht|supprimé des deux côtés|@is.po|@it.po|양쪽에서 삭제|eliminado por ambos|оба удалены|borttaget av bägge|bị xóa bởi cả hai|双方删除
added_by_us: added by us|добавени от вас|afegit per nosaltres|von uns hinzugefügt|ajouté par nous|@is.po|@it.po|이 쪽에서 추가|adicionado por nós|добавлено нами|tillagt av oss|được thêm vào bởi chúng ta|由我们添加
deleted_by_them: deleted by them|изтрити от тях|suprimit per ells|von denen gelöscht|supprimé par eux|@is.po|@it.po|저 쪽에서 삭제|eliminado por eles|удалено ими|borttaget av dem|bị xóa đi bởi họ|由他们删除
added_by_them: added by them|добавени от тях|afegit per ells|von denen hinzugefügt|ajouté par eux|@is.po|@it.po|저 쪽에서 추가|adicionado por eles|добавлено ими|tillagt av dem|được thêm vào bởi họ|由他们添加
deleted_by_us: deleted by us|изтрити от вас|suprimit per nosaltres|von uns gelöscht|supprimé par nous|@is.po|@it.po|이 쪽에서 삭제|eliminado por nós|удалено нами|borttaget av oss|bị xóa bởi chúng ta|由我们删除
both_added: both added|добавени и в двата случая|afegit per ambdós|von beiden hinzugefügt|ajouté de deux côtés|@is.po|@it.po|양쪽에서 추가|adicionado por ambos|оба добавлены|tillagt av bägge|được thêm vào bởi cả hai|双方添加
both_modified: both modified|променени и в двата случая|modificat per ambdós|von beiden geändert|modifié des deux côtés|@is.po|@it.po|양쪽에서 수정|modificado por ambos|оба изменены|ändrat av bägge|bị sửa bởi cả hai|双方修改
new_file: new file|нов файл|fitxer nou|neue Datei|nouveau fichier|@is.po|nuovo file|새 파일|novo ficheiro|новый файл|ny fil|tập tin mới|新文件
copied: copied|копиран|copiat|kopiert|copié|@is.po|copiato|복사함|copiado|скопировано|kopierad|đã chép|拷贝
deleted: deleted|изтрит|suprimit|gelöscht|supprimé|@is.po|eliminato|삭제함|eliminado|удалено|borttagen|đã xóa|删除
modified: modified|променен|modificat|geändert|modifié|@is.po|modificato|수정함|modificado|изменено|ändrad|đã sửa|修改
renamed: renamed|преименуван|canviat de nom|umbenannt|renommé|@is.po|rinominato|이름 바꿈|nome mudado|переименовано|namnbytt|đã đổi tên|重命名
typechange: typechange|смяна на вида|canviat de tipus|Typänderung|modif. type|@is.po|typechange|종류 바뀜|tipo alterado|изменен тип|typbyte|đổi-kiểu|类型变更
unknown: unknown|непозната промяна|desconegut|unbekannt|inconnu|@is.po|sconosciuto|알 수 없음|desconhecido|неизвестно|okänd|không hiểu|未知
unmerged: unmerged|неслят|sense fusionar|nicht gemerged|non fusionné|@is.po|@it.po|병합하지 않음|não integrado|не слитые|osammanslagen|chưa hòa trộn|未合并

contexts:
prototype:
- include: dropped-content
- include: comments

main:
- match: ^\s*(?=\S)
set: commit-subject

commit-subject:
# first none empty none comment line is commit subject
- meta_scope: meta.subject.git.commit markup.heading.subject.git.commit
- match: $\n?
set: commit-separator
- include: references

commit-separator:
# empty line between subject and message
- match: \n
set: commit-message
- match: \S.*
scope: invalid.illegal.empty-line-expected.git.commit

commit-message:
# all none comment lines after subject belong to the message
- match: ^
push:
- meta_include_prototype: false
- meta_scope: meta.message.git.commit
- match: ^(?=#)
pop: true
- include: references
- include: signed-off

references:
# issue reference
# https://help.github.com/articles/closing-issues-using-keywords
- match: |-
(?x)
# optional closing keyword
(?i:
( (?:close|fixe|resolve)[ds]? | fix ) # keyword
\s* (:)? \s* # optional colon separator
)? # keyword is optional
# user/repo#issue
(
(?:
\b(?: \w+ (/) )? \w+ # user (optional) / repo
)?
(\#)[0-9]+ # issue number
)\b
scope: meta.reference.issue.git.commit
captures:
1: keyword.other.resolved-issue.git.commit
2: punctuation.separator.mapping.pair.resolved-issue.git.commit
3: constant.other.reference.issue.git.commit
4: punctuation.separator.reference.issue.git.commit
5: punctuation.definition.reference.issue.git.commit
# email reference
- match: (<)(\S+(\@)\S+?(\.)\S+)(>)
scope: meta.reference.email.git
captures:
1: punctuation.definition.reference.email.begin.git
2: entity.name.reference.email.git
3: punctuation.separator.email.git
4: punctuation.separator.email.git
5: punctuation.definition.reference.email.end.git
# user reference
- match: (\@)\w+\b
scope: meta.reference.username.git entity.name.reference.username.git
captures:
1: punctuation.definition.reference.username.git

signed-off:
- match: ^\s*(Signed-off-by)\s*(:)
captures:
1: keyword.other.signed-off-by.git.commit
2: punctuation.separator.mapping.pair.git.commit

comments:
- match: ^#
scope: punctuation.definition.comment.git.commit
push:
- meta_include_prototype: false
- meta_scope: comment.line.git.commit
- match: $\n?
pop: true
- include: branch-line
- include: change-list
- include: commands-line
- include: date-line
- include: head-line

branch-line:
- match: \b({{on_branch}})\s+(.*)
captures:
1: markup.heading.on-branch.git.commit
2: constant.language.branch-name.git.commit

change-list:
# list body
- match: \b({{new_file}}|{{added_by_them}}|{{added_by_us}}|{{both_added}})\s*(:)\s*(.*)
scope: meta.change-list.git.commit
captures:
1: keyword.other.change-list.git.commit
2: punctuation.separator.mapping.pair.change-list.git.commit
3: string.unquoted.git.commit markup.inserted.file.git.commit
- match: \b({{copied}}|{{renamed}}|{{typechange}})\s*(:)\s*(.*)
scope: meta.change-list.git.commit
captures:
1: keyword.other.change-list.git.commit
2: punctuation.separator.mapping.pair.change-list.git.commit
3: string.unquoted.git.commit markup.changed.file.name.git.commit
- match: \b({{modified}}|{{both_modified}})\s*(:)\s*(.*)
scope: meta.change-list.git.commit
captures:
1: keyword.other.change-list.git.commit
2: punctuation.separator.mapping.pair.change-list.git.commit
3: string.unquoted.git.commit markup.changed.file.content.git.commit
- match: \b({{deleted}}|{{deleted_by_them}}|{{deleted_by_us}}|{{both_deleted}})\s*(:)\s*(.*)
scope: meta.change-list.git.commit
captures:
1: keyword.other.change-list.git.commit
2: punctuation.separator.mapping.pair.change-list.git.commit
3: string.unquoted.git.commit markup.deleted.file.git.commit
- match: \b({{unknown}}|{{unmerged}})\s*(:)\s*(.*)
scope: meta.change-list.git.commit
captures:
1: keyword.other.change-list.git.commit
2: punctuation.separator.mapping.pair.change-list.git.commit
3: string.unquoted.git.commit markup.ignored.file.git.commit

commands-line:
# A rebase commit message's comment contains the list of the recent
# operations to help understand the context of the current commit.
- match: \s*({{operator}})\s+({{hash}})\s+(.+?)\s*$
scope: meta.command-list.git.commit
captures:
1: keyword.operator.git.commit
2: constant.numeric.hex.hash.git.commit
3: string.unquoted.subject.git.commit

date-line:
- match: \b({{date}})\s*(:)\s*(.*)
captures:
1: markup.heading.git.commit
2: punctuation.separator.mapping.pair.date.git.commit
3: constant.language.timestamp.git.commit

head-line:
# all comments ending with colon are scoped as headlines
- match: \b\w.+(?=:\s*$)
scope: markup.heading.git.commit

dropped-content:
# ------------------------ >8 ------------------------
- match: '# -{24} >8 -{24}\s*\n'
scope: comment.line.git.commit markup.bold.commit
set:
- meta_content_scope: meta.dropped.git.commit
- include: comments
- match: ^(?=diff --git)
set: [Packages/Diff/Diff.sublime-syntax]
Loading