84 lines
2.8 KiB
Lua
84 lines
2.8 KiB
Lua
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')
|
|
|
|
local gitgroup = vim.api.nvim_create_augroup('config_git', { clear = true })
|
|
-- enable spell checking
|
|
vim.api.nvim_create_autocmd({ 'FileType' }, {
|
|
group = gitgroup,
|
|
pattern = { 'gitcommit' },
|
|
command = [[setlocal spell]]
|
|
})
|
|
|
|
-- start git commits in insert mode
|
|
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')
|
|
})
|
|
|
|
-- fugitive and Neogit buffers
|
|
vim.api.nvim_create_autocmd({ 'FileType' }, {
|
|
group = gitgroup,
|
|
pattern = { 'git', 'Neogit*' },
|
|
callback = function()
|
|
vim.o.list = false
|
|
-- this messes up the path of the current file for some reason
|
|
--vim.cmd.lcd(require('my.functions').get_project_root())
|
|
end
|
|
})
|
|
|
|
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,
|
|
['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,
|
|
}
|
|
})
|
|
|
|
require('which-key').register({ ['<Leader>g'] = { name = 'Git' } })
|
|
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')
|
|
map('n', '<Leader>gP', ':Git push<CR>', 'push')
|
|
require('which-key').register({ ['<Leader>gp'] = { name = 'pull' } })
|
|
map('n', '<Leader>gpo', ':Git pull origin<CR>', 'origin')
|
|
map('n', '<Leader>gpu', ':Git pull upstream<CR>', 'upstream')
|
|
require('which-key').register({ ['<Leader>ga'] = { name = 'add' } })
|
|
map('n', '<Leader>gau', ':Git add --update --patch<CR>', '--update --patch')
|
|
map('n', '<Leader>ga%', ':Git add %<CR>', 'This file')
|
|
map('n', '<Leader>gl', ':Git log --decorate<CR>', 'log')
|
|
map('n', '<Leader>gs', ':Git status<CR>', 'status')
|