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

neovim: fix SignColumn transparency #628

Merged
merged 2 commits into from
Feb 10, 2025

Conversation

soulsoiledit
Copy link
Contributor

Closes #599 .

This does not fully resolve the issue with SignColumn being not transparent, as that behavior is dependent on the option cursorline, as they change the highlight groups used for the sign column. In addition, LineNr is also not transparent and is dependent on both cursorline and relativenumber. I think these issues are to be best resolved later on by #249 by relying on the respective vim highlight groups.

Regardless, this change does fix SignColumn when neither of those options are set.

Copy link
Collaborator

@trueNAHO trueNAHO left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I verified that this PR builds in all cases:

Tested-by: NAHO <[email protected]>

However, since my setup causes weird colors (regardless of this PR) when enabling these options, I am unsure how valuable my testing is.

@anotherhadi, can you verify and approve whether this PR closes your issue #599?

@anotherhadi
Copy link

@anotherhadi, can you verify and approve whether this PR closes your issue #599?

It does not, however I didn't enabled cursorline.

In addition, LineNr is also not transparent and is dependent on both cursorline and relativenumber.

@soulsoiledit
Copy link
Contributor Author

I did not change anything involving LineNr currently, so that makes sense. Is SignColumn itself transparent though?

@anotherhadi
Copy link

anotherhadi commented Nov 18, 2024

Is SignColumn itself transparent though?

No

2024-11-18_13:30:19

Here are my related settings:
On commit 118e064

programs.stylix = {
    targets.nixvim.transparentBackground = {
      main = true;
      signColumn = true;
    };
    targets.nixvim.plugin = "base16-nvim";
};

programs.nixvim.opts = {
    signcolumn = "yes";
    cursorline = false;
    number = true;
    relativenumber = true;
};

@soulsoiledit
Copy link
Contributor Author

soulsoiledit commented Nov 20, 2024

That's quite strange, these are my results with mini and base16. Could you post your init.lua?

image

image

@soulsoiledit soulsoiledit force-pushed the signcolumn-fix branch 3 times, most recently from ae1afef to f1bc08b Compare February 7, 2025 04:42
@soulsoiledit
Copy link
Contributor Author

I added the correct placement for the highlights for Neovim. After testing the changes with vim :sign on the configuration provided, transparency seems to work across both Neovim/Nixvim and either colorscheme plugin. It would be helpful for another look at this, as I'm not sure why the Nixvim-only changes did not work for @anotherhadi.

Neovim configuration:

programs.neovim = {
  enable = true;
  extraConfig = "set signcolumn=yes number relativenumber nocursorline";
};

stylix.targets.neovim = {
  enable = true;
  # plugin = "mini.base16";
  # plugin = "base16-nvim";
  transparentBackground = {
    main = true;
    signColumn = true;
  };
};

Nixvim configuration:

programs.nixvim = {
  enable = true;
  opts = {
    signcolumn = "yes";
    number = true;
    relativenumber = true;
    cursorline = false;
  };
};

stylix.targets.nixvim = {
  enable = true;
  # plugin = "mini.base16";
  plugin = "base16-nvim";
  transparentBackground = {
    main = true;
    signColumn = true;
  };
};

Terminal:

programs.foot.settings.colors.alpha = 0.75;

Moves highlights towards the end of the generated config, preventing the
colorscheme plugins from overwriting them
Moves highlights to the end of plugin configuration, preventing the
colorscheme from overwriting them
@trueNAHO
Copy link
Collaborator

trueNAHO commented Feb 9, 2025

I am testing this PR on NixVim with the following patch:

diff --git a/flake.lock b/flake.lock
index c494c960..e195e27b 100644
--- a/flake.lock
+++ b/flake.lock
@@ -594,15 +594,16 @@
         "tinted-zed": "tinted-zed"
       },
       "locked": {
-        "lastModified": 1738610773,
-        "narHash": "sha256-rgX4VzzX9E/9YOYoIJHq6u/jlmlLxrtZrhAVU1qboXU=",
-        "owner": "danth",
+        "lastModified": 1738903984,
+        "narHash": "sha256-a03hzw+i8PYbs4Lc6r8r76OkJ05OXg4pHfGUylk+2YM=",
+        "owner": "soulsoiledit",
         "repo": "stylix",
-        "rev": "596d6644077d6d25ff713e93b55efc867979959d",
+        "rev": "af074786c1c0b1f0bd236885bf46d39980d8e2dd",
         "type": "github"
       },
       "original": {
-        "owner": "danth",
+        "owner": "soulsoiledit",
+        "ref": "signcolumn-fix",
         "repo": "stylix",
         "type": "github"
       }
diff --git a/flake.nix b/flake.nix
index a19bf1b5..5b130364 100644
--- a/flake.nix
+++ b/flake.nix
@@ -131,7 +131,7 @@
         systems.follows = "systems";
       };

-      url = "github:danth/stylix";
+      url = "github:soulsoiledit/stylix/signcolumn-fix";
     };

     systems.url = "github:nix-systems/default";
diff --git a/modules/inputs/nixvim/programs/nixvim/default.nix b/modules/inputs/nixvim/programs/nixvim/default.nix
index 2b9a4a33..9626119c 100644
--- a/modules/inputs/nixvim/programs/nixvim/default.nix
+++ b/modules/inputs/nixvim/programs/nixvim/default.nix
@@ -39,9 +39,21 @@

       home.shellAliases.n = lib.getExe config.programs.nixvim.build.package;

+      programs.foot = {
+        enable = true;
+        settings.colors.alpha = lib.mkForce 0.75;
+      };
+
       programs.nixvim = {
         enable = true;

+        opts = {
+          cursorline = lib.mkForce false;
+          number = true;
+          relativenumber = true;
+          signcolumn = "yes";
+        };
+
         globals = let
           leader = " ";
         in {
diff --git a/modules/inputs/stylix/default.nix b/modules/inputs/stylix/default.nix
index a846fb8a..2823785a 100644
--- a/modules/inputs/stylix/default.nix
+++ b/modules/inputs/stylix/default.nix
@@ -54,6 +54,16 @@
       };

       polarity = "dark";
+
+      targets.nixvim = {
+        enable = true;
+        plugin = "base16-nvim";
+
+        transparentBackground = {
+          main = true;
+          signColumn = true;
+        };
+      };
     };
   };
 }

I assume this is the intended behaviour:

image

@soulsoiledit
Copy link
Contributor Author

soulsoiledit commented Feb 9, 2025

If that is gitsigns, it looks correct. gitsigns does derive colors from the rest of your theme (not including SignColumn!), so anyone wishing to remove the extra opaque part to the right will need to modify GitSignsAdd, GitSignsChange, etc..

Copy link
Collaborator

@trueNAHO trueNAHO left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If that is gitsigns, it looks correct.

Let's wait on @anotherhadi's reply before merging this.

@anotherhadi
Copy link

Works now, ty!

@trueNAHO trueNAHO merged commit 7f0154c into danth:master Feb 10, 2025
49 checks passed
@soulsoiledit soulsoiledit deleted the signcolumn-fix branch February 10, 2025 18:58
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.

[BUG] SignColumn not transparent
3 participants