A terminal may be opened in a floating window, but the insert command
would be applied to the current window.
This was an issue with neotest and nvim-dap, where in some instance it
would switch to insert mode.
See https://github.com/nvim-neotest/neotest/issues/2#issuecomment-
1149532666
if !has('nvim')
autocmd TerminalOpen * if &buftype == 'terminal' | setlocal bufhidden=hide | endif
else
- autocmd TermOpen * startinsert
+ autocmd TermOpen * lua if vim.startswith(vim.api.nvim_buf_get_name(0), "term://") then vim.cmd("startinsert") end
autocmd TermOpen * if &buftype == 'terminal' | setlocal bufhidden=hide | endif
autocmd CmdlineLeave,WinEnter,BufWinEnter * call timer_start(0, function('s:TermEnter'), {})
endif