Skip to content

Commit ef78f29

Browse files
committed
Add docstrings highlight
1 parent e58383c commit ef78f29

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

syntax/python.vim

+13
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ if s:Enabled('g:python_highlight_all')
4545
call s:EnableByDefault('g:python_highlight_string_formatting')
4646
call s:EnableByDefault('g:python_highlight_string_format')
4747
call s:EnableByDefault('g:python_highlight_string_templates')
48+
call s:EnableByDefault('g:python_highlight_string_doc')
4849
call s:EnableByDefault('g:python_highlight_indent_errors')
4950
call s:EnableByDefault('g:python_highlight_space_errors')
5051
call s:EnableByDefault('g:python_highlight_doctests')
@@ -302,6 +303,17 @@ if s:Enabled('g:python_highlight_doctests')
302303
syn region pythonDocTest2 start='^\s*>>>' skip=+\\"+ end=+"""+he=s-1 end='^\s*$' contained
303304
endif
304305

306+
if s:Enabled('g:python_highlight_string_doc')
307+
syn match pythonColon ':' nextgroup=pythonDocString skipempty
308+
syn match pythonStartFile +\%^+ nextgroup=pythonDocString skipempty
309+
syn region pythonDocString start=+^\s*[rRfFbB]\='''+ skip=+\\'+ end=+'''+ keepend contains=pythonBytesEscape,pythonBytesEscapeError,pythonUniEscape,pythonUniEscapeError,pythonDocTest,pythonSpaceError,@Spell
310+
syn region pythonDocString start=+^\s*[rRfFbB]\="""+ skip=+\\"+ end=+"""+ keepend contains=pythonBytesEscape,pythonBytesEscapeError,pythonUniEscape,pythonUniEscapeError,pythonDocTest2,pythonSpaceError,@Spell
311+
syn region pythonString start=+^\s*[rRfFbB]\='''+ skip=+\\'+ end=+'''+ keepend contains=pythonBytesEscape,pythonBytesEscapeError,pythonUniEscape,pythonUniEscapeError,pythonDocTest,pythonSpaceError,@Spell
312+
syn region pythonString start=+^\s*[rRfFbB]\="""+ skip=+\\"+ end=+"""+ keepend contains=pythonBytesEscape,pythonBytesEscapeError,pythonUniEscape,pythonUniEscapeError,pythonDocTest2,pythonSpaceError,@Spell
313+
syn region pythonDocString start=+\%^\s*[rRfFbB]\='''+ skip=+\\'+ end=+'''+ keepend contains=pythonBytesEscape,pythonBytesEscapeError,pythonUniEscape,pythonUniEscapeError,pythonDocTest,pythonSpaceError,@Spell
314+
syn region pythonDocString start=+\%^\s*[rRfFbB]\="""+ skip=+\\"+ end=+"""+ keepend contains=pythonBytesEscape,pythonBytesEscapeError,pythonUniEscape,pythonUniEscapeError,pythonDocTest2,pythonSpaceError,@Spell
315+
endif
316+
305317
"
306318
" Numbers (ints, longs, floats, complex)
307319
"
@@ -493,6 +505,7 @@ if v:version >= 508 || !exists('did_python_syn_inits')
493505
HiLink pythonStrFormatting Special
494506
HiLink pythonStrFormat Special
495507
HiLink pythonStrTemplate Special
508+
HiLink pythonDocString Comment
496509

497510
HiLink pythonDocTest Special
498511
HiLink pythonDocTest2 Special

0 commit comments

Comments
 (0)