zed icon indicating copy to clipboard operation
zed copied to clipboard

Inline git blame

Open mrnugget opened this issue 1 year ago • 2 comments

This adds so-called "inline git blame" to the editor that, when turned on, shows git blame information about the current line inline:

screenshot-2024-04-12-15 26 43@2x

When the inline information is hovered, a new tooltip appears that contains more information on the current commit:

screenshot-2024-04-12-15 50 29@2x

The commit message in this tooltip is rendered as Markdown, is scrollable and clickable.

The tooltip is now also the tooltip used in the gutter:

screenshot-2024-04-12-15 51 24@2x

Settings

The inline git blame information can be turned on and off via settings:

{
  "git": {
    "inline_blame": "on"
  }
}

It can also be turned on/off for the current buffer with editor: toggle git blame inline.

To be done in follow-up PRs

  • [ ] Add link to pull request in tooltip
  • [ ] Add avatars of users if possible

Release notes

Release Notes:

  • Added inline git blame information the editor. It can be turned on in the settings with {"git": { "inline_blame": "on" } } for every buffer or, temporarily for the current buffer, with editor: toggle git blame inline.

mrnugget avatar Apr 11 '24 04:04 mrnugget

Great stuff. I don't want to disrupt anything you have going on here, but just posting a couple things I wonder about for the future:

  • I really like inline blame tooltips, but don't tend to want to see it when moving throughout the code. I see a mention of "enable/disable", but assume that means a global on/off switch. I wonder if it would be possible to have a command allowing a keybinding to be assigned to display the tooltip similar to g h for editor::Hover.
  • "Add link to PR to tooltip" - This would be amazing to have at some point. As an aside, this is wayyyy outside the scope of this PR, but would generally like to be able to visit links in tooltips via keyboard.

baldwindavid avatar Apr 11 '24 16:04 baldwindavid

Thanks, David!

  • I wonder if it would be possible to have a command allowing a keybinding to be assigned to display the tooltip similar to g h for editor::Hover.

Yeah, that's a great idea, and we talked about it before: a push-to-talk kinda thing where you hold a key combination down and while it's down it shows the inline blame or something like that.

But before we do that, maybe we need global setting and a toggle keybinding, yeah.

mrnugget avatar Apr 12 '24 04:04 mrnugget

This is cool, but is there a way to display it in the bottom toolbar (like VSCode). I pretty much never want to see it in the code itself.

Tenkir avatar Apr 26 '24 00:04 Tenkir

No, there isn't right now.

mrnugget avatar Apr 26 '24 07:04 mrnugget

All good, just wondering. I'd also be happy with the toggle hotkey baldwindavid mentioned above, so I'll throw a +1 behind that. As it is, it's too distracting so I just have it disabled. But I often want to know who wrote a function if I have questions about it, so it'd be super helpful to have a way to get this information on-demand.

Tenkir avatar Apr 26 '24 13:04 Tenkir

@Tenkir you're probably aware but, if not, a bit of a workaround is to use the editor: toggle git blame command to pop open the blame only as needed rather than using "inline" blame at all. I have a keybinding to open/close that quickly.

  {
    "context": "Editor && VimControl && !VimWaiting && !menu",
    "bindings": {
      "space g l": "editor::ToggleGitBlame"
    }
}

baldwindavid avatar Apr 26 '24 14:04 baldwindavid

Hey! what is the relevant styling config for this feature? In my editor it shows up as super white, but I can't narrow down which config would change it

jay-herrera avatar Jul 08 '24 22:07 jay-herrera

@jay-herrera it's using hint. You can override it like this:

{
  "experimental.theme_overrides": {
    "hint": "#fb4a35ff"
  }
}

mrnugget avatar Jul 09 '24 07:07 mrnugget