|
return {
|
|
"tpope/vim-fugitive",
|
|
dependencies = {
|
|
"shumphrey/fugitive-gitlab.vim",
|
|
},
|
|
config = function()
|
|
vim.opt.diffopt = vim.opt.diffopt + "vertical"
|
|
vim.opt.display = vim.opt.display + "lastline"
|
|
|
|
vim.api.nvim_set_keymap("n", "<leader>gl", ":GBrowse<CR>", { noremap = true })
|
|
vim.cmd([[ let g:fugitive_gitlab_domains = {"ssh://code.codium.com.au": "https://code.codium.com.au"} ]])
|
|
|
|
local function gitBlame(lines)
|
|
local current_file = vim.fn.expand('%:p')
|
|
local range = lines[1] .. "," .. lines[2]
|
|
local cmd = string.format("git -C %s blame -L %s %s | awk '{print $1}'", vim.fn.shellescape(vim.fn.fnamemodify(current_file, ':h')), range, vim.fn.fnamemodify(current_file, ':t'))
|
|
|
|
local handle = io.popen(cmd)
|
|
local result = handle:read("*a")
|
|
handle:close()
|
|
|
|
return result
|
|
end
|
|
|
|
vim.keymap.set('n', '<leader>gc', function ()
|
|
vim.cmd(string.format('Git show %s', gitBlame({vim.fn.line('.'), vim.fn.line('.')})))
|
|
end)
|
|
end,
|
|
}
|