Skip to content

Commit 557e516

Browse files
committed
Add docstrings highlight
1 parent 5f3ce6a commit 557e516

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')
@@ -301,6 +302,17 @@ if s:Enabled('g:python_highlight_doctests')
301302
syn region pythonDocTest2 start='^\s*>>>' skip=+\\"+ end=+"""+he=s-1 end='^\s*$' contained
302303
endif
303304

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

496509
HiLink pythonDocTest Special
497510
HiLink pythonDocTest2 Special

0 commit comments

Comments
 (0)