OK, so technically this is a language definition and not a plugin, but I figured I’d post it here anyways. [size=150]Python Improved[/size] has (finally) been released on Package Control for all the world to use. Basically, I started out with the default Python.tmLanguage files from ST2 and TextMate, and ironed out a few minor (if I recall) differences between them, and started making some improvements, like having any *Exception or *Error highlighted, instead of just the predefined ones, and clarifying the difference between a “builtin function” (like open() or isinstance()) and a “builtin type” (like “ascii” or “bytearray”), even though many of them are also functions. I’m also a huge fan of @wuub’s SublimeREPL and its IPython integration, so I added scopes to highlight the “In #]/Out #]” line markers.
At some point I discovered @facelessuser’s Better Python and adapted many ideas from there. I then started playing with Django and installed Djaneiro, but wasn’t completely happy with it, so I cannabalized the parts I liked most and added them to what I was now calling “PythonImproved”. The project kind of languished for a while, but the success I’ve had with my Neon Color Scheme, which contains syntax highlighting for all of the new scopes in PythonImproved, I decided to clean it up, put together a README, and submit it to Package Control, and here we are.
Issues:
None that I’m really aware of, having been using it and tweaking it for most of the past year, but there is one thing I’d like to ask for help on: I haven’t put an extensive amount of work into it, but I’d love to support Python 3’s function annotations, even just the straightforward “:” and “->” operators, perhaps with a specialized scope for the word that comes after:
def greet(name: str, age: int) -> str:
print('Hello {0}, you are {1} years old'.format(name, age))
# instead of the standard
def greet(name, age):
print(...)
So, if you’re an expert regexer and want to contribute, head over to GitHub and open a pull request. Otherwise, if you have any other questions, concerns, implementation problems, whatever, feel free to open an issue and I’ll get back to you as soon as I can.
This will go into the README soon, but if you love Python Improved so much you want to make it your default Python language definition, do the following (in ST2):
- Copy “Packages/Python Improved/PythonImproved.tmLanguage” to some other location in your filesystem, not under the Sublime Text hierarchy.
- Open PythonImproved.tmLanguage in ST2.
- Change the contents of the key on line 44 to “Python”
- Save the file as “Python.tmLanguage”
- Quit ST2.
- From your OS/command line, rename “Packages/Python/Python.tmLanguage” to “Python.tmLanguage.backup” or something similar, just in case.
- Delete “Packages/Python/Python.tmLanguage.cache”
- Copy the newly edited and renamed Python.tmLanguage from its other location to “Packages/Python”
- Restart ST2.
- ???
- Profit!
(sorry, couldn’t help myself)
So, I hope you enjoy it, and if you have any questions just let me know!
MattDMo