From 981d82444e4722e7a1c0852e2b515876b2d64980 Mon Sep 17 00:00:00 2001 From: Thomas Vanbesien Date: Mon, 15 Jun 2026 18:55:04 +0200 Subject: misc(nvim): replace 50-git.lua with vim-fugitive --- .config/nvim/plugin/00-plugin.lua | 1 + .config/nvim/plugin/50-git.lua | 81 --------------------------------------- 2 files changed, 1 insertion(+), 81 deletions(-) delete mode 100644 .config/nvim/plugin/50-git.lua (limited to '.config') diff --git a/.config/nvim/plugin/00-plugin.lua b/.config/nvim/plugin/00-plugin.lua index 47588c4..def11c0 100644 --- a/.config/nvim/plugin/00-plugin.lua +++ b/.config/nvim/plugin/00-plugin.lua @@ -16,6 +16,7 @@ vim.pack.add({ "https://github.com/nvim-tree/nvim-web-devicons", "https://github.com/nvim-treesitter/nvim-treesitter", "https://github.com/qadzek/link.vim", + "https://github.com/tpope/vim-fugitive", "https://github.com/tpope/vim-surround", "https://github.com/windwp/nvim-autopairs", }) diff --git a/.config/nvim/plugin/50-git.lua b/.config/nvim/plugin/50-git.lua deleted file mode 100644 index 8bebef1..0000000 --- a/.config/nvim/plugin/50-git.lua +++ /dev/null @@ -1,81 +0,0 @@ --- --- Git-related utilities --- - -local function git_blame(file, line) - local sys = vim.system({ - vim.fn.stdpath("config") .. "/scripts/git_blame.bash", - tostring(line), - file, - }, { text = true }):wait() - if sys.stdout then - return vim.split(sys.stdout, "\n", { trimempty = true }) - 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 - -local git_blame_toggle = (function() - local win, auid, buf - - local function close() - if win and vim.api.nvim_win_is_valid(win) then - vim.api.nvim_win_close(win, true) - end - if buf and vim.api.nvim_buf_is_valid(buf) then - vim.api.nvim_buf_delete(buf, { force = true }) - end - win, auid, buf = nil, nil, nil - end - - return function() - if win and vim.api.nvim_win_is_valid(win) then - if auid then - vim.api.nvim_del_autocmd(auid) - end - vim.api.nvim_set_current_win(win) - -- Transient, self-cleaning (once): not part of the global dotfiles augroup. - vim.api.nvim_create_autocmd("BufLeave", { - once = true, - callback = close, - }) - return - end - - local text = git_blame(vim.api.nvim_buf_get_name(0), vim.api.nvim_win_get_cursor(0)[1]) - if not text then - return - end - - buf = vim.api.nvim_create_buf(false, true) - vim.api.nvim_buf_set_lines(buf, 0, -1, false, text) - win = vim.api.nvim_open_win(buf, false, { - relative = "cursor", - width = 50, - height = #text, - row = 0, - col = 0, - style = "minimal", - border = "rounded", - title = "git blame", - noautocmd = true, - }) - -- Transient, manually managed via auid/del_autocmd: not part of the global dotfiles augroup. - auid = vim.api.nvim_create_autocmd({ "CursorMoved", "CursorMovedI", "BufLeave" }, { - once = true, - callback = close, - }) - end -end)() - -vim.api.nvim_create_user_command( - "GitBlame", - git_blame_toggle, - { desc = "Open/enter git blame window" } -) - --- The original mappings from the plugin are broken -vim.keymap.set("n", "]c", "GitGutterNextHunk", { desc = "Next git hunk" }) -vim.keymap.set("n", "[c", "GitGutterPreviousHunk", { desc = "Next git hunk" }) -- cgit v1.3.1