sindrets / diffview.nvim

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

[features] Quickily close CommitLogView #461

Open tyalie opened 4 months ago

tyalie commented 4 months ago

Hi there,

I've noticed that there's no action or otherwise that would allow one to quickly close the CommitLogView through e.g. Esc or similar keys. Currently it seems like that the only option would to be type in :q every time, which is rather unpractical. Additionally the CommitLogView class also doesn't seem to have a mechanism already which would allow configuring such behavior easily through the keymap config.

I've (for now) build a workaround, which registers a hook, but I feel like this should at best be a default behavior or at least an action.

hooks = {
  view_opened = function (view)
    if view.commit_log_panel then
      local opt = { desc = "Close commit log panel", buffer = view.commit_log_panel.bufid }
      vim.keymap.set("n", "<ESC>", function()view.commit_log_panel:close()end, opt)
    end
  end,
}

With best regards Tyalie