vscode-zig icon indicating copy to clipboard operation
vscode-zig copied to clipboard

color doc comments differently than normal comments

Open andrewrk opened this issue 6 years ago • 1 comments

// normal comment
fn foo() void {}

/// doc comment
fn foo() void {}

It helps to show that they will be parsed differently.

andrewrk avatar Jul 15 '19 21:07 andrewrk

As far as I can find, this isn't controlled by the extension. Syntax highlighters return only a small set of token types to the theme to colour (eg: functions, keywords, strings, comments, etc...)

Single line comments, block comments, docstring, etc... all get injected as "comments" and get themed with the same color. Therefore, I don't think this feature is possible.

However, I have found a workaround. You can override themes in your user settings. In the extension doc comments are specified with the scope comment.line.documentation which you can override with your own color. For example:

"editor.tokenColorCustomizations": {
    "textMateRules": [
        {
            "scope": "comment.line.documentation.zig",
            "settings": {
                "foreground": "#ffd650"
            }
        }
    ],
}

Swoogan avatar Dec 31 '19 18:12 Swoogan

This isn't within the scope of this extension.

It's very common for color theme extensions to handle this for the user, emitting normal comments as one color and doc comments in another. For example, I maintain a color theme extension and I do this. It's extremely trivial to implement and improves developer experience.

All information needed to customize the token colors based on whether it is a doc comment or regular comment is being emitted. Users and extensions can customize the colors used, and @Swoogan posted the "fix" 4 years ago.

Since there has been no activity since, I think this issue could probably be closed.

ellacrity avatar Sep 23 '23 04:09 ellacrity