vim: add terminal focus handling code

Also split off terminal setup into its own plugin.