NeogitOrg / neogit

An interactive and powerful Git interface for Neovim, inspired by Magit
MIT License
3.71k stars 221 forks source link

Allow running `:Neogit $popup` with pre-populated flags #1287

Closed ptn closed 2 months ago

ptn commented 2 months ago

Is your feature request related to a problem? Please describe. I frequently want to do git log for the current file only and also pass in the -S switch. This at the moment requires me to do:

  1. Copy the file name of the current file.
  2. Open the Neogit status buffer.
  3. Press l
  4. Tap --
  5. Paste the file name
  6. Press -S
  7. Fill in the value.
  8. Press l again.

It'd be much easier to do all that from the file in question, with some switches filled in for me.

Describe the solution you'd like I would like to be able to do :Neogit log -- % and the log popup opens with -- pre-populated to the current buffer. If in visual mode, then :Neogit log opens with -L (trace line evolution) correctly populated.

In general, a way to invoke any popup like so :Neogit $popup -X -Y -Zvalue prepopulates the switches passed.

Describe alternatives you've considered A clear and concise description of any alternative solutions or features you've considered.

Additional context Add any other context or screenshots about the feature request here.

CKolkey commented 2 months ago

There's a way to invoke actions directly via lua: https://github.com/NeogitOrg/neogit/blob/master/lua/neogit.lua#L118-L169

CKolkey commented 2 months ago

Just as an example, here's the rhs of a binding to open the current file:

      function()
        require("neogit").action("log", "log_current", { "--", vim.fn.expand("%") })()
      end
ptn commented 2 months ago

That doesn't open the popup though, it gives me the log view. The popup is helpful because it summarizes all options possible, I sometimes want to pass -S, or -G, or disable -g... anything.

Magit offers this. From my todo.org file, pressing <leader>gl in Emacs gives:

Screenshot 2024-05-14 at 12 45 57

Notice how -- is already provided, and I'm then free to add any switches I fancy. Can this be implemented?