Kakoune: Change the default face for Python docstring from string to comment.

Created on 29 Oct 2020  路  4Comments  路  Source: mawww/kakoune

Docstring in Python files uses string face as the default one. I think it is bad idea. When you have both strings and docstrings on the display they blends together.
Example:
image

After potential change to comment.
image

feature request

Most helpful comment

I advised that change in the PR that introduces the documentation face.

Triple strings could be highlighted as documentation if they are not assigned to a variable, e.g. ^\h*"{3}\b.

All 4 comments

As you might know the other main use case of triple quotes is to define strings than can contain newlines:

my_long_string = """This is a multi-line string,
where this is the second line
    then you can even have indented lines like this one.
"""
print(my_long_string)
print("""Another one with a newline at the end.
""")

Is there a reliable and robust way to detect whether a triple-quoted string is a docstring or a regular string? Vim also seems to not make this distinction. This change would be good for docstrings as long as we can reliably detect which one it is.

I advised that change in the PR that introduces the documentation face.

Triple strings could be highlighted as documentation if they are not assigned to a variable, e.g. ^\h*"{3}\b.

I was trying to fix this. However, I do not understand what is the meaning of (?<!\\)(?:\\\\)* within

add-highlighter shared/python/docstring  region -match-capture ("""|''') (?<!\\)(?:\\\\)*("""|''') regions

This bit makes sure that the closing quote is not escaped.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

abitofalchemy picture abitofalchemy  路  3Comments

a12l picture a12l  路  3Comments

1g0rb0hm picture 1g0rb0hm  路  3Comments

lenormf picture lenormf  路  3Comments

alexherbo2 picture alexherbo2  路  4Comments