1234567891011121314151617181920212223242526272829303132333435363738394041 |
- local MiniDiff = require('mini.diff')
- local util = require('user.util')
- -- shows added/removed/changed lines
- MiniDiff.setup({
- -- keymap #bracketed
- -- ]h / [h - navigate by hunks
- view = {
- style = 'sign',
- signs = {
- delete = '_',
- },
- },
- source = {
- MiniDiff.gen_source.git(),
- -- handle fugitive paths
- {
- name = 'fugitive',
- attach = function(buf_id)
- local resolved = util.resolve_git_path(buf_id)
- if not resolved or resolved.path == '' then
- return false
- end
- local source = vim.fn.FugitiveFind(string.format('%s~1:%s', resolved.commit, resolved.path))
- local text = vim.fn['fugitive#readfile'](source)
- MiniDiff.set_ref_text(buf_id, text)
- end
- }
- }
- })
- -- open status in current split without special flag (so navigating away closes it)
- -- https://github.com/tpope/vim-fugitive/issues/1296
- vim.keymap.set('n', '<Leader>gs', '<cmd>Gedit :<CR>')
- vim.keymap.set('n', '<Leader>gb', '<cmd>Telescope git_branches<CR>')
- vim.keymap.set('n', '<Leader>gd', MiniDiff.toggle_overlay)
- -- conflicts navigation #bracketed
- vim.keymap.set('n', '[x', '?^[<lt>=>]\\{7}<CR>')
- vim.keymap.set('n', ']x', '/^[<lt>=>]\\{7}<CR>')
|