Comments (2)
This has been fixed over at the fork vim-python/python-syntax.
from python-syntax.
Trying to make a PR for this, but needs help!
I'm not quite professional in vim syntax writing. 😞
syn region pythonFString start=+[fF]'+ skip=+\\\\\|\\'\|\\$+ excludenl end=+'+ end=+$+ keepend contains=pythonBytesEscape,pythonBytesEscapeError,pythonUniEscape,pythonUniEscapeError,@Spell
syn region pythonFString start=+[fF]"+ skip=+\\\\\|\\"\|\\$+ excludenl end=+"+ end=+$+ keepend contains=pythonBytesEscape,pythonBytesEscapeError,pythonUniEscape,pythonUniEscapeError,@Spell
syn region pythonFString start=+[fF]"""+ end=+"""+ keepend contains=pythonBytesEscape,pythonBytesEscapeError,pythonUniEscape,pythonUniEscapeError,pythonDocTest2,pythonSpaceError,@Spell
syn region pythonFString start=+[fF]'''+ end=+'''+ keepend contains=pythonBytesEscape,pythonBytesEscapeError,pythonUniEscape,pythonUniEscapeError,pythonDocTest,pythonSpaceError,@Spell
...
syn match pythonStrFormat "{{\|}}" contained containedin=pythonString,pythonRawString
syn match pythonStrFormat "{\%(\%([^[:cntrl:][:space:][:punct:][:digit:]]\|_\)\%([^[:cntrl:][:punct:][:space:]]\|_\)*\|\d\+\)\=\%(\.\%([^[:cntrl:][:space:][:punct:][:digit:]]\|_\)\%([^[:cntrl:][:punct:][:space:]]\|_\)*\|\[\%(\d\+\|[^!:\}]\+\)\]\)*\%(![rsa]\)\=\%(:\%({\%(\%([^[:cntrl:][:space:][:punct:][:digit:]]\|_\)\%([^[:cntrl:][:punct:][:space:]]\|_\)*\|\d\+\)}\|\%([^}]\=[<>=^]\)\=[ +-]\=#\=0\=\d*,\=\%(\.\d\+\)\=[bcdeEfFgGnosxX%]\=\)\=\)\=}" contained containedin=pythonString,pythonRawString
syn match pythonStrInterpFormat "{{\|}}" contained containedin=pythonFString
syn match pythonStrInterpFormat "{<any python expression>\%(![rsa]\)\=\%(:\%({\%(\%([^[:cntrl:][:space:][:punct:][:digit:]]\|_\)\%([^[:cntrl:][:punct:][:space:]]\|_\)*\|\d\+\)}\|\%([^}]\=[<>=^]\)\=[ +-]\=#\=0\=\d*,\=\%(\.\d\+\)\=[bcdeEfFgGnosxX%]\=\)\=\)\=}" contained containedin=pythonFString
...
HiLink pythonFString String
HiLink pythonStrInterpFormat Special
I need to make Vim to treat above <any python expression>
part like a just normal Python expression. The only rules for them are:
- It should not contain the string terminating quote (e.g., if the current f-string has begun with a single quote, then the expressions may not contain single quote because it will break the Python parser.
- As the content inside braces are limited to expressions,
colon andexclamation mark can be used like previous string formatting mini-language. So I've copy-and-pasted the later part from the existing syntax. Update: colon may be used in parenthesized lambda expression, for example,f"{(lambda: 1)()}"
A nice test case would be something like f"{var} plain {expr1 if True or False else expr2} text {var!r} {dictob['key']:.2f} abc {123_34E+2:g} {(lambda: 1)()}"
. Somebody please help me to figure out how to do this! 😁
from python-syntax.
Related Issues (20)
- datetime formatting in "{}" formay string
- None is highlighted differently in Python 3 than in Python 2 HOT 2
- "{{" not recognized as an escape HOT 1
- Please add new syntax (await, async) highlight HOT 1
- The identifier next to "async def" is not highlighted as function name HOT 2
- Function annotations? HOT 1
- No difference in highlighting of `print` between Python 2 and 3 HOT 1
- More module attributes HOT 1
- self isn't highlighted in classes HOT 6
- highlight keyword in keyword arguments in function calls with kwargs HOT 1
- highliting isn't semantic aware. HOT 1
- matrix multiplication HOT 1
- `is not` does not highlight
- exec is a function under Python3, not a statement HOT 2
- How to enable folding ? HOT 4
- async / await not highlighted
- Python 3.6 underscores in numeric literal support HOT 1
- This project is dead, time to fork HOT 6
- Tabbing behaviour is broken
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from python-syntax.