Files
dotfiles/home/config/nvim/utils.vim
2021-05-02 09:24:02 +05:30

20 lines
883 B
VimL
Executable File

" I got this part of the config from Michael Lan Source = https://www.youtube.com/watch?v=I4Rz0qoWYBl
function! TermWrapper(command) abort
if !exists('g:split_term_style') | let g:split_term_style = 'vertical' | endif
if g:split_term_style ==# 'vertical'
let buffercmd = 'vnew'
elseif g:split_term_style ==# 'horizontal'
let buffercmd = 'new'
else
echoerr 'ERROR! g:split_term_style is not a valid value (must be ''horizontal'' or ''vertical'' but is currently set to ''' . g:split_term_style . ''')'
throw 'ERROR! g:split_term_style is not a valid value (must be ''horizontal'' or ''vertical'')'
endif
exec buffercmd
exec 'term ' . a:command
exec 'startinsert'
endfunction
command! -nargs=0 CompileAndRun call TermWrapper(printf('g++ -std=c++17 %s && ./a.out', expand('%')))
autocmd FileType cpp nnoremap <F5> :CompileAndRun<CR>
let g:split_term_style = 'vertical'