Python syntax highlighting doom type Vim

I started working with doxygen to create documentation for my Python code. I use a doxypy filter to preprocess Python dockstrings. My goal is to have good syntax highlighting for doxygen comments in Python.

When writing my main page in a special .dox file, I found that doxygen comments can be highlighted in vim with the following command:

 set syntax=c.doxygen 

I tried the same command for Python but got nothing: set syntax = python.doxygen

I also did some searches and didn’t find anything interesting.

Here is a typical piece of code that I would like to highlight:

 class CompilationTab: """ The compilation tab of the verif GUI. It contains the layout description and the functions required to deal with specific behaviors of the tab """ def __init__(self, notebook, tab_name): """ The class constructor. @param notebook Notebook: The parent @c Notebook widget @param tab_name String: The display name of the tab """ 

Has anyone already fixed this issue? Thank you for your help!

+4
source share
1 answer

If you look at syntax/doxygen.vim , you can read in the preamble of the file, which is currently only

 cpp, c, idl, doxygen and php 
Supported files

.

Since doxygen.vim works a lot with the syn region command, I was looking for a string that defines a multi-line string in syntax/python.vim .

An interesting part of the team defining this area is

 syn region pythonString start=+[uU]\=\z('''\|"""\)+ end="\z1" keepend 

Derived from what is in doxygen.vim and above, you can add the following lines

 "delete the following line if you don't want to have enhanced colors let g:doxygen_enhanced_color=1 runtime! syntax/doxygen.vim syn region doxygenComment matchgroup=pythonString start=+[uU]\=\z('''\|"""\)+ end="\z1" contains=doxygenSyncStart,doxygenStart,doxygenTODO keepend fold containedin=pythonString 

before ~/.vim/after/syntax/python.vim or execute them manually.

In addition, you may need to manually adjust the colors of the added oxygen groups. At least I would do it, as the result obtained does not correspond to my taste.

Perhaps the fold argument to syn is of particular interest to you. If you set the foldmethod to syntax , you can add and expand multi-line comments. This seems useful if you can no longer look at these colors and don't be lazy to customize them :)


without oxygen evolution:

enter image description here

backlit doxygen and g:doxygen_enhanced_color == 1 :

enter image description here

+6
source

Source: https://habr.com/ru/post/1495895/


All Articles