You can map FloatTermNew <cmd>
in an autocmd for specific filetypes:
autocmdaugroup floatterm-mappings
au!
au FileType javascript nnoremap <buffer> <F5> :w<esc>:FloatermNew node %<CR>
autocmd au FileType c nnoremap <buffer> <F5> :w<esc>:FloatermNew gcc % && ./a.out && rm a.out<CR>
autocmd au FileType cpp nnoremap <buffer> <F5> :w<esc>:FloatermNew g++ % && ./a.out && rm a.out<CR>
autocmd au FileType python nnoremap <buffer> <F5> :w<esc>:FloatermNew python3 %<CR>
augroup end
The <buffer>
in nnoremap
makes sure the mapping only works for that specific buffer (rather than all buffers).