I'm trying to make g++ run as a function :call
in vim> For some reason that I don't understand vim throws me an E81 error when I try to execute the s:compile_run_cpp()
function.
function! s:compile_run_cpp() abort
let src_path = expand('%:p:~')
let src_noext = expand('%:p:~:r')
" The building flags
let _flag = '-Wall -Wextra -std=c++11 -O2'
if executable('clang++')
let prog = 'clang++'
elseif executable('g++')
let prog = 'g++'
else
echoerr 'No compiler found!'
endif
call s:create_term_buf('v', 80)
execute printf('term %s %s %s -o %s && %s', prog, _flag, src_path, src_noext, src_noext)
startinsert
endfunction
function s:create_term_buf(_type, size) abort
set splitbelow
set splitright
if a:_type ==# 'v'
vnew
else
new
endif
execute 'resize ' . a:size
endfunction