Skip to content

feat: Inline Git Blame #13133

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

Open
wants to merge 25 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
29f4428
feat: Inline Git Blame
nik-rev Mar 18, 2025
647615d
perf: optimize obtaining blame for the same line
nik-rev Mar 24, 2025
07c69c1
fix: update blame when editing config
nik-rev Mar 24, 2025
8f0721f
use format! instead of preallocating
nik-rev Mar 24, 2025
f54fdef
refactor: remove extra layer of sync
nik-rev Mar 25, 2025
7478d9e
refactor: extract as variable
nik-rev Mar 25, 2025
76a92af
feat: `all-lines` option for inline blame
nik-rev Mar 25, 2025
ac0e677
chore: appease clippy
nik-rev Mar 25, 2025
d34074a
perf: do not render inline blame on invisible lines
nik-rev Mar 25, 2025
b9f8226
refactor: remove `new_config` from EditorConfigDidChange event
nik-rev Mar 25, 2025
22f9571
feat: split `inline-blame.behaviour` into two options
nik-rev Mar 25, 2025
a8097f1
perf: use `Vec<T>` instead of `HashMap<usize, T>`
nik-rev Mar 25, 2025
00d168a
fix: funny boolean inversion
nik-rev Mar 25, 2025
ab56638
refactor: render inline blame in a separate Editor function
nik-rev Mar 25, 2025
082ba4d
refactor: `match` over `if`
nik-rev Mar 25, 2025
c101f37
style: fmt
nik-rev Mar 25, 2025
b3b1c88
refactor: pass the `Style` instead of `Theme`
nik-rev Mar 25, 2025
af3b670
refactor: move expression
nik-rev Mar 25, 2025
95344a9
perf: use string preallocations for string concatenation
nik-rev Mar 29, 2025
1a0dad3
perf: only render inline blame for visible lines when `all-lines` is set
nik-rev Mar 30, 2025
e8d7e76
fix: spelling error
nik-rev Apr 1, 2025
c74fec4
fix?: do not block on the main thread when acquiring diff handle
nik-rev Apr 1, 2025
616758e
refactor: rename macro
nik-rev Apr 4, 2025
5d83e93
Merge branch 'master' into gix-blame
nik-rev Apr 16, 2025
03f0883
chore: fix merge conflicts
nik-rev Apr 16, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
111 changes: 78 additions & 33 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

