12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 |
- local diffview = require('diffview')
- local MiniDiff = require('mini.diff')
- local util = require('user.util')
- diffview.setup({
- use_icons = false,
- signs = {
- fold_closed = ' ',
- fold_open = '-',
- }
- })
- -- 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)
- vim.keymap.set('n', '<Leader>gvi', '<cmd>DiffviewOpen<CR>')
- vim.keymap.set('n', '<Leader>gvr', '<cmd>DiffviewFileHistory --range=origin..HEAD<CR>')
- -- conflicts navigation #bracketed
- vim.keymap.set('n', '[x', '?^[<lt>=>]\\{7}<CR>')
- vim.keymap.set('n', ']x', '/^[<lt>=>]\\{7}<CR>')
|