zed icon indicating copy to clipboard operation
zed copied to clipboard

Allow Git blame to be customizable

Open hshreekar opened this issue 2 months ago • 7 comments

Check for existing issues

  • [X] Completed

Describe the feature

The default git blame takes up too much space (in my opinion). Allow the user to change the behaviour of git blame, allowing users to choose what entry he wishes to see (The full information may still be seen by hovering and clicking on it ). This may also allow users to configure the author width as seen in issue #10631.

If applicable, add mockups / screenshots to help present your vision of the feature

No response

hshreekar avatar Apr 19 '24 11:04 hshreekar

I am willing to submit a PR for this, incase this makes sense and someone who could guide me

fields i am thinking would make sense are ,

show_author: bool, 
show_relative_timestamp: bool or could be an enum of "None", "abbreviated", "full", (abbreviated would show 2 wks instead of 2 weeks ago)
show_commit_id: bool,
author_style: an enum containing ("dynamic", "fixed_width") (maybe with a better name ),
color_author_by_commit: bool  (add a  filled circle after the author name coloured by commit id), 
dock: enum of right or left

hshreekar avatar Apr 19 '24 11:04 hshreekar

Do you mean the inline git blame or the git blame in the gutter?

mrnugget avatar Apr 19 '24 13:04 mrnugget

Git Blame in the Gutter

hshreekar avatar Apr 19 '24 13:04 hshreekar

One thing that might help with the width of the git blame gutter is dynamically computing what is needed:

  • https://github.com/zed-industries/zed/issues/10631#issuecomment-2059553516

JosephTLyons avatar Apr 19 '24 18:04 JosephTLyons

Yes that would help with the width of the git blame , I only skimmed through the git blame code portion but I believe we can add a field for max_author_len in the blame struct or have a field called authors which would be vec<string> and compute the max length just before rendering the elements. I would prefer the authors field just because we could maybe reuse the blame entries to implement specialized file searches ( something like search for files edited by a particular author) although maybe it's too compute intensive

I still believe we can maybe make the info in git blame gutter more dense like not showing commit id or just replacing the string with a custom colour filled circle (my preference) or colour the line number by the commit id (might look ugly, also some users might not have enabled line numbers )

However I do believe that if most of the users of zed are fine with the current method, only the author width can be adjusted.

hshreekar avatar Apr 19 '24 19:04 hshreekar

One nice option would be to put commit, author and date on separate lines when possible and have a colored bar on one side to indicate which lines are part of the same blame chunk.

The GitHub blame view actually does this last bit so should be a good reference.

jansol avatar Apr 20 '24 16:04 jansol

One nice option would be to put commit, author and date on separate lines when possible and have a colored bar on one side to indicate which lines are part of the same blame chunk.

That's actually not that simple, since right now we "simply" draw next to the editor line. If you have multiple blame-lines you also need to space out the editor lines, which (I think) is not as easy as making the format of the blame lines configurable.

mrnugget avatar Apr 22 '24 07:04 mrnugget

Hi! @mrnugget, Would it be possible to add a template to inline blame?

%ic - icon commit
%ca - committer avatar
%cn - committer name
%ce - committer email
%cr - committer date, relative
%cs - committer date, short format (YYYY-MM-DD)
...

Link pretty format: https://git-scm.com/docs/pretty-formats#Documentation/pretty-formats.txt-emHem

"inline_blame": {
      "enabled": true,
       "template": "%ca %cn, %cr <%ce>" //"%ic %cn, %cr" default
      // Sets a delay after which the inline blame information is shown.
      // Delay is restarted with every cursor movement.
      // "delay_ms": 600
}

Angelk90 avatar Apr 29 '24 18:04 Angelk90