zed-industries / zed

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
https://zed.dev
Other
39.42k stars 2.05k forks source link

Allow Git blame to be customizable #10771

Open hshreekar opened 2 months ago

hshreekar commented 2 months ago

Check for existing issues

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 commented 2 months ago

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
mrnugget commented 2 months ago

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

hshreekar commented 2 months ago

Git Blame in the Gutter

JosephTLyons commented 2 months ago

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

hshreekar commented 2 months ago

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.

jansol commented 2 months ago

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.

mrnugget commented 2 months ago

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.

Angelk90 commented 2 months ago

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
}