gitsigns.nvim icon indicating copy to clipboard operation
gitsigns.nvim copied to clipboard

Add signs for staged hunks

Open hkupty opened this issue 3 years ago • 5 comments

Is your feature request related to a problem? Please describe. Thanks for the really awesome plugin. I'd like to suggest adding a new sign for a staged section. If I just staged that section, it is clear that only that section is added, but on a file, when adding multiple pieces of change into a single commit, it can be tricky to know what is included just by looking at the file

Describe the solution you'd like Another sign, just like add or change, but in a different color (say, cyan, purple...) that would visually indicate that it is staged.

Describe alternatives you've considered Didn't really think of an alternative. It could be either "let's go for it" or "no can do", just wanted to suggest it :)

Additional context Nope, just wanted to say thanks once again.

hkupty avatar Jan 11 '22 13:01 hkupty

This is something I've wanted to implement for a long time. I already attempted this in #303, but I found it quite difficult to handle all the intersections with different features. Though it is still planned to be implemented eventually.

Basically, #303 adds the ability for 'secondary signs' which can be signs for any comparison, including staged.

lewis6991 avatar Jan 11 '22 13:01 lewis6991

Just a thought, would it be possible to apply highlighting to staged regions maybe? Could imagine slightly changed background as a good indicator here.

gegoune avatar Jan 11 '22 14:01 gegoune

Yes, signs already allow this, we just need to implement adding signs for staged regions.

lewis6991 avatar Jan 11 '22 14:01 lewis6991

I imagine the issue might be if, for example, you change a line that contains something that is staged.

I might be completely wrong, but the way I understand this is that the sign column is a flattened projection of whatever happens in the text to the side. Then, there would be a priority between the statuses.

I'll try to demonstrate below.

  • x: Deleted
  • ~: Changed
  • *: Staged

Imagine there is some staged block

*   local x = {
* 
*     foo = function(a) return a + 1 end
*  }

But there's an error in the function and you fix it, while also cleaning some whitespace:

x   local x = {
~     foo = function(a) return a - 1 end
*  }

The fact that there is a staged block is lower in priority than the fact that there is a change in the line or a deletion. To link to @gegoune's comment. A slight background change in the staged area could show the whole block, even though it wouldn't represent the whole truth since a deleted line is present in the staged block, but not in the source code, but that should be obvious by the sign of a deleted line on the sign column.

I hope this makes some sense 😅

hkupty avatar Jan 12 '22 08:01 hkupty

Yes, signs already allow this

Wait so how do I highlight staged hunks? is there a DiffStaged highlight group?

Davincible avatar Jun 29 '22 18:06 Davincible