python-syntax icon indicating copy to clipboard operation
python-syntax copied to clipboard

Add support for Python 3.6 f-string literal, underscore in numbers, and Python 3.5 type annotations

Open achimnol opened this issue 8 years ago • 9 comments

PR for #58 and #59. Finally I figured out how to "embed" other syntax inside a region using syn cluster. Python keywords, numbers, booleans, and builtins are highlighted inside f-string braced regions. I tried to prevent the content inside braces from being highlighted as "Special" while keeping the braces and format string highlighted, but could not separate them. Still, I think this version much improves readability.

image image

Comments, optimizations, and fixes are welcome.

achimnol avatar Nov 25 '16 14:11 achimnol

It works great for me, thank you!

lilydjwg avatar Dec 09 '16 06:12 lilydjwg

Seems like @hdima is rare guest on github lately. But this is the best known vim python syntax repository. Maybe someone should take lead of this repo, someone who atleast can review and accept pull requests?

monkoose avatar Dec 31 '16 13:12 monkoose

That will need privileges granted by hdima, or we can only have forks. I'm already maintaining my own fork.

lilydjwg avatar Dec 31 '16 13:12 lilydjwg

@achimnol

Thanks you for you work.

I seems that pythonTypeArgs is not correctly matched. I highlight type annotation with red italic font, thus your can see the bug directly.

image

*red arrow indicate the code that should not mark as python type annotation. *

y9c avatar Mar 15 '18 05:03 y9c

as I know Vim runtime has python syntax file. so what is the differences? and why is can not be merged into Vim core repo?

wsdjeg avatar Mar 16 '18 23:03 wsdjeg

@achimnol @yech1990 don't include pythonTypeArgs in pythonTypeExpression. pythonTypeArgs should only be contained in pythonType*, not everywhere pythonTypeExpression can be contained.

lilydjwg avatar Mar 19 '18 08:03 lilydjwg

@lilydjwg Thank you for your reply. I remove pythonTypeArgs from L213 and python list is rendered correctly now. Is there any other bug I didn't notice?

y9c avatar Mar 19 '18 15:03 y9c

@yech1990 No. I was using another version. I've switched to this version since it has more features. I'll comment here if I notice anything wrong.

lilydjwg avatar Mar 23 '18 10:03 lilydjwg

@yech1990 here's another bug:

def func():
  a = call(x | y)

y will be highlighted as pythonTypeUnion.

lilydjwg avatar Apr 28 '18 06:04 lilydjwg