Python: allow Docstring coloring different than other "strings"
Check for existing issues
- [X] Completed
Describe the feature
This is request to enable different Docstring coloring vs. other "strings". I say strings, because currently ZED does not differentiate between any regular string definition and Docstring. I would rather expect Docstring to be recognized to similar coloring as in-line comments or perfectly a separate color block.
If applicable, add mockups / screenshots to help present your vision of the feature
Current status of Docstring coloring: see attached screenshot. Notice log string statement has the same color as the """ Docstring text. IMHO, those two should definitely have separate colors. Notice also coloring of the in-line comment. I would sooner expect Docstring to have similar coloring to the comment text.
What I would perfectly want to achieve:
I'd argue that docstrings should be considered doc comments for the purpose of syntax highlighting
This is fine, all I care about is ability to specify diff color between those two.
Reference to similar ticket: https://github.com/zed-industries/zed/issues/4296
I specifically mentioned that because the user themes that landed in preview builds last week do have separate styles for "comment" and "comment.doc". So this would just be a matter of making the tree sitter definition categorize the doc strings correctly.
Yeah, I've seen it.
Needless to say it is not clear to me what comment.doc does affect. At least on python level I do not see it affecting code or any comments in any way. Thanks though for reiterating this.
I took a stab at this in https://github.com/zed-industries/zed/pull/7585 and was able to get it working.
However, after a bit of further investigation, it seems that treating docstrings as comments/doc comments from a syntax highlighting perspective is a bit of a contentious topic, and both GitHub and VS Code seem to fall on the side of treating them as strings.
While I don't think treating docstrings as comments by default is the right choice, it does seem like a desirable feature to be able to style them separately, should you want to.
I ended up introducing a new string.doc syntax node for docstrings in https://github.com/zed-industries/zed/pull/7587.
By default, Python docstrings will be displayed using the string styles, but if you add a string.doc in your theme it will take precedence and allow you to style docstrings separately from strings.
Thank you for taking care of this. And yes, this is what I had in mind. Can't wait to test it out with next release 🙏
Is this live? I don’t see mt obe able to get it to work.