diff options
| author | Thomas Vanbesien <tvanbesi@proton.me> | 2026-05-20 16:32:06 +0200 |
|---|---|---|
| committer | Thomas Vanbesien <tvanbesi@proton.me> | 2026-05-21 09:23:16 +0200 |
| commit | a7fb2b55fd014c4e3dbad3c75d757ddcec9b163b (patch) | |
| tree | 7368f2af3e7c78751284d72e34dba346482fa64d | |
| parent | 293865aeb7f6459d930f359b05a267ae9a85581e (diff) | |
| download | dotfiles-a7fb2b55fd014c4e3dbad3c75d757ddcec9b163b.tar.gz dotfiles-a7fb2b55fd014c4e3dbad3c75d757ddcec9b163b.zip | |
fix(nvim): git_blame() handles errors and output with vim.notify()
| -rw-r--r-- | .config/nvim/plugin/50-git.lua | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/.config/nvim/plugin/50-git.lua b/.config/nvim/plugin/50-git.lua index 247dfa3..ee5da46 100644 --- a/.config/nvim/plugin/50-git.lua +++ b/.config/nvim/plugin/50-git.lua @@ -1,7 +1,22 @@ +-- +-- Git-related utilities +-- + vim.pack.add({ "https://github.com/airblade/vim-gitgutter" }) -- Show git status in the gutter local function git_blame(file, line) - vim.cmd(string.format("!git blame --line-porcelain -L %d,%d -- %s", line, line, file)) + local sys = vim.system({ + "bash", + "-c", + string.format('grep -E "^author |^summary " <(git blame -L %d,%d --porcelain -- %s)', line, line, file), + }):wait() + if sys.stdout then + vim.notify(sys.stdout, vim.log.levels.INFO) + end + if sys.code ~= 0 then + local err_msg = "git blame failed (" .. sys.code .. ")\n" .. sys.stderr + vim.notify(err_msg, vim.log.levels.ERROR) + end end vim.api.nvim_create_user_command("GitBlame", function() |
