-
Notifications
You must be signed in to change notification settings - Fork 6
git diff
Zeioth edited this page Dec 24, 2024
·
10 revisions
You can add this component to the statusline section of heirline opts.
require("heirline-components.all").component.git_diff()
You can see how this component look on the left of the next image: It displays the current changes of your git repository.
If you click this area, it will display the git diff
of every file.
These are the available providers for this component and its options.
added = { icon = { kind = "GitAdd", padding = { left = 1, right = 1 } } }, -- If set, displays icon+n of added lines.
changed = { icon = { kind = "GitChange", padding = { left = 1, right = 1 } }, }, -- If set, displays icon+n of changed lines.
removed = { icon = { kind = "GitDelete", padding = { left = 1, right = 1 } }, }, -- If set, displays icon+n of removed lines.
surround = {
separator = "left", -- where to add the separator.
color = "git_diff_bg", -- you can set a custom background color, for example "#444444".
condition = require("heirline-components.all").condition.git_changed -- a function that determines when to display the component.
},
hl = hl.get_attributes "git_diff", -- you can specify your own highlight group here.
on_click = { name = "<your_event_name", callback = function() end } -- what happens when you click the component.
update = { "User", pattern = "GitSignsUpdate" }, -- events that make the component refresh.
init = require("heirline-components.all").init.update_events { "BufEnter" }, -- what happens when the component starts.
For example you could explicitly pass the provider git_add to disable its icon.
component.git_diff({ git_add = { icon = false } })
Or disable that provider entirely
component.git_diff({ git_add = false })
This component won't display if you don't have one of the plugins: gitsigns, or mini.diff.