2022-09-28 12:04:05 +02:00
|
|
|
local map = require('my.functions').map
|
|
|
|
|
|
|
|
local neogit = require('neogit')
|
|
|
|
neogit.setup {
|
|
|
|
disable_commit_confirmation = true,
|
|
|
|
kind = 'tab',
|
|
|
|
integrations = {
|
|
|
|
diffview = true
|
|
|
|
},
|
|
|
|
disable_insert_on_commit = false
|
|
|
|
}
|
|
|
|
map('n', '<Leader>gg', neogit.open, 'Open Neogit')
|
|
|
|
|
2022-09-28 12:54:17 +02:00
|
|
|
local gitgroup = vim.api.nvim_create_augroup('config_git', { clear = true })
|
2022-09-29 23:03:20 +02:00
|
|
|
-- enable spell checking
|
|
|
|
vim.api.nvim_create_autocmd({ 'FileType' }, {
|
|
|
|
group = gitgroup,
|
|
|
|
pattern = { 'gitcommit' },
|
|
|
|
command = [[setlocal spell]]
|
|
|
|
})
|
|
|
|
|
|
|
|
-- start git commits in insert mode
|
2022-09-28 12:04:05 +02:00
|
|
|
vim.api.nvim_create_autocmd({ 'FileType' }, {
|
|
|
|
group = gitgroup,
|
|
|
|
pattern = { 'gitcommit', 'gitrebase' },
|
|
|
|
command = [[startinsert | 1]]
|
|
|
|
})
|
|
|
|
|
|
|
|
-- split Neogit commit messages vertically if possible
|
|
|
|
vim.api.nvim_create_autocmd({ 'FileType' }, {
|
|
|
|
group = gitgroup,
|
|
|
|
pattern = { 'NeogitCommitMessage' },
|
|
|
|
callback = require('autosplit')
|
|
|
|
})
|
|
|
|
|
|
|
|
-- don't show dots for spaces in Neogit buffers
|
|
|
|
vim.api.nvim_create_autocmd({ 'FileType' }, {
|
|
|
|
group = gitgroup,
|
|
|
|
pattern = { 'Neogit*' },
|
|
|
|
command = [[set nolist]]
|
|
|
|
})
|
|
|
|
|
|
|
|
require('gitsigns').setup({
|
|
|
|
on_attach = function(bufnr)
|
|
|
|
local gs = package.loaded.gitsigns
|
|
|
|
|
|
|
|
map('n', '<Leader>gb', function() gs.blame_line({ full = true }) end,
|
|
|
|
'Show blame for current line', bufnr)
|
|
|
|
end
|
|
|
|
})
|
|
|
|
|
|
|
|
require('gitlinker').setup({
|
|
|
|
callbacks = {
|
|
|
|
['schlomp.space'] = require('gitlinker.hosts').get_gitea_type_url,
|
2022-09-28 12:54:48 +02:00
|
|
|
['git.gentoo.org'] = function(url_data)
|
|
|
|
url_data.host = 'gitweb.gentoo.org'
|
|
|
|
return require('gitlinker.hosts').get_cgit_type_url(url_data)
|
|
|
|
end,
|
|
|
|
['anongit.gentoo.org'] = function(url_data)
|
|
|
|
url_data.host = 'gitweb.gentoo.org'
|
|
|
|
url_data.repo = url_data.repo:gsub('^git/', '', 1)
|
|
|
|
return require('gitlinker.hosts').get_cgit_type_url(url_data)
|
|
|
|
end,
|
2022-09-28 12:04:05 +02:00
|
|
|
}
|
|
|
|
})
|
2022-10-01 19:15:03 +02:00
|
|
|
|
2022-10-01 19:38:11 +02:00
|
|
|
require('which-key').register({ ['<Leader>g'] = { name = 'Git' } })
|
2022-10-02 11:19:54 +02:00
|
|
|
require('which-key').register({ ['<Leader>gc'] = { name = 'commit' } })
|
|
|
|
map('n', '<Leader>gcc', ':Git commit<CR>', 'commit')
|
|
|
|
map('n', '<Leader>gca', ':Git commit --amend<CR>', 'amend')
|
2022-10-01 19:15:03 +02:00
|
|
|
map('n', '<Leader>gp', ':Git push<CR>', 'push')
|
2022-10-01 19:38:11 +02:00
|
|
|
require('which-key').register({ ['<Leader>ga'] = { name = 'add' } })
|
|
|
|
map('n', '<Leader>gau', ':Git add --update --patch<CR>', '--update --patch')
|
2022-10-02 01:03:41 +02:00
|
|
|
map('n', '<Leader>ga%', ':Git add %<CR>', 'This file')
|
2022-10-01 19:15:03 +02:00
|
|
|
map('n', '<Leader>gl', ':Git log --decorate<CR>', 'log')
|
2022-10-02 01:03:41 +02:00
|
|
|
map('n', '<Leader>gs', ':Git status<CR>', 'status')
|