1
0
mirror of https://github.com/jdhao/nvim-config.git synced 2025-06-08 14:14:33 +02:00
jdhao 3539207913 use 2 spaces for tabs by default
This removes a lot of code duplication. If we want to use 4 spaces, we
can set it separately in their ftplugin settings.
2022-10-15 11:28:15 +08:00

40 lines
932 B
VimL

set commentstring=//\ %s
" Disable inserting comment leader after hitting o or O or <Enter>
set formatoptions-=o
set formatoptions-=r
nnoremap <silent> <buffer> <F9> :call <SID>compile_run_cpp()<CR>
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 C++ compiler found on the system!'
endif
call s:create_term_buf('h', 20)
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
" For delimitMate
let b:delimitMate_matchpairs = "(:),[:],{:}"