`async` and `await` are Python keywords since Python 3.5, however, they are not highlighted as such in Geany.
![geany-async](https://cloud.githubusercontent.com/assets/2401856/21525405/64e7c93a-cd1d-11...)
Patch to Scintilla isn't necessary. The list of keywords is maintained in Geany. If you wish, you could create a patch for Scite but this is out of scope of this project :).
Back to Geany: we have a script to automatically update the Python keywords which basicalls asks the Python `keyword` module for known keywords: ```python from keyword import kwlist print("\n".join(kwlist)) ``` (source: https://github.com/geany/geany/blob/master/scripts/update-python-identifiers...)
However, the Python `keyword` module doesn't know `await` and `async` neither (source: https://hg.python.org/cpython/file/3.6/Lib/keyword.py). So, maybe this is the root thing to fix first. Would you mind reporting this to the Python guys?
Thanks Miro.
And the docs don't list them as keywords https://docs.python.org/3/reference/lexical_analysis.html#keywords
In fact they are not meant to be keywords until Python 3.7, see [the PEP](https://www.python.org/dev/peps/pep-0492/#deprecation-plans).
Thanks for the info. Would it be possible to add `async` and `await` manually for now and remove it in the future?
Personally I would suggest not adding manually because:
1) manual additions are likely to be forgotten when the script @eht16 mentioned gets run
2) since Geany does not know which Python is being used it will highlight async and friends in old code where they are not keywords. Better to wait until they are keywords in at least some code by which time many non-keyword uses will have been fixed.
But you can add them yourself you know, `Menu->Tools->Configuration files->Filetype configuration->scripting languages->filetypes.python` will open the appropriate file and save it to your user configuration directory. Just add them to the `primary=` line.
1. I meant adding them in the script not to be forgotten 2. That's up to you. I think that it is more likely that people have them in new code as keywords than other way around.
Thanks for the workaround tip.
I meant adding them in the script not to be forgotten
So then its forgotten to remove the special handling years in the future when 3.7 is released :smile: Although the script could check versions its better to KISS.
I think that it is more likely that people have them in new code as keywords than other way around.
In new code I agree, but at the moment there is likely to be lots more old code (including python 2 code). Its a balancing act, like the question of when `python` defaults to `python3` instead of `python2`, some bleeding edge distros already do, more mainstream ones do not.
Could we at least distinguish between python2 and python3 relying on the shebang line (if it exists) in order to highlight differently python2 source files from python3 ones?
@Akronix no Geany only has one python filetype.
It would be possible to split that into Python 2 and Python 3 types but it would require C coding to appropriately handle two filetypes everywhere Python behaviour is currently hard coded in Geany :(
Splitting Python 2 and 3 as filetypes in Geany is whole another story. Apart from the fact, that I don't think it's necessary at all. Except a very few details, the syntax is identically regarding highlighting between Python 2 and Python 3. And in the long term, most people will write and maintain Python 3 code.
Back to this issue: I'd say let's way for Python 3.7 and then just regenerate the keywords list. In the meantime, users can manually add the keywords if necessary.
I agree with @eht16, the future is Python 3, it doesn't make much sense to split into separate filetypes, just as it doesn't for C89 vs C11 or C++98 vs C++14 or whatever.
3.7 is out
Closed #1351 via #1894.
github-comments@lists.geany.org