45 changes: 45 additions & 0 deletions book/src/editor.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
- [`[editor.clipboard-provider]` Section](#editorclipboard-provider-section)
- [`[editor.statusline]` Section](#editorstatusline-section)
- [`[editor.lsp]` Section](#editorlsp-section)
- [`[editor.inline-blame]` Section](#editorinlineblame-section)
- [`[editor.cursor-shape]` Section](#editorcursor-shape-section)
- [`[editor.file-picker]` Section](#editorfile-picker-section)
- [`[editor.auto-pairs]` Section](#editorauto-pairs-section)
Expand Down Expand Up @@ -165,6 +166,50 @@ The following statusline elements can be configured:

[^2]: You may also have to activate them in the language server config for them to appear, not just in Helix. Inlay hints in Helix are still being improved on and may be a little bit laggy/janky under some circumstances. Please report any bugs you see so we can fix them!

### `[editor.inline-blame]` Section

Inline blame is virtual text that appears at the end of a line, displaying information about the most recent commit that affected this line.

| Key | Description | Default |
| ------- | ------------------------------------------ | ------- |
| `behaviour` | Choose when to show inline blame | `"hidden"` |
| `compute` | Choose when inline blame should be computed | `"on-demand"` |
| `format` | The format in which to show the inline blame | `"{author}, {time-ago} • {message} • {commit}"` |

The `behaviour` can be one of the following:
- `"all-lines"`: Inline blame is on every line.
- `"cursor-line"`: Inline blame is only on the line of the primary cursor.
- `"hidden"`: Inline blame is not shown.

Inline blame will only show if the blame for the file has already been computed.

The `compute` key determines under which circumstances the blame is computed, and can be one of the following:
- `"on-demand"`: Blame for the file is computed only when explicitly requested, such as when using `space + B` to blame the line of the cursor. There may be a little delay when loading the blame. When opening new files, even with `behaviour` not set to `"hidden"`, the inline blame won't show. It needs to be computed first in order to become available. This computation can be manually triggered by requesting it with `space + B`.
- `"background"`: Blame for the file is loaded in the background. This will have zero effect on performance of the Editor, but will use a little bit extra resources. Directly requesting the blame with `space + B` will be instant. Inline blame will show as soon as the blame is available when loading new files.

`inline-blame-format` allows customization of the blame message, and can be set to any string. Variables can be used like so: `{variable}`. These are the available variables:

- `author`: The author of the commit
- `date`: When the commit was made
- `time-ago`: How long ago the commit was made
- `message`: The message of the commit, excluding the body
- `body`: The body of the commit
- `commit`: The short hex SHA1 hash of the commit
- `email`: The email of the author of the commit

Any of the variables can potentially be empty.
In this case, the content before the variable will not be included in the string.
If the variable is at the beginning of the string, the content after the variable will not be included.

Some examples, using the default value `format` value:

- If `author` is empty: `"{time-ago} • {message} • {commit}"`
- If `time-ago` is empty: `"{author} • {message} • {commit}"`
- If `message` is empty: `"{author}, {time-ago} • {commit}"`
- If `commit` is empty: `"{author}, {time-ago} • {message}"`
- If `time-ago` and `message` is empty: `"{author} • {commit}"`
- If `author` and `message` is empty: `"{time-ago} • {commit}"`

### `[editor.cursor-shape]` Section

Defines the shape of cursor in each mode.
Expand Down
1 change: 1 addition & 0 deletions book/src/generated/static-cmd.md
Original file line number Diff line number Diff line change
Expand Up @@ -301,3 +301,4 @@
| `extend_to_word` | Extend to a two-character label | select: `` gw `` |
| `goto_next_tabstop` | goto next snippet placeholder | |
| `goto_prev_tabstop` | goto next snippet placeholder | |
| `blame_line` | Show blame for the current line | normal: `` <space>B ``, select: `` <space>B `` |
1 change: 1 addition & 0 deletions book/src/keymap.md
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,7 @@ This layer is a kludge of mappings, mostly pickers.
| `R` | Replace selections by clipboard contents | `replace_selections_with_clipboard` |
| `/` | Global search in workspace folder | `global_search` |
| `?` | Open command palette | `command_palette` |
| `B` | Show blame for the current line | `blame_line` |

> 💡 Global search displays results in a fuzzy picker, use `Space + '` to bring it back up after opening a file.

Expand Down
1 change: 1 addition & 0 deletions book/src/themes.md
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,7 @@ These scopes are used for theming the editor interface:
| `ui.virtual.inlay-hint.type` | Style for inlay hints of kind `type` (language servers are not required to set a kind) |
| `ui.virtual.wrap` | Soft-wrap indicator (see the [`editor.soft-wrap` config][editor-section]) |
| `ui.virtual.jump-label` | Style for virtual jump labels |
| `ui.virtual.inline-blame` | Inline blame indicator (see the [`editor.inline-blame` config][editor-section]) |
| `ui.menu` | Code and command completion menus |
| `ui.menu.selected` | Selected autocomplete item |
| `ui.menu.scroll` | `fg` sets thumb color, `bg` sets track color of scrollbar |
Expand Down
2 changes: 2 additions & 0 deletions helix-stdx/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,7 @@ pub mod faccess;
pub mod path;
pub mod range;
pub mod rope;
pub mod str;
pub mod time;

pub use range::Range;
Loading
Loading