Closed imroc closed 10 months ago
The plugin already sets the cursor at the top of the file the first time a diff is opened for a given entry. If folds are enabled - as they are by default - then that is the first diff hunk. Did you disable folds?
[...] in DiffviewFileHistory, select a commit and press Enter to open a diff file, the cursor do not jump to file panel, I have to move cursor to my file panel [...]
Remap the action for <cr>
to actions.focus_entry()
(See :h diffview-actions-focus_entry
). This will bring the cursor directly into the diff buffer when you select an entry.
When I use the default config, it also do not focus the diff, cursor still stays in file history panel, not in file content, is my screen recording (I use LazyVim):
I tried to remap <cr>
to actions.focus_entry
, it works!
Now I use this config and it works perfect:
hooks = {
diff_buf_win_enter = function()
vim.opt_local.foldenable = false
end,
diff_buf_read = function()
vim.api.nvim_input("gg]czz")
end,
},
keymaps = {
file_history_panel = {
{
"n",
"<cr>",
actions.focus_entry,
{ desc = "Open and focus the diff for the selected entry." },
},
{
"n",
"o",
actions.focus_entry,
{ desc = "Open and focus the diff for the selected entry." },
},
{
"n",
"l",
actions.focus_entry,
{ desc = "Open and focus the diff for the selected entry." },
},
{
"n",
"<2-LeftMouse>",
actions.focus_entry,
{ desc = "Open and focus the diff for the selected entry." },
},
},
},
This is my screen recording:
Is the a way to jump to next file, and how do you config that
Is the a way to jump to next file, and how do you config that
Tab
Thank you... @imroc
For example, in DiffviewFileHistory, select a commit and press Enter to open a diff file, the cursor do not jump to file panel, I have to move cursor to my file panel, and then
gg]c
to the first change every time, which is troublesome.