-
Notifications
You must be signed in to change notification settings - Fork 28k
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
[python] Replace TextMate for Python syntax highlighting #2208
Comments
There's also #2867 suggesting to take MagicPython. |
Just gave it a try. Looks good to me! |
I'm the maintainer of Python Improved, and I have no issues at all with your using it to supplement or replace the TextMate syntax definition in VSCode. One issue I've found with Magic Python is that a number of the scopes are rather different than the TM/Sublime Text originals, so switching to that could cause issues with color schemes that aren't compatible with MP. Those of us working on PI with me have tried to maintain compatibility with the original scopes as much as possible (or, at least, as much as makes sense), so it should work with a broader array of color schemes. I've tailored my Neon Color Scheme to work with all the new scopes in PI, in case you want to include that as well. Let me know what you think, or if I can help in any way. Alternatively, I can add PI and Neon to the VSCode store if you think that would be a better option. |
Perhaps @aeschli can offer advice on a path to take (I'm just a random user), but I would guess a solid first step would be to make PythonImproved available as a VS Code extension and then take it from there. |
@MattDMo Thanks Matt for your comment. Yes, making Python Improved available as a VS Code extension would be a great first step so more people can try it out. "extensionDependencies": [
"vscode.python"
] to your |
There has been new work in the TextMate's Python bundle. So I've updated the grammar to the latest. I'm still open to update to any other grammar if the community has a clear preference. But then, as said, thanks to the extension model it's possible to add grammars as extensions and each user is free to choose what to use. |
@MattDMo , have you had any luck in building an extension for VS Code. I'm certain there would plenty of people within the community and the VS Code team willing to help you with this. |
@MattDMo , @aeschli , I'm am in the process of creating a VS Code extension using the code from Python Improved. The issue #2936 doesn't appear in Magic Python, however when using the tmLanguage file from PythonImproved, I can see that the issue still exists. Those are the only two issues I could find. |
@DonJayamanne As a maintainer of MagicPython I'd strongly recommend you to go with it. Simply because we embrace TDD, MP is super stable and we can add new features very quickly. It's also used by GitHub to highlight Python sources. We have 100s of complex automated unittests, something that no other syntax highlighter for any other language does (for tmLanguage format anyways). Some additional features of MP (I just went through our unittests and checked which ones break standard highlighter or PI):
some. True
a = True
class F:
def __init__(self, a, b=1):
self.a = a
x = None # type: List[str, a]
y = None # type: Dict[int, Any] # int
r'''Module docstring
Some text followed by code sample:
>>> for a in foo(2, b=1,
... c=3):
... print(a)
0
1
'''
def some_func(a:
lambda x=None:
{key: val
for key, val in
(x if x is not None else [])
}=42):
1 + \ sdgfsdf
def foo(): pass
a = 'qqq{0:{width}{base}}www'
a = 'qqq{0:$20}www'
a = 'qqq{0}www'
class Üa(Êa):
'Œ\nŃ'
@æaœ
def ŌÏŒĘ(self, Ú=1):
print('превед 你好')
return Ù
你好 = lambda: 你好
def 你好(): pass There are much more small, but handy (sometimes obscure) features in MP, but I don't want to list too many examples. |
Also, MP is already used by >31000 VSCode users: https://marketplace.visualstudio.com/items?itemName=magicstack.MagicPython |
As the person who reported this issue, I can also add that I'm a happy MagicPython user too. 👍 |
I have no issues with using MagicPython, if that's the way you want to go. PythonImproved is just a side project in my free time (I'm actually a research scientist in biotech in real life), and honestly I just don't have the time at the moment to support some of the features that MP does already. If there's anything in PI that can be useful, please feel free to grab it (just attribute me in some way). Hopefully I'll eventually get around to releasing PI for VSCode, but work is definitely my top priority at the moment, so I don't know when that will be. Sorry I can't spend more time on it, but since PI isn't directly related to my primary job functions at work, the company won't support my time spent on an open source project. Please do keep me in the loop, though, and I'll try to answer any concerns that may arise. |
@aeschli , my plan is to update the Python tmlanguage files (later today) with the ones from MagicPython:
FYI - as this is a simple update to a tmlanguage file, I won't be creating a PR. |
One quick note just in case: please make sure that the Also, would it be possible to publicly state that VSCode uses MagicPython and to direct highlighter related issues to our tracker? |
|
|
I initiated the OSSRequest. You can proceed and change the OSSReadme file to
Let me know one you committed the changes, then I'll trigger the script that updates the ThirdPartyNotices. |
@aeschli , I will submit a PR later today.
I.e. the final result would be as follows (one json and other tmLanguage): "grammars": [{
"language": "python",
"scopeName": "source.python",
"path": "./syntaxes/Python.tmLanguage.json"
},{
"scopeName": "source.regexp.python",
"path": "./syntaxes/Regular Expressions (Python).tmLanguage"
}] |
@DonJayamanne Thanks for looking into the grammar update scripts. It’s a manual step. We want to update at a controlled time (e.g. not right before a release so that we get a chance to receive bug reports in time) and also do some sanity testing before pushing a grammar update. I have just started adopting the scripts. I will add the script and migrate from using Yes, if |
VS Code's syntax highlighting for Python is broken in a few ways.
VS Code currently uses TextMate's Python bundle for syntax highlighting. The problem is that this project seems to be unmaintained. The last commit was from mid-2014.
We should replace this with a project that is more up-to-date and actively maintained. PythonImproved seems to fit the bill, though I haven't used it yet. I've asked the maintainers of that project about compatibility with VS Code.
If anyone has other suggestions for a better tokenizer for Python, please speak up.
The text was updated successfully, but these errors were encountered: