add more keywords to python #2
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "patch-1"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Commit adds more keywords, specifically python built-ins.
https://github.com/codemirror/CodeMirror/blob/master/mode/python/python.js
https://docs.python.org/3/library/functions.html
https://docs.python.org/3/library/constants.html
Built-in functions aren't keywords, and shouldn't be highlighted as such. In any case, this change will not do anything since it makes the highlighting target syntax nodes that don't exist.
Does that mean to syntax highlight python built-ins, it would require both a change to grammers in lezer python and a new tag for built-ins in codemirror?
There is a tag modifier called
standardthat is intended to be used for builtins. But yes, you do need cooperation from the grammar to parse them, and doing so reliably may not even be possible on the syntax level (many languages allow you to shadow standard globals, for example, or make them contextual in other ways).There are some half-baked plans for adding scope tracking support to the highlighting system, and it might be reasonable to integrate some way to highlight standard identifiers with that, but for the moment there's no solid (or even easy) way to do this.
@marijnh Is there a way to achieve highlighting for python built-in functions currently? All the links to tags are no longer valid, as that's something that was removed I assume.
No, there isn't, without forking the Python parser.
Pull request closed