Skip to content

Commit 907ec01

Browse files
committed
Added support for string.Template syntax
1 parent 780c6ef commit 907ec01

File tree

3 files changed

+20
-2
lines changed

3 files changed

+20
-2
lines changed

CHANGES.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ Revision 2.6.1 (unknown):
99
- Added option "python_print_as_function" for highlight "print" as a
1010
function;
1111
- Added support for new integer literal syntax "0o" and "0b";
12+
- Added support for string.Template syntax controlled by
13+
"python_highlight_string_templates" option;
1214

1315
Revision 2.5.6 (2007-02-04):
1416

TODO.txt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
1-
- Highligh for string.Template?
1+
Now
2+
===
23

34
- Python 3.0 string formatting
45

6+
Later
7+
=====
8+
59
- Highligh errors where symbols follow by numbers like this: 0o123LaB
610

711
- Need more accurate way to handle indentation errors. For example

python.vim

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
" Thanks:
1414
"
1515
" Jeroen Ruigrok van der Werven
16-
" for the idea of highlighting for erroneous operators
16+
" for the idea to highlight erroneous operators
1717
" Pedro Algarvio
1818
" for the patch to enable spell checking only for the right spots
1919
" (strings and comments)
@@ -37,6 +37,9 @@
3737
" For highlight string formatting:
3838
" python_highlight_string_formatting
3939
"
40+
" For highlight string.Template templates:
41+
" python_highlight_string_templates
42+
"
4043
" For highlight indentation errors:
4144
" python_highlight_indent_errors
4245
"
@@ -75,6 +78,9 @@ if exists("python_highlight_all") && python_highlight_all != 0
7578
if !exists("python_highlight_string_formatting")
7679
let python_highlight_string_formatting = 1
7780
endif
81+
if !exists("python_highlight_string_templates")
82+
let python_highlight_string_templates = 1
83+
endif
7884
if !exists("python_highlight_indent_errors")
7985
let python_highlight_indent_errors = 1
8086
endif
@@ -180,6 +186,11 @@ if exists("python_highlight_string_formatting") && python_highlight_string_forma
180186
syn match pythonStrFormat "%[-#0 +]*\(\*\|\d\+\)\=\(\.\(\*\|\d\+\)\)\=[hlL]\=[diouxXeEfFgGcrs%]" contained containedin=pythonString,pythonUniString,pythonRawString,pythonUniRawString
181187
endif
182188

189+
if exists("python_highlight_string_templates") && python_highlight_string_templates != 0
190+
" String templates
191+
syn match pythonStrTemplate "\$\(\$\|{[^}]*}\|[a-zA-Z_][a-zA-Z0-9_]*\)" contained containedin=pythonString,pythonUniString,pythonRawString,pythonUniRawString
192+
endif
193+
183194
if exists("python_highlight_doctests") && python_highlight_doctests != 0
184195
" DocTests
185196
syn region pythonDocTest start="^\s*>>>" end=+'''+he=s-1 end="^\s*$" contained
@@ -301,6 +312,7 @@ if version >= 508 || !exists("did_python_syn_inits")
301312
HiLink pythonUniRawEscapeError Error
302313

303314
HiLink pythonStrFormat Special
315+
HiLink pythonStrTemplate Special
304316

305317
HiLink pythonDocTest Special
306318
HiLink pythonDocTest2 Special

0 commit comments

Comments
 (0)