When you run an external command using
:! in NeoVim, it doesn't get connected to a terminal, which means it can't take input from the user.
:help :! in NeoVim:
The command runs in a non-interactive shell connected to a pipe (not a terminal). Use
:terminal to run an interactive shell connected to a terminal.
Note that this is NeoVim-specific. In regular Vim, running a command under
:! runs in a terminal, which means it can take input from the user. This is intended behavior in NeoVim, it's that way by design.
:!, you can instead use the
:terminal command to run your binary inside a NeoVim window.
For example, this command should take care of it:
autocmd filetype cpp nnoremap <silent> <buffer> <F10> :split | execute 'terminal ./%:r' | startinsert<CR>
I also added
<silent> to the mapping, so that it doesn't print the Ex command before executing it (usually a good idea) and also
<buffer>, since the mapping is set based on filetype, it should only apply to buffers of that specific filetype (and not be a global mapping, which would apply to all buffers and would potentially be overwritten by the mapping for the last filetype you opened.)