nvim/lua/user/plugins/util/git-conflict.lua
2023-10-28 00:00:00 +07:00

38 lines
1.2 KiB
Lua

local gc = require('git-conflict')
gc.setup {
disable_diagnostics = true,
default_mappings = false,
default_commands = false,
}
vim.api.nvim_create_autocmd('User', {
pattern = 'GitConflictDetected',
once = true,
callback = function()
local bufnr = vim.api.nvim_get_current_buf()
local actions = {
['Base change'] = 'base',
['Both changes'] = 'both',
['Current change'] = 'ours',
['Incoming change'] = 'theirs',
['None of the changes'] = 'none',
}
vim.api.nvim_buf_create_user_command(bufnr, 'GitConflict', function()
vim.ui.select(vim.tbl_keys(actions), { prompt = 'Select a conflict action' }, function(choice)
if choice then gc.choose(actions[choice]) end
end)
end, { nargs = 0 })
vim.keymap.set('n', '<localleader>c', '<cmd>GitConflict<CR>', {
buffer = true,
noremap = true,
silent = true,
desc = 'Resolve git conflict',
})
end,
desc = 'Custom user command for git-conflict',
group = vim.api.nvim_create_augroup('UserGitConflict', { clear = true }),
})