-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2361 from Freed-Wu/main
Add Requirementstxt.sublime-syntax and its test.
- Loading branch information
Showing
4 changed files
with
282 additions
and
0 deletions.
There are no files selected for viewing
120 changes: 120 additions & 0 deletions
120
assets/syntaxes/02_Extra/Requirementstxt.sublime-syntax
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,120 @@ | ||
%YAML 1.2 | ||
--- | ||
# http://www.sublimetext.com/docs/syntax.html | ||
name: Requirements.txt | ||
scope: source.requirements-txt | ||
# https://pip.pypa.io/en/stable/reference/requirements-file-format/ | ||
# https://github.com/raimon49/requirements.txt.vim/blob/f246bd10155fbc3b1a9e2fff6c95b21521b09116/ftdetect/requirements.vim | ||
file_extensions: | ||
- requirements.txt | ||
- requirements.in | ||
- pip | ||
# https://github.com/sublimehq/Packages/pull/2760/files | ||
first_line_match: |- | ||
(?xi: | ||
^ \#! .* \bpip # shebang | ||
| ^ \s* \# .*? -\*- .*? \bpip-requirements\b .*? -\*- # editorconfig | ||
| ^ \s* \# (vim?|ex): .*? \brequirements\b # modeline | ||
) | ||
# pip install -r | ||
# pip-compile | ||
|
||
variables: | ||
operator: '===?|<=?|>=?|~=|!=' | ||
|
||
contexts: | ||
main: | ||
- match: '(?i)\d+[\da-z\-_\.\*]*' | ||
scope: constant.other.version-control.requirements-txt | ||
- match: '(?i)^\[?--?[\da-z\-]*\]?' | ||
scope: entity.name.function.option.requirements-txt | ||
- match: '{{operator}}' | ||
scope: keyword.operator.logical.requirements-txt | ||
- match: '(\[)' | ||
captures: | ||
1: punctuation.section.braces.begin.requirements-txt | ||
push: | ||
- meta_scope: variable.function.extra.requirements-txt | ||
- match: ',' | ||
scope: punctuation.separator.requirements-txt | ||
- match: '(\])' | ||
captures: | ||
1: punctuation.section.braces.end.requirements-txt | ||
pop: true | ||
- match: '(git\+?|hg\+|svn\+|bzr\+).*://.\S+' | ||
scope: markup.underline.link.versioncontrols.requirements-txt | ||
- match: '(@\s)?(https?|ftp|gopher)://?[^\s/$.?#].\S*' | ||
scope: markup.underline.link.url.requirements-txt | ||
captures: | ||
1: punctuation.definition.keyword.requirements-txt | ||
- match: '(?i)^[a-z\d_\-\.]*[a-z\d]' | ||
scope: variable.parameter.package-name.requirements-txt | ||
- match: '(;)' | ||
captures: | ||
1: punctuation.definition.annotation.requirements-txt | ||
push: | ||
- meta_scope: meta.annotation.requirements-txt | ||
# https://pip.pypa.io/en/stable/reference/inspect-report/#example | ||
- match: |- | ||
(?x: | ||
implementation_name | ||
| implementation_version | ||
| os_name | ||
| platform_machine | ||
| platform_release | ||
| platform_system | ||
| platform_version | ||
| python_full_version | ||
| platform_python_implementation | ||
| python_version | ||
| sys_platform | ||
) | ||
scope: variable.language.requirements-txt | ||
- match: '{{operator}}' | ||
scope: keyword.operator.logical.requirements-txt | ||
# https://pip.pypa.io/en/stable/reference/requirement-specifiers/#examples | ||
- match: '(")' | ||
captures: | ||
1: punctuation.definition.string.begin.double.requirements-txt | ||
push: | ||
- meta_scope: string.quoted.double.requirements-txt | ||
- match: '\\"' | ||
scope: constant.character.escape.double.requirements-txt | ||
- match: '(")' | ||
captures: | ||
1: punctuation.definition.string.end.double.requirements-txt | ||
pop: true | ||
- match: "(')" | ||
captures: | ||
1: punctuation.definition.string.begin.single.requirements-txt | ||
push: | ||
- meta_scope: string.quoted.single.requirements-txt | ||
- match: '\\''' | ||
scope: constant.character.escape.single.requirements-txt | ||
- match: "(')" | ||
captures: | ||
1: punctuation.definition.string.end.single.requirements-txt | ||
pop: true | ||
- match: '(.(?=#)|$)' | ||
pop: true | ||
- match: '(\$)(\{)' | ||
captures: | ||
1: punctuation.definition.keyword.requirements-txt | ||
2: punctuation.definition.begin.parameter.requirements-txt | ||
push: | ||
- meta_scope: variable.parameter.requirements-txt | ||
- match: '(\})' | ||
captures: | ||
1: punctuation.definition.end.parameter.requirements-txt | ||
pop: true | ||
- match: '(#)' | ||
captures: | ||
1: punctuation.definition.comment.requirements-txt | ||
push: | ||
- meta_scope: comment.line.requirements-txt | ||
- match: '(-*-) coding: .* (-*-)' | ||
captures: | ||
1: punctuation.definition.begin.pep263.requirements-txt | ||
2: punctuation.definition.end.pep263.requirements-txt | ||
- match: '$' | ||
pop: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
# SYNTAX TEST "Requirementstxt.sublime-syntax" | ||
# Options | ||
# <- punctuation.definition.comment | ||
# ^^^^^^^ comment.line | ||
--allow-external | ||
#^^^^^^^^^^^^^^^ entity.name.function.option | ||
--allow-unverified | ||
|
||
# Freeze packages | ||
alabaster==0.7.6 | ||
Babel>=2.9.1 | ||
docutils==0.12 | ||
gevent_subprocess==0.1.2 | ||
gitpython==3.0.7 | ||
hg-diff==1.2.4 | ||
#^^^^^^ variable.parameter.package-name | ||
# ^^ keyword.operator.logical | ||
# ^^^^^ constant.other | ||
Jinja2>=2.8.1 | ||
MarkupSafe==0.23 | ||
Pygments==2.7.4 | ||
pytz==2015.7 | ||
six==1.10.0 | ||
snowballstemmer==1.2.0 | ||
Sphinx==1.3.3 | ||
sphinx-rtd-theme==0.1.9 | ||
svn==1.0.1 | ||
zope.interface==4.2.0 | ||
|
||
# Examples from PEP508 | ||
# c.f. https://www.python.org/dev/peps/pep-0508/ | ||
requests [security,tests] >= 2.8.1, == 2.8.* ; python_version < "2.7" # Comment | ||
#^^^^^^^ variable.parameter.package-name | ||
# ^^^^^^^^^^^^^^^^ variable.function.extra | ||
# ^ punctuation.section.braces.begin | ||
# ^ punctuation.separator | ||
# ^ punctuation.section.braces.end | ||
# ^^ keyword.operator.logical | ||
# ^^^^^ constant.other | ||
# ^^ keyword.operator.logical | ||
# ^^^^^ constant.other | ||
# ^ punctuation.definition.annotation | ||
# ^^^^^^^^^^^^^^^^^^^^^^^^ meta.annotation | ||
# ^^^^^^^^^^^^^^ variable.language | ||
# ^ keyword.operator.logical | ||
# ^ punctuation.definition.string.begin.double | ||
# ^^^^^ string.quoted.double.requirements-txt | ||
# ^ punctuation.definition.string.end.double | ||
# ^^^^^^^^^ comment.line | ||
pip @ https://github.com/pypa/pip/archive/1.3.1.zip#sha1=da9234ee9982d4bbb3c72346a6de940a148ea686 | ||
# ^ punctuation.definition.keyword | ||
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ markup.underline.link.url | ||
name @ gopher:/foo/com" | ||
foobar[quux]<2,>=3; os_name=='a' | ||
|
||
# VCS repositories | ||
-e git+git://git.myproject.org/MyProject#egg=MyProject # Git | ||
# <- entity.name.function.option | ||
#^ entity.name.function.option | ||
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ markup.underline.link.versioncontrols | ||
# ^^^^^^^^^^^^^^^ - comment.line | ||
# ^^^^^ comment.line | ||
-e git://git.myproject.org/MyProject.git@v1.0#egg=MyProject | ||
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ markup.underline.link.versioncontrols | ||
-e hg+https://hg.myproject.org/MyProject#egg=MyProject # Mercurial | ||
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ markup.underline.link.versioncontrols | ||
# ^^^^^^^^^^^ comment.line | ||
-e hg+http://hg.myproject.org/MyProject@da39a3ee5e6b#egg=MyProject | ||
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ markup.underline.link.versioncontrols | ||
-e svn+http://svn.myproject.org/svn/MyProject/trunk@2019#egg=MyProject # Subversion | ||
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ markup.underline.link.versioncontrols | ||
# ^^^^^^^^^^^^ comment.line | ||
-e bzr+ssh://user@myproject.org/MyProject/trunk#egg=MyProject # Bazaar | ||
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ markup.underline.link.versioncontrols | ||
# ^^^^^^^^ comment.line | ||
-e bzr+https://bzr.myproject.org/MyProject/trunk@2019#egg=MyProject | ||
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ markup.underline.link.versioncontrols | ||
|
||
# Project or archive URL | ||
https://github.com/pallets/click/archive/7.0.zip#egg=click | ||
#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ markup.underline.link.url | ||
# ^^^^^^^^^^ - comment.line |
40 changes: 40 additions & 0 deletions
40
tests/syntax-tests/highlighted/Requirements.txt/requirements.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
[38;2;117;113;94m#[0m[38;2;117;113;94m Options[0m | ||
[38;2;166;226;46m--allow-external[0m | ||
[38;2;166;226;46m--allow-unverified[0m | ||
|
||
[38;2;117;113;94m#[0m[38;2;117;113;94m Freeze packages[0m | ||
[3;38;2;253;151;31malabaster[0m[38;2;249;38;114m==[0m[38;2;190;132;255m0.7.6[0m | ||
[3;38;2;253;151;31mBabel[0m[38;2;249;38;114m>=[0m[38;2;190;132;255m2.9.1[0m | ||
[3;38;2;253;151;31mdocutils[0m[38;2;249;38;114m==[0m[38;2;190;132;255m0.12[0m | ||
[3;38;2;253;151;31mgevent_subprocess[0m[38;2;249;38;114m==[0m[38;2;190;132;255m0.1.2[0m | ||
[3;38;2;253;151;31mgitpython[0m[38;2;249;38;114m==[0m[38;2;190;132;255m3.0.7[0m | ||
[3;38;2;253;151;31mhg-diff[0m[38;2;249;38;114m==[0m[38;2;190;132;255m1.2.4[0m | ||
[3;38;2;253;151;31mJinja2[0m[38;2;249;38;114m>=[0m[38;2;190;132;255m2.8.1[0m | ||
[3;38;2;253;151;31mMarkupSafe[0m[38;2;249;38;114m==[0m[38;2;190;132;255m0.23[0m | ||
[3;38;2;253;151;31mPygments[0m[38;2;249;38;114m==[0m[38;2;190;132;255m2.7.4[0m | ||
[3;38;2;253;151;31mpytz[0m[38;2;249;38;114m==[0m[38;2;190;132;255m2015.7[0m | ||
[3;38;2;253;151;31msix[0m[38;2;249;38;114m==[0m[38;2;190;132;255m1.10.0[0m | ||
[3;38;2;253;151;31msnowballstemmer[0m[38;2;249;38;114m==[0m[38;2;190;132;255m1.2.0[0m | ||
[3;38;2;253;151;31mSphinx[0m[38;2;249;38;114m==[0m[38;2;190;132;255m1.3.3[0m | ||
[3;38;2;253;151;31msphinx-rtd-theme[0m[38;2;249;38;114m==[0m[38;2;190;132;255m0.1.9[0m | ||
[3;38;2;253;151;31msvn[0m[38;2;249;38;114m==[0m[38;2;190;132;255m1.0.1[0m | ||
[3;38;2;253;151;31mzope.interface[0m[38;2;249;38;114m==[0m[38;2;190;132;255m4.2.0[0m | ||
|
||
[38;2;117;113;94m#[0m[38;2;117;113;94m Examples from PEP508[0m | ||
[38;2;117;113;94m#[0m[38;2;117;113;94m c.f. https://www.python.org/dev/peps/pep-0508/[0m | ||
[3;38;2;253;151;31mrequests[0m[38;2;248;248;242m [0m[38;2;248;248;242m[[0m[38;2;248;248;242msecurity[0m[38;2;248;248;242m,[0m[38;2;248;248;242mtests[0m[38;2;248;248;242m][0m[38;2;248;248;242m [0m[38;2;249;38;114m>=[0m[38;2;248;248;242m [0m[38;2;190;132;255m2.8.1[0m[38;2;248;248;242m, [0m[38;2;249;38;114m==[0m[38;2;248;248;242m [0m[38;2;190;132;255m2.8.*[0m[38;2;248;248;242m [0m[38;2;248;248;242m;[0m[38;2;248;248;242m [0m[38;2;255;255;255mpython_version[0m[38;2;248;248;242m [0m[38;2;249;38;114m<[0m[38;2;248;248;242m [0m[38;2;230;219;116m"[0m[38;2;230;219;116m2.7[0m[38;2;230;219;116m"[0m[38;2;248;248;242m [0m[38;2;117;113;94m#[0m[38;2;117;113;94m Comment[0m | ||
[3;38;2;253;151;31mpip[0m[38;2;248;248;242m [0m[4;38;2;166;226;46m@ [0m[4;38;2;166;226;46mhttps://github.com/pypa/pip/archive/1.3.1.zip#sha1=da9234ee9982d4bbb3c72346a6de940a148ea686[0m | ||
[3;38;2;253;151;31mname[0m[38;2;248;248;242m [0m[4;38;2;166;226;46m@ [0m[4;38;2;166;226;46mgopher:/foo/com"[0m | ||
[3;38;2;253;151;31mfoobar[0m[38;2;248;248;242m[[0m[38;2;248;248;242mquux[0m[38;2;248;248;242m][0m[38;2;249;38;114m<[0m[38;2;190;132;255m2[0m[38;2;248;248;242m,[0m[38;2;249;38;114m>=[0m[38;2;190;132;255m3[0m[38;2;248;248;242m;[0m[38;2;248;248;242m [0m[38;2;255;255;255mos_name[0m[38;2;249;38;114m==[0m[38;2;230;219;116m'[0m[38;2;230;219;116ma[0m[38;2;230;219;116m'[0m | ||
|
||
[38;2;117;113;94m#[0m[38;2;117;113;94m VCS repositories[0m | ||
[38;2;166;226;46m-e[0m[38;2;248;248;242m [0m[4;38;2;166;226;46mgit+git://git.myproject.org/MyProject#egg=MyProject[0m[38;2;248;248;242m [0m[38;2;117;113;94m#[0m[38;2;117;113;94m Git[0m | ||
[38;2;166;226;46m-e[0m[38;2;248;248;242m [0m[4;38;2;166;226;46mgit://git.myproject.org/MyProject.git@v1.0#egg=MyProject[0m | ||
[38;2;166;226;46m-e[0m[38;2;248;248;242m [0m[4;38;2;166;226;46mhg+https://hg.myproject.org/MyProject#egg=MyProject[0m[38;2;248;248;242m [0m[38;2;117;113;94m#[0m[38;2;117;113;94m Mercurial[0m | ||
[38;2;166;226;46m-e[0m[38;2;248;248;242m [0m[4;38;2;166;226;46mhg+http://hg.myproject.org/MyProject@da39a3ee5e6b#egg=MyProject[0m | ||
[38;2;166;226;46m-e[0m[38;2;248;248;242m [0m[4;38;2;166;226;46msvn+http://svn.myproject.org/svn/MyProject/trunk@2019#egg=MyProject[0m[38;2;248;248;242m [0m[38;2;117;113;94m#[0m[38;2;117;113;94m Subversion[0m | ||
[38;2;166;226;46m-e[0m[38;2;248;248;242m [0m[4;38;2;166;226;46mbzr+ssh://user@myproject.org/MyProject/trunk#egg=MyProject[0m[38;2;248;248;242m [0m[38;2;117;113;94m#[0m[38;2;117;113;94m Bazaar[0m | ||
[38;2;166;226;46m-e[0m[38;2;248;248;242m [0m[4;38;2;166;226;46mbzr+https://bzr.myproject.org/MyProject/trunk@2019#egg=MyProject[0m | ||
|
||
[38;2;117;113;94m#[0m[38;2;117;113;94m Project or archive URL[0m | ||
[4;38;2;166;226;46mhttps://github.com/pallets/click/archive/7.0.zip#egg=click[0m |
40 changes: 40 additions & 0 deletions
40
tests/syntax-tests/source/Requirements.txt/requirements.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# Options | ||
--allow-external | ||
--allow-unverified | ||
|
||
# Freeze packages | ||
alabaster==0.7.6 | ||
Babel>=2.9.1 | ||
docutils==0.12 | ||
gevent_subprocess==0.1.2 | ||
gitpython==3.0.7 | ||
hg-diff==1.2.4 | ||
Jinja2>=2.8.1 | ||
MarkupSafe==0.23 | ||
Pygments==2.7.4 | ||
pytz==2015.7 | ||
six==1.10.0 | ||
snowballstemmer==1.2.0 | ||
Sphinx==1.3.3 | ||
sphinx-rtd-theme==0.1.9 | ||
svn==1.0.1 | ||
zope.interface==4.2.0 | ||
|
||
# Examples from PEP508 | ||
# c.f. https://www.python.org/dev/peps/pep-0508/ | ||
requests [security,tests] >= 2.8.1, == 2.8.* ; python_version < "2.7" # Comment | ||
pip @ https://github.com/pypa/pip/archive/1.3.1.zip#sha1=da9234ee9982d4bbb3c72346a6de940a148ea686 | ||
name @ gopher:/foo/com" | ||
foobar[quux]<2,>=3; os_name=='a' | ||
|
||
# VCS repositories | ||
-e git+git://git.myproject.org/MyProject#egg=MyProject # Git | ||
-e git://git.myproject.org/MyProject.git@v1.0#egg=MyProject | ||
-e hg+https://hg.myproject.org/MyProject#egg=MyProject # Mercurial | ||
-e hg+http://hg.myproject.org/MyProject@da39a3ee5e6b#egg=MyProject | ||
-e svn+http://svn.myproject.org/svn/MyProject/trunk@2019#egg=MyProject # Subversion | ||
-e bzr+ssh://user@myproject.org/MyProject/trunk#egg=MyProject # Bazaar | ||
-e bzr+https://bzr.myproject.org/MyProject/trunk@2019#egg=MyProject | ||
|
||
# Project or archive URL | ||
https://github.com/pallets/click/archive/7.0.zip#egg=click |