How to make SublimeText support Python 3 annotations?

I tested both SublimeText 2 and 3, and both of them are wrong:

If you check this code, you will see all the code immediately after : syntax is not correctly allocated.

 def foo(a, b) -> str: # Nothing gets properly colored from here # A bunch of code… return "bar" 

I found some links explaining how to add my own syntax highlighting rules, but I did not find how to change the ones that were already implemented to fix them.

EDIT: Now, knowing where to change the default syntax highlighting rules thanks to MattDMo, I tried to change line 385 of my file

  <key>end</key> <string>(\))\s*(?:(\:)|(.*$\n?))</string> 

to

  <key>end</key> <string>(\))\s*(?:\->\s*[A-Za-z_][A-Za-z0-9_]*\s*)?(?:(\:)|(.*$\n?))</string> 

But that did not work.

+7
python sublimetext annotations syntax-highlighting
source share
1 answer

I created my own version ~ 2 months ago, it still has some (serious) errors, so feel free to report these errors on this github page or make a correction to it:

https://github.com/petervaro/python

Although there is a version of Cython that is created from the same file as Python itself, β†’ but it is absolutely incomplete tmLanguage, so do not use it! :)


UPDATE: Now it is "stable" and ready for serious work, so use it, share it and report errors! :)

+5
source share

All Articles