[mini.git] Show short commit hash when in detached HEAD #2002
-
Contributing guidelines
Module(s)mini.git QuestionHi, I'm currently cutting down on my plugins. Besides moving what I can to mini I'm also creating my own statusbar, which is basically the nvim default one but with extra git information. From what it seems, Do you have an idea how I can achieve this? I know gitsigns does this by default, but it would be great if I could do this with mini instead. This is what I currently have and it half works. But doing a vim.api.nvim_create_autocmd('User', {
pattern = "MiniGitUpdated",
callback = function(data)
local summary = vim.b[data.buf].minigit_summary
if summary.head_name == "HEAD" then
vim.cmd([[Git rev-parse --short HEAD]])
end
end
})
vim.api.nvim_create_autocmd('User', {
pattern = "MiniGitCommandDone",
callback = function(data)
-- react on `:Git rev-parse`
if data.data.git_subcommand == "rev-parse" then
vim.b[data.buf].minigit_summary_string = data.data.stdout
end
end,
}) PS: To the reason for preferring the git hash over I feel it gives me more information on where I am in my git tree. E.g if I'm backtracing commits for some faulty change and have my history open in a second window (github), I can map in my head what I see in the current buffer to the list I have open. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Yes, it is documented.
Yes, explicitly trimming full commit hash is the suggested approach and it is what is done for
The main reason the |
Beta Was this translation helpful? Give feedback.
Yes, it is documented.
Yes, explicitly trimming full commit hash is the suggested approach and it is what is done for
minigit_summary_string
. If you feel like 10 characters is needed, then always trimming to 10 characters doesn't seem like a big problem.