之前在用 Vim 的时候,有一个配置项,

nmap <unique> <F5> :!git difftool --tool=nvimdiff -y HEAD -- %<LEFT><LEFT><LEFT><LEFT><LEFT>

效果如下图:编辑文件时用 F5 查看当前内容与 Git 库 HEAD 的差异

现在改用 Neovim 以后,暂时无法实现。

简单调查后,问题可能在于 Neovim 删除了 term,改用了 terminal。

在 Vim 和 Neovim 分别执行一个外部的命令(!top),可以看出差别。


@https://github.com/neovim/neovim/issues/1496

This is not a bug, it is the new behavior of bang commands: We no longer spawn the program with it’s stdout connected to Nvim tty, instead we open a pipe, read output and display to the user. This is the only way the bang commands will be consistent across UIs, so programs designed to be used interactively from the terminal will no longer work from inside nvim.

There are two alternatives for bang commands that behave differently when opened from terminals:

Invoke it from a shell(either from a different terminal or with ctrl+z)
Use the fugitive git plugin

Unfortunately there’s not much I can do to help, this is a consequence of Nvim’s client-server architecture which can’t cope with programs being spawned in the main process tty.
It seems interactive-bang commands is a popular feature(you are not the first to report this behavior), I’m starting to think it’s better to find a solution to that soon.