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 | bcac2bd0172d53f38c203488f32925698a11b549 (patch) | |
| tree | 2c58cd4c729c2391e4798057677c2fb881f542d1 /plugin/50-git.lua | |
| parent | c05f6803c48b6d22e4b8b8437dfd922d34da3ebb (diff) | |
| download | nvim-config-bcac2bd0172d53f38c203488f32925698a11b549.tar.gz nvim-config-bcac2bd0172d53f38c203488f32925698a11b549.zip | |
fix(nvim): git_blame() handles errors and output with vim.notify()
Diffstat (limited to 'plugin/50-git.lua')
| -rw-r--r-- | plugin/50-git.lua | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/plugin/50-git.lua b/plugin/50-git.lua index 247dfa3..ee5da46 100644 --- a/plugin/50-git.lua +++ b/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() |
