diff options
| author | Răzvan C. Rădulescu <razcore.rad@gmail.com> | 2022-11-30 12:15:49 +0200 |
|---|---|---|
| committer | Maxime Coste <mawww@kakoune.org> | 2022-12-17 10:08:33 +1100 |
| commit | 86bd4efd258a3e51245f5a6fcca9ee19790dee6e (patch) | |
| tree | 84bdd07bf249ec867e23b3005d15f0100ac0f3d8 /rc/filetype/python.kak | |
| parent | 80ae73c66547949c6e39117f46d0c38a91a84687 (diff) | |
Add Python f-string interpolation highlights
Diffstat (limited to 'rc/filetype/python.kak')
| -rw-r--r-- | rc/filetype/python.kak | 23 |
1 files changed, 20 insertions, 3 deletions
diff --git a/rc/filetype/python.kak b/rc/filetype/python.kak index 6444423b..391789ba 100644 --- a/rc/filetype/python.kak +++ b/rc/filetype/python.kak @@ -36,12 +36,29 @@ provide-module python %§ add-highlighter shared/python regions add-highlighter shared/python/code default-region group add-highlighter shared/python/docstring region -match-capture ^\h*("""|''') (?<!\\)(?:\\\\)*("""|''') regions -add-highlighter shared/python/triple_string region -match-capture ("""|''') (?<!\\)(?:\\\\)*("""|''') fill string -add-highlighter shared/python/double_string region '"' (?<!\\)(\\\\)*" fill string -add-highlighter shared/python/single_string region "'" (?<!\\)(\\\\)*' fill string + add-highlighter shared/python/documentation region '##' '$' fill documentation add-highlighter shared/python/comment region '#' '$' fill comment +# String interpolation +add-highlighter shared/python/f_triple_string region -match-capture [fF]("""|''') (?<!\\)(?:\\\\)*("""|''') group +add-highlighter shared/python/f_triple_string/ fill string +add-highlighter shared/python/f_triple_string/ regex \{.*?\} 0:value + +add-highlighter shared/python/f_double_string region '[fF]"' (?<!\\)(\\\\)*" group +add-highlighter shared/python/f_double_string/ fill string +add-highlighter shared/python/f_double_string/ regex \{.*?\} 0:value + +add-highlighter shared/python/f_single_string region "[fF]'" (?<!\\)(\\\\)*' group +add-highlighter shared/python/f_single_string/ fill string +add-highlighter shared/python/f_single_string/ regex \{.*?\} 0:value + + +# Regular string +add-highlighter shared/python/triple_string region -match-capture ("""|''') (?<!\\)(?:\\\\)*("""|''') fill string +add-highlighter shared/python/double_string region '"' (?<!\\)(\\\\)*" fill string +add-highlighter shared/python/single_string region "'" (?<!\\)(\\\\)*' fill string + # Integer formats add-highlighter shared/python/code/ regex '(?i)\b0b[01]+l?\b' 0:value add-highlighter shared/python/code/ regex '(?i)\b0x[\da-f]+l?\b' 0:value |
