Skip to content

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

Open
achimnol wants to merge 23 commits into
hdima:masterfrom
achimnol:master
Open

Add support for Python 3.6 f-string literal, underscore in numbers, and Python 3.5 type annotations#60
achimnol wants to merge 23 commits into
hdima:masterfrom
achimnol:master

Conversation

@achimnol

@achimnol achimnol commented Nov 25, 2016

Copy link
Copy Markdown
Contributor

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.

@lilydjwg

lilydjwg commented Dec 9, 2016

Copy link
Copy Markdown

It works great for me, thank you!

@monkoose

monkoose commented Dec 31, 2016

Copy link
Copy Markdown

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?

@lilydjwg

Copy link
Copy Markdown

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

lilydjwg added a commit to vim-python/python-syntax that referenced this pull request Feb 17, 2017
lilydjwg added a commit to vim-python/python-syntax that referenced this pull request Feb 17, 2017
achimnol added 2 commits June 2, 2017 11:24
 * Make them highlighted only when used as in the global namespace. (e.g., `id` in `something.id` is not highlighted)
 * Also add self and cls to builtin objects
 * Builtin-functions are highlighted only when used as global functions.
 * Annotations in type-only variable definitions and assignment statements are not supported yet due to potential conflicts with dictionary expressions.
 * Uses a custom syntax highlight def "Optional" (in my setup, it applies italic style.)
 * Taken from purpleP/python-syntax commits and customized.
@achimnol achimnol changed the title Add support for Python 3.6 f-string literal and underscore in numbers. Add support for Python 3.6 f-string literal, underscore in numbers, and Python 3.5 type annotations Jun 5, 2017
@y9c

y9c commented Mar 15, 2018

Copy link
Copy Markdown

@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 y9c left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image

@wsdjeg

wsdjeg commented Mar 16, 2018

Copy link
Copy Markdown

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?

@lilydjwg

Copy link
Copy Markdown

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

Comment thread syntax/python.vim
syn match pythonStatement "\<async\s\+for\>" display
endif

syn cluster pythonTypeExpression contains=pythonTypeAnno,pythonTypeUnion,pythonTypeArgs

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove pythonTypeArgs ?

@y9c

y9c commented Mar 19, 2018

Copy link
Copy Markdown

@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?

@lilydjwg

lilydjwg commented Mar 23, 2018

Copy link
Copy Markdown

@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 added a commit to lilydjwg/dotvim that referenced this pull request Mar 26, 2018
@lilydjwg

Copy link
Copy Markdown

@yech1990 here's another bug:

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

y will be highlighted as pythonTypeUnion.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants