Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: hide_separator option for powerline; new theme: powerlevel10k_rainbow #697

Closed
wants to merge 2 commits into from

Conversation

uruz-7
Copy link
Contributor

@uruz-7 uruz-7 commented May 3, 2021

Prerequisites

  • I have read and understand the CONTRIBUTING guide
  • The commit message follows the conventional commits guidelines
  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been added / updated (for bug fixes / features)

Description

I wanted an option that could hide the separator between a powerline segment and others, so I could make a powerlevel10k rainbow style based on the fascinating jandedobbeleer theme.

theme: powerlevel10k_rainbow.omp
@JanDeDobbeleer
Copy link
Owner

@uruz-7 can you give me a screenshot the result? Maybe we can go about this another way (or not).

@uruz-7
Copy link
Contributor Author

uruz-7 commented May 3, 2021

@uruz-7 can you give me a screenshot the result? Maybe we can go about this another way (or not).

The result is like this.

image

What issues is that by default, a separator will be rendered between diamond and powerline 1(or 4), which I personally didn't want.

I have tried to change powerline 1 and 2 to diamond with customized color leading and trailing diamonds, but the git segment will change color, so the color of the separator between 1 and 2 must be adaptive => powerline seems to be a better choice.

image

Anyway, I'll appreciate it if there is a better way,.

@JanDeDobbeleer
Copy link
Owner

It looks so pretty. Let me check if we can fix this without an additional property 👍🏻

@JanDeDobbeleer
Copy link
Owner

@uruz-7 if I do the following change I get the same result by leaving either trailing or leading diamond empty:

diff --git a/src/block.go b/src/block.go
index d6f2f5c7..d6e444a0 100644
--- a/src/block.go
+++ b/src/block.go
@@ -89,9 +89,10 @@ func (b *Block) renderSegments() string {
 }

 func (b *Block) endPowerline() {
-   if b.activeSegment != nil &&
-       b.activeSegment.Style != Powerline &&
-       b.previousActiveSegment != nil &&
+   if b.previousActiveSegment == nil || b.activeSegment == nil {
+       return
+   }
+   if b.activeSegment.Style != Powerline &&
        b.previousActiveSegment.Style == Powerline {
        b.writePowerLineSeparator(b.getPowerlineColor(false), b.previousActiveSegment.background(), true)
    }
@@ -113,6 +114,12 @@ func (b *Block) getPowerlineColor(foreground bool) string {
    if b.previousActiveSegment == nil {
        return Transparent
    }
+   if b.previousActiveSegment.Style == Diamond && len(b.previousActiveSegment.TrailingDiamond) == 0 {
+       return b.previousActiveSegment.background()
+   }
+   if b.activeSegment.Style == Diamond && len(b.activeSegment.LeadingDiamond) == 0 {
+       return b.activeSegment.background()
+   }
    if !foreground && b.activeSegment.Style != Powerline {
        return Transparent
    }

JanDeDobbeleer added a commit that referenced this pull request May 4, 2021
@uruz-7
Copy link
Contributor Author

uruz-7 commented May 4, 2021

Wonderful job! Let me check it!

@uruz-7
Copy link
Contributor Author

uruz-7 commented May 4, 2021

@JanDeDobbeleer This worked perfect for my case. Thanks!

And it influenced some other themes which could be fixed easily in #700.

This PR could be closed :)

(Please just ignore my mistake in branching above.)

@uruz-7 uruz-7 closed this May 4, 2021
JanDeDobbeleer added a commit that referenced this pull request May 4, 2021
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.

None yet

2 participants