tpope / vim-fugitive

fugitive.vim: A Git wrapper so awesome, it should be illegal
https://www.vim.org/scripts/script.php?script_id=2975
20.01k stars 1.01k forks source link

toggling `Press ENTER or type command...` prompt? #2316

Closed kristoferfannar closed 3 months ago

kristoferfannar commented 3 months ago

Hey, thanks for you work. Fugitive is great and very useful!

There is however one thing that I'd like to ask about: Whenever I commit :Git commit or push :Git push or the like, I not only receive the output, but also the prompt to continue, like below.

image

ps, I have cmdheight = 1, which causes this.

I see in your readme that you've specifically made :Git add quiet in this sense, which works for me (no prompt, unlike with :!git add .), but committing and pushing still display this prompt.

I imagine including it for commit/push is deliberate, but I doubt I've ever found the prompt very useful. I wonder therefore whether there are options to toggle this prompt for commands other than :Git add, such as those I've mentioned.

Thanks a lot!

kristoferfannar commented 3 months ago

For now, I've looked at #190 and see that prepending with :silent ! in front of my commands does silently remove the message. That will do for me, but I'd like to still see some message without the prompt.

For example, only displaying the last cmdheight lines?

tpope commented 3 months ago

I see in your readme that you've specifically made :Git add quiet in this sense, which works for me (no prompt, unlike with :!git add .)

This is not a special case for :Git add. :Git add --verbose . can produce a "Press ENTER" prompt and :Git commit --quiet . won't. The README is only calling out that you don't get "Press ENTER" prompts except when they're necessary.

prepending with :silent ! in front of my commands does silently remove the message.

This silences everything, including important messages like "no changes added to commit" and even exceptions thrown by Fugitive. You probably want --quiet (or -q).

For example, only displaying the last cmdheight lines?

This would be actively harmful most of the time.

jondkinney commented 2 months ago

I'm using Lazy to load plugins, and have the following configuration.

---@type LazySpec
return {
  {
    "tpope/vim-fugitive",
    config = function()
      -- Git related mappings
      vim.keymap.set("n", "<leader>gw", ":Gwrite<CR>")
      vim.keymap.set("n", "<leader>ge", ":Gedit<CR>")
      vim.keymap.set("n", "<leader>gb", ":Git blame -w -M<CR>")
      vim.keymap.set("n", "<leader>gco", ":Gread<CR>")
      vim.keymap.set("n", "<leader>gcm", ":silent Git commit<CR>")
    end,
  },
}

I tried to use

vim.keymap.set("n", "<leader>gcm", ":Git commit --quiet .<CR>")

and

vim.keymap.set("n", "<leader>gcm", ":Git commit --quiet<CR>")

since I'm not sure what the . was for...

But neither worked. Only prefixing the command with silent (no bang) prevented the "Press ENTER or type command to continue" when triggering the git commit command.