Skip to content
This repository was archived by the owner on Feb 20, 2022. It is now read-only.

Commit e694005

Browse files
committed
optional-comment-based highlighter (re, %, fmt, tmp) added, closes #19;
format string highlight added (except datetime and escape support), closes #36; template string highlight added; pure raw string support added; space between pound sign and comment text added, closes #32, closes #33; 3.5 matrix multiplication operator added; 3.6 async, await keywords added; 3.6 await, aenter, aexit, aiter and anext dunder methods support added; 3.6 StopAsyncIteration exception added; 3.7 f-string support added; improved and updated README + screenshot
1 parent 56ea301 commit e694005

16 files changed

+6712
-1154
lines changed

README.md

Lines changed: 44 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -1,74 +1,24 @@
11
Python and Cython language bundles
22
==================================
33

4-
***THE MOST POPULAR (AND FEATURE RICH) PYTHON SYNTAX HIGHLIGHTER FOR SUBLIME
5-
([OVER 11,000 DOWNLOADS!](https://sublime.wbond.net/packages/Python%203))***
4+
***THE MOST POPULAR AND MOST FEATURE RICH PYTHON SYNTAX HIGHLIGHTER FOR
5+
SUBLIME TEXT AS OF TIME,
6+
[OVER 75,000 DOWNLOADS](https://sublime.wbond.net/packages/Python%203))!***
67

7-
This repo is about python 3.3+ and cython 0.19.1+ related bundles for Sublime
8-
Text 2/3 and TextMate editors and for online usage.
8+
Bleeding-egde Python and Cython syntax highlighters and other goodies for
9+
Sublime Text 2/3 and TextMate editors.
910

10-
![Preview](img/preview.png)
11-
12-
Python 3.3
13-
----------
14-
15-
Python 3.3 is a truly powerful version of python, with a lot new and creative
16-
features -- and some of them are actually bringing new or different syntaxes!
17-
Unfortunately, the only available and default `tmLanguage` syntax-highlight
18-
definition file is pretty old (only supports 2.x) and has several annoying bugs
19-
and unfinished features -- not to mention, that the syntax of the new python
20-
features brake the full highlighting of the entire code.
21-
22-
I belive, that a good syntax highlighter for software developers has to be as
23-
much help as the auto-completion pop-up or a code linter script in a text
24-
editor.
25-
26-
That's why I have implemented a new syntax definition from scratch that is
27-
created especially for python 3.3 and above. I did this with pure python
28-
structures, some converters and build scripts. *(I found editing `JSON` files
29-
with their ugly double escape characters or editing `XML`/`tmLanguage`s directly
30-
could be pretty annoying on the long run.)*
31-
32-
The end result is very flexible, dynamic, reuseable and easy to read and write
33-
(syntax highlighted regexes -- with comments and variables). It is also simple
34-
to maintain and pretty short too (the new version is only 35% of the old one)!
35-
36-
Cython support
37-
--------------
38-
39-
Unfortunately cython syntax highlighter definitions also lack of updated,
40-
fully-working and 100% python compatible syntax definitions! I have created a
41-
brand-new build-system to combine and convert the highlighter based on the
42-
python one. With this tool, it is quite easy to keep up-to-date both the cython
43-
and the python definitions, and as a plus, I only have to maintain a single
44-
code-base. *Viva la* modularity!
45-
46-
Highlight on web
47-
----------------
11+
*(Or for any other editor, that is using the `.tmLanguage` syntax definition)*
4812

49-
***WORK IN PROGRESS***
50-
51-
Previously I wanted to support [`Rainbow.js`](http://craig.is/making/rainbows),
52-
but unfortunately this project hasn't been updated for almost a year now, it
53-
also has several very important, pending, open issues and without these the
54-
proper "translation" from my syntax highlighters to a Rainbow one is impossible.
13+
![Preview](img/preview.png)
5514

56-
Thankfully, there is a new, and very actively developed tool, called the
57-
[Ace Editor](http://ace.c9.io). I'm willing to support them, as they are
58-
providing a more feature rich syntax highlighter system, they call it
59-
`Ace Mode`. *(Further more, it is very similar to the `tmLanguage` system, and
60-
they also provide a tool for automatic `Mode` generation from `tmLanguage`,
61-
which is not perfect of course, as they claimed, but still better than
62-
nothing!)*
6315

64-
> The old, Rainbow-compatible version is still available:
65-
`etc/archive/js/Python.js`, but as before, it is still work-in-progress state,
66-
and it is very unlikely that I will finish it and/or support it in the future.
6716

68-
New is better
69-
-------------
17+
State of the Art
18+
----------------
7019

71-
Below are some of the most important improvements:
20+
Below are some of the most important improvements compared to the existing
21+
syntax highlighters:
7222

7323
- Added better number highlighting:
7424
- All types of floating point notations are working now;
@@ -79,21 +29,32 @@ Below are some of the most important improvements:
7929
- Declaration rules are extended with `nonlocal`.
8030
- *Ex-statements-now-functions* (like `print`) are updated.
8131
- New Exception highlighting added.
32+
- New keywords `async` and `await` added.
8233
- Function annotations are now supported.
8334
- Conventional-language variable `cls` added.
84-
- Better regex support (multiline, grouping, comments and more are improved).
35+
- Optional-comment-based string highlighting:
36+
- Better regex support (multiline, grouping, comments and more are improved).
37+
- Format specifier mini-language
38+
- Template strings
39+
- Matrix multiplication operator
8540
- String and byte literals:
8641
- Byte notation added;
8742
- Proper string prefixes added.
8843
- All the unused built-in and magic functions/methods are now removed.
8944
- All the unused keywords and notations are now removed.
9045

46+
47+
9148
Future plans
9249
------------
9350

94-
- Support format mini-language in strings.
51+
- Combine optional-comment-based string highlighters, eg. `# syntax:re+fmt`
52+
- Add optional-comment-based external language support, eg: `# syntax:sql`, for
53+
starters these should be SQL, HTML and JSON
9554
- Create a better Twilight-based theme file.
9655

56+
57+
9758
Installation
9859
------------
9960

@@ -129,6 +90,8 @@ repository. Navigate to your `Packages` folder and create a `Python3` and/or a
12990
folder and copy `Gloom.tmTheme` into it. Then go to user-settings, and change
13091
your old color theme to the new one.*
13192

93+
94+
13295
Contribute
13396
----------
13497

@@ -144,24 +107,31 @@ please use the following conventions when editing the original python files:
144107
- comment separators can be easily generated with the `src.utils.separator()`
145108
function
146109

110+
111+
147112
Appreciation
148113
------------
149114

150-
*Thank you very much @joncle (Jon Clements) for all the support and answers
151-
about python and regexes in general, @kms70847 (Kevin), @Ffisegydd (Keiron
152-
Pizzey), @schesis (Zero Piraeus) and @poke (Patrick Westerhoff) for the
153-
feedbacks, and of course thanks for all the wonderful members of the
154-
[sopython](http://sopython.com) chat room for supporting me in any ways! May the
155-
Cabbage be with us ;)*
115+
Thank you very much [@joncle](https://github.com/joncle) (Jon Clements) for all
116+
the support in general, [@kms70847](https://github.com/kms70847) (Kevin),
117+
[@Ffisegydd](https://github.com/Ffisegydd) (Keiron Pizzey),
118+
[@schesis](https://github.com/schesis) (Zero Piraeus) and
119+
[@poke](https://github.com/poke) (Patrick Westerhoff) for the feedbacks, and of
120+
course thanks for all the wonderful members of the
121+
[sopython](http://sopython.com) chat room for supporting me in any ways! *May
122+
the Cabbage be with us ;)*
123+
124+
I also want to thank for all the loyal users of this package, and especially
125+
[@rahul-ramadas](https://github.com/rahul-ramadas) (Rahul Ramadas) and
126+
[@bordaigorl](https://github.com/bordaigorl) (Emanuele D'Osualdo) who were
127+
very active on giving me feedbacks, reports, etc.
128+
156129

157-
*I also want to thank for all the loyal users of this package, and especially
158-
@rahul-ramadas (Rahul Ramadas) and @bordaigorl (Emanuele D'Osualdo) who were
159-
very active on giving me feedbacks, reports, etc.*
160130

161-
LICENSE
131+
License
162132
-------
163133

164-
Copyright (C) 2013 - 2014 Peter Varo
134+
Copyright (C) 2013 - 2017 Peter Varo
165135

166136
This program is free software: you can redistribute it and/or modify it under
167137
the terms of the GNU General Public License as published by the Free Software

TODO

Lines changed: 0 additions & 131 deletions
Original file line numberDiff line numberDiff line change
@@ -1,131 +0,0 @@
1-
## INFO ########################################################################
2-
## ##
3-
## Python and Cython Syntax Highlighters ##
4-
## ===================================== ##
5-
## ##
6-
## Version: 2.0.00.085 (20141101) ##
7-
## File: TODO ##
8-
## ##
9-
## For more information about the project, please visit ##
10-
## <https://github.com/petervaro/python>. ##
11-
## Copyright (C) 2013 - 2014 Peter Varo ##
12-
## ##
13-
## This program is free software: you can redistribute it and/or modify it ##
14-
## under the terms of the GNU General Public License as published by the ##
15-
## Free Software Foundation, either version 3 of the License, or ##
16-
## (at your option) any later version. ##
17-
## ##
18-
## This program is distributed in the hope that it will be useful, but ##
19-
## WITHOUT ANY WARRANTY; without even the implied warranty of ##
20-
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. ##
21-
## See the GNU General Public License for more details. ##
22-
## ##
23-
## You should have received a copy of the GNU General Public License ##
24-
## along with this program, most likely a file in the root directory, ##
25-
## called 'LICENSE'. If not, see <http://www.gnu.org/licenses>. ##
26-
## ##
27-
######################################################################## INFO ##
28-
29-
#---------------------------- 11 POSTS IN 4 FILES -----------------------------#
30-
TODO:
31-
#- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #
32-
# 1
33-
- file: etc/archive/to_css.py
34-
line: 1
35-
note: |
36-
Add this functionality src.convert.Theme
37-
38-
#- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #
39-
# 2
40-
- file: etc/archive/to_css.py
41-
line: 5
42-
note: |
43-
decide if we need `word-wrap: break-word;` or not?
44-
45-
#- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #
46-
# 3
47-
- file: src/cython.py
48-
line: 138
49-
note: |
50-
highlight type declarations in functions!
51-
Function name
52-
53-
#- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #
54-
# 4
55-
- file: src/cython.py
56-
line: 155
57-
note: |
58-
add illegal
59-
60-
#- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #
61-
# 5
62-
- file: src/cython.py
63-
line: 227
64-
note: |
65-
rearrange -> what is builtin function and what is builtin type?
66-
67-
#- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #
68-
# 6
69-
- file: src/cython.py
70-
line: 287
71-
note: |
72-
rearrange -> what is magic function and what is magic variable?
73-
74-
#- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #
75-
# 7
76-
- file: src/python.py
77-
line: 135
78-
note: |
79-
add illegal
80-
81-
#- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #
82-
# 8
83-
- file: src/python.py
84-
line: 198
85-
note: |
86-
rearrange -> what is builtin function and what is builtin type?
87-
88-
#- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #
89-
# 9
90-
- file: src/python.py
91-
line: 246
92-
note: |
93-
rearrange -> what is magic function and what is magic variable?
94-
95-
#- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #
96-
# 10
97-
- file: src/common.py
98-
line: 584
99-
note: |
100-
rearrange -> what is magic function and what is magic variable?
101-
102-
#- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #
103-
# 11
104-
- file: src/common.py
105-
line: 614
106-
note: |
107-
decide if source.sql and special words, like SELECT and INSERT needed
108-
109-
110-
111-
#----------------------------- 2 POSTS IN 2 FILES -----------------------------#
112-
NOTE:
113-
#- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #
114-
# 1
115-
- file: src/common.py
116-
line: 862
117-
note: |
118-
the problem of making this to be a begin/end block
119-
is that the patterns needs to include the multiline-
120-
comments only if the expression is in multline
121-
quotes otherwise it should be exclude it...
122-
123-
#- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #
124-
# 2
125-
- file: build.py
126-
line: 93
127-
note: |
128-
Old path to theme files => DO NOT SUPPORT IT:
129-
'~/Library/Application Support/Sublime Text 3/Packages/Color Scheme - Default'
130-
131-

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
2.0.00.085 (20141101)
1+
3.0.00 (20161115)

build.py

Lines changed: 7 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,14 @@
11
#!/usr/bin/env python3
2-
## INFO ########################################################################
3-
## ##
4-
## Python and Cython Syntax Highlighters ##
5-
## ===================================== ##
6-
## ##
7-
## Version: 2.0.00.081 (20141101) ##
8-
## File: build.py ##
9-
## ##
10-
## For more information about the project, please visit ##
11-
## <https://github.com/petervaro/python>. ##
12-
## Copyright (C) 2013 - 2014 Peter Varo ##
13-
## ##
14-
## This program is free software: you can redistribute it and/or modify it ##
15-
## under the terms of the GNU General Public License as published by the ##
16-
## Free Software Foundation, either version 3 of the License, or ##
17-
## (at your option) any later version. ##
18-
## ##
19-
## This program is distributed in the hope that it will be useful, but ##
20-
## WITHOUT ANY WARRANTY; without even the implied warranty of ##
21-
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. ##
22-
## See the GNU General Public License for more details. ##
23-
## ##
24-
## You should have received a copy of the GNU General Public License ##
25-
## along with this program, most likely a file in the root directory, ##
26-
## called 'LICENSE'. If not, see <http://www.gnu.org/licenses>. ##
27-
## ##
28-
######################################################################## INFO ##
2+
## INFO ##
3+
## INFO ##
294

305
# Import python modules
316
from os.path import join
327

338
# Module level constants
349
CURRENT_DIR = '.'
35-
LANG_PATH = join(CURRENT_DIR, 'langs')
36-
THEME_PATH = join(CURRENT_DIR, 'themes')
10+
LANG_PATH = join(CURRENT_DIR, 'langs')
11+
THEME_PATH = join(CURRENT_DIR, 'themes')
3712

3813
# Import cutils modules
3914
try:
@@ -72,22 +47,19 @@
7247
'scope': 'python.3',
7348
'comments' : {'lines': '# '},
7449
'test_name': 'Python3_TEST',
75-
'test_path': '~/Library/Application Support/Sublime Text 3/'
76-
'Packages/User/Python3_TEST'}
50+
'test_path': '~/.config/sublime-text-3/Packages/User/Python3_TEST'}
7751

7852
cy_details = {'name' : 'Cython',
7953
'path' : LANG_PATH,
8054
'scope': 'cython',
8155
'comments' : {'lines': '# '},
8256
'test_name': 'Cython_TEST',
83-
'test_path': '~/Library/Application Support/Sublime Text 3/'
84-
'Packages/User/Cython_TEST'}
57+
'test_path': '~/.config/sublime-text-3/Packages/User/Cython_TEST'}
8558

8659
gl_details = {'name': 'Gloom',
8760
'path': THEME_PATH,
8861
'test_name': 'Gloom_TEST',
89-
'test_path': '~/Library/Application Support/Sublime Text 3/'
90-
'Packages/User/Gloom_TEST'}
62+
'test_path': '~/.config/sublime-text-3/Packages/User/Gloom_TEST'}
9163

9264
# NOTE: Old path to theme files => DO NOT SUPPORT IT:
9365
# '~/Library/Application Support/Sublime Text 3/Packages/Color Scheme - Default'

0 commit comments

Comments
 (0)