I would like to see beautiful syntax highlighting and coloring in my Python dokstels, which are (of course) valid RESt. For example:
'''
A section
=========
an example::
some code
'''
rest of python code
The closest I have is in my .vim/after/syntax/python.vim:
syn include syntax/rst.vim
syn region pythonDocstring start=+^\s*'''+ end=+'''+ contained
According to the include syntax documentation , which should be enough. Also note that rst.vimoverriding a bunch of python elements, so I had to comment out all sections related to the code:
" syn region rstCodeBlock contained matchgroup=rstDirective
" \ start=+\%(sourcecode\|code\%(-block\)\=\)::\_s*\n\ze\z(\s\+\)+
" \ skip=+^$+
" \ end=+^\z1\@!+
" \ contains=@NoSpell
" syn cluster rstDirectives add=rstCodeBlock
" if !exists('g:rst_syntax_code_list')
[...]
Finally, I cannot use !runtimeit because it rst.vimdoes nothing if the variable is b:current_syntaxalready defined:
if exists("b:current_syntax")
finish
endif
Despite my efforts, my docstring remains the same color as the other comments, without syntax highlighting.
I also tried this:
syn region pythonDocstring start=+^\s*'''+ end=+'''+ contains=CONTAINED
Special, Comment.
, , pythonDocstring ?
: python raw python.vim, , python.
Update
after/syntax/python.vim:
syn include @pythonRst syntax/rst.vim
syn region pythonDocstring start=+^\s*'''+ end=+'''+ contains=@pythonRst
RESt, .py:

.rst. , , ( , ):

, , colorscheme .vimrc