Comments (8)
At the moment this is not possible due to pattern invariance, i.e. the start and end pattern consist of the same string pattern which is ambiguous. And what's possible won't be that great, for example:
{"py", "(\"\"\"[!\"\"\"]*)|(^[ \t]*\"\"\".*$)", {4 | SYN_IT}, {0}, 2},
In this case it will only work if starting string does not contain [ \t] and the ending pattern has it. Otherwise the priority is always given to the ending pattern due to shortest match first regex rule which won't trigger a start of a multiline block.
No matter how you look at it the patterns are the same (or could be the same theoretically).
One solution is to provide a way for user to specify the starting pattern such that the start and end are the same match group, and since they will be the same the 2nd match will terminate the blockhl.
This will be enough to terminate the block, but im not sure if highlighting """.* and .*""" will work. That's the case where everything before the first """ and after the last """ must not match .
I have to revisit this in the future.
from nextvi.
from nextvi.
Hi Claude,
I've made a promising change. Pull the last commit and try this pattern out:
{"/", "\"{3}.*\"{3}", {5 | SYN_IT}, {0}},
{"/", "((?:[!\"\"\"]*\"{3}\n$)|(?:^\"{3}.*)|\"{3})", {4 | SYN_IT}, {0}, -1},
It comes pretty close to what you want, here are the test cases:
ashds """ sdhash
123
asdas
asd
hasdhas """ sdhadh
Not quite, hasdhas and sdhash are not highlighted
""" sdhash
123
asdas
asd
hasdhas """
All good.
""" sdhash
123
asdas
asd
hasdhas """df
Not quite, hasdhas not highlighted but the block is terminated.
""" sdhash
123
asdas
asd
"""
All good.
"""
123
asdas
asd
"""
All good.
absbdabs """ 123 asdas asd """ sdf s
All good.
""" 123 asdas asd """
All good.
hh """ 123 asdas asd """
All good.
""" 123 asdas asd """ hsdfhshd
All good.
from nextvi.
from nextvi.
Are these two patterns working together? It looks like the first one will detect a single line docstring, but not trigger on a multi-line docstring. I am assuming the .* will not include newlines.
Yes, multiline patterns are those that contain non zero value for blkend struct member.
In more general contexts, some have suggested this pattern. Note the use of the non-greedy ? which nextvi supports. """[\s\S]?""" I think nextvi's regex does not support meta characters, right? If so, is there an equivalent to the [\s\S] ?
Right, [\s\S] is not supported because it can be achieved by just hard entering the character values into [],
I don't remember exactly but for example \s would be equalent to something like [ \t-\r]
There remains the difficulty of the identical docstring start and end markers. The second pattern has three options: a line ending with """, a line beginning with """, and just """. Is the order of these three options significant?
The order is significant, what comes first gets tested first.
This covers all the common uses of a docstring (in my limited experience). I could run into imaginative uses of docstrings. :-) Excellent! Thanks. P. S. I added the following to the Python section of conf. I like to highlight docstrings as comments.
Aye, I think I will add this to the base version as it demonstates single multiline pattern group. Its only valid if blkend is negative.
-Kyryl
from nextvi.
from nextvi.
Ah, I see if docstring must be preceded by ):
maybe a different approach could be used.
from nextvi.
from nextvi.
Related Issues (20)
- i<CR><ESC> HOT 6
- stdin pipe breaks all syntax highlighting HOT 1
- Issues with stdin_pipe HOT 14
- Is gf bind in normal mode that edits the file whose address is under the cursor, a thing in Nextvi? HOT 6
- arrowkeys_normal.patch shouldn't exit insert mode HOT 24
- Remove variable length arrays HOT 14
- arrowkeys_insert: the first time entering command mode, the command bar is broken until you type something HOT 1
- gcc warning HOT 2
- visual mode equivalent? HOT 2
- ec_closebuf segfaults if it is the only remaining buffer HOT 1
- Float without leading zero HOT 2
- a way to change how big tabs are HOT 1
- soft line wrap? HOT 2
- implementing vim-like dw HOT 3
- stdin_pipe: lockup if stdin is terminal HOT 5
- Skip command confirmation when only one line HOT 1
- arrowkeys_insert: cursor position is wrong when moving up or down a line after typing something HOT 6
- Segmentation fault HOT 3
- Edge case of missing filename HOT 3
- ex "!" HOT 2
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 nextvi.