sindrets / diffview.nvim

Single tabpage interface for easily cycling through diffs for all modified files for any git rev.
Other
3.92k stars 107 forks source link

File History Layout #434

Closed victorscomma closed 11 months ago

victorscomma commented 11 months ago

Is it possible to change the file history layouts? I tried all of the below but none of them appear to effect the code/diff boxes in file_history

require("diffview").setup({
        view = {
              default = {
                  layout = "diff2_vertical",
              },
              file_history = {
                  layout = "diff2_vertical",
              },
              diff_view = {
                  layout = "diff2_vertical",
              },
              file_history_view = {
                  layout = "diff2_vertical",
              },
        },

Ideally I was hoping to keep it horizontal but swap the boxes, but was just testing with vertical to see if I can get it working.

I like using the command :DiffviewFileHistory --base=LOCAL % and I wanted to try to keep my local state on the left since it feels a little more natural.

Thanks for any assistance

tummetott commented 11 months ago

The right config is opts.view.file_history.layout

require("diffview").setup({
    view = {
        file_history = {
            layout = "diff2_vertical",
        },
    },
})

But this does not swap the boxes. If you want to swap the boxes you could use one of the hooks and play a little with wincmd:

require("diffview").setup({
    hooks = {
        view_opened = function(view)
            if(view.class:name() == 'FileHistoryView') then
                vim.cmd('wincmd k')
                vim.cmd('wincmd x')
                vim.cmd('wincmd j')
            end
        end,
    }
})
victorscomma commented 11 months ago

thank you @tummetott works perfect!