Skip to content

feat: colored/rainbow indentation guides#76

Merged
usagi-flow merged 3 commits intomainfrom
feat-colored-indent-guides
Apr 13, 2025
Merged

feat: colored/rainbow indentation guides#76
usagi-flow merged 3 commits intomainfrom
feat-colored-indent-guides

Conversation

@usagi-flow
Copy link
Copy Markdown
Owner

@usagi-flow usagi-flow commented Apr 13, 2025

Usage

This feature will be opt-in, i.e. disabled by default. Enable it in your config.toml as follows:

[editor.indent-guides]
render = true
rainbow-option = "normal"  # supports "normal", "dim", "none"

Theming

A theme can define a rainbow palette as follows (e.g. by referencing palette colors):

rainbow = ["red", "yellow", "green", "blue", "teal", "pink"]

If a theme does not define or inherit any rainbow palette, a standard color palette will be used.

In this PR the "catppuccin" themes define a custom rainbow palette.

Preview

catppuccin_macchiato:
image

catppuccin_latte:
image

image courtesy of the original PR author:
image

Known issues

Dimming does not work. If rainbow-option is set to dim, it will likely act as if set to normal.


This pull request introduces colored indentation guides, a.k.a. rainbow indentation guides.

This is helix-editor/helix#4493 (which in turn was a continuation of helix-editor/helix#4056), squashed and rebased, and with conflicts resolved.

Note

This makes considerable changes in the upstream implementation, and may never be merged upstream. We may have to refactor this implementation in the near future to avoid further conflicts.

Suggested in #42.

@usagi-flow usagi-flow force-pushed the feat-colored-indent-guides branch from 1d31b46 to 5e93dc6 Compare April 13, 2025 15:56
commit b5bf68129b56dc0178a61b7e22151decf82a25da
Merge: d1517c6a 207829e
Author: SoraTenshi <dream@neoncity.dev>
Date:   Thu May 25 19:53:22 2023 +0200

    Merge branch 'master' into colored-indent-guides

commit d1517c6a4b9b09609df03d984f4e890ec1998c26
Author: SoraTenshi <dream@neoncity.dev>
Date:   Sun Feb 12 22:18:41 2023 +0100

    Update to new TextRenderer

    Docs

    fmt

commit 7f47756b6d3d9119e1e426d7df48221d9019265c
Author: Michael Davis <mcarsondavis@gmail.com>
Date:   Mon Jul 11 19:10:57 2022 -0500

    Parse rainbow style array in themes

    This change adds a field to the schema of themes which takes a
    list of styles.

        rainbow = ["red", "orange", "yellow", { modifiers = ["reversed"] }]
        [palette]
        red = "#ff0000"
        orange = "#ffa500"
        yellow = "#fff000"

    Normal style rules apply for each element in `rainbows`: you can
    use definitions from the palette and the full fg/bg/modifiers
    notation.

    Themes written with `rainbow` keys are not backwards compatible.
    Parsing errors will be generated for older versions of Helix
    attempting to use themes with `rainbow` keys.

    A default rainbow is provided with base16 colors.

    This change is made with rainbow pair characters (parens, brackets, etc.)
    in mind but it could also be used for other rainbow cosmetic elements
    like rainbow indent-guides.
@usagi-flow usagi-flow force-pushed the feat-colored-indent-guides branch from 5e93dc6 to 2909a53 Compare April 13, 2025 17:38
@usagi-flow usagi-flow marked this pull request as ready for review April 13, 2025 18:12
@usagi-flow usagi-flow merged commit c2664a4 into main Apr 13, 2025
3 checks passed
@usagi-flow usagi-flow deleted the feat-colored-indent-guides branch April 20, 2025 19:42
usagi-flow added a commit that referenced this pull request Jul 31, 2025
* Squashed commit of the following:

commit b5bf68129b56dc0178a61b7e22151decf82a25da
Merge: d1517c6a 207829e
Author: SoraTenshi <dream@neoncity.dev>
Date:   Thu May 25 19:53:22 2023 +0200

    Merge branch 'master' into colored-indent-guides

commit d1517c6a4b9b09609df03d984f4e890ec1998c26
Author: SoraTenshi <dream@neoncity.dev>
Date:   Sun Feb 12 22:18:41 2023 +0100

    Update to new TextRenderer

    Docs

    fmt

commit 7f47756b6d3d9119e1e426d7df48221d9019265c
Author: Michael Davis <mcarsondavis@gmail.com>
Date:   Mon Jul 11 19:10:57 2022 -0500

    Parse rainbow style array in themes

    This change adds a field to the schema of themes which takes a
    list of styles.

        rainbow = ["red", "orange", "yellow", { modifiers = ["reversed"] }]
        [palette]
        red = "#ff0000"
        orange = "#ffa500"
        yellow = "#fff000"

    Normal style rules apply for each element in `rainbows`: you can
    use definitions from the palette and the full fg/bg/modifiers
    notation.

    Themes written with `rainbow` keys are not backwards compatible.
    Parsing errors will be generated for older versions of Helix
    attempting to use themes with `rainbow` keys.

    A default rainbow is provided with base16 colors.

    This change is made with rainbow pair characters (parens, brackets, etc.)
    in mind but it could also be used for other rainbow cosmetic elements
    like rainbow indent-guides.

* fix: avoid panic, properly set rainbow_length when loading theme

* feat: define a rainbow palette for the catppuccin themes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant