Implement build function at <C-B>

This commit is contained in:
Yannick Reiß 2023-08-26 17:15:48 +02:00
parent 4134bec26e
commit dab3a1bca9
No known key found for this signature in database
GPG Key ID: 5A3AF456F0A0338C
1 changed files with 20 additions and 1 deletions

View File

@ -75,4 +75,23 @@ endfunction
nnoremap <M-u> :call Update_Sys()<CR> nnoremap <M-u> :call Update_Sys()<CR>
nnoremap <C-b> :!lualatex % < /dev/null<CR> " Call build function
function! Build()
let l:filetype = &filetype
if l:filetype == 'c' || l:filetype == 'cpp' || l:filetype == 'h' || l:filetype == 'hpp'
execute 'make'
elseif l:filetype == 'py' || l:filetype == 'python'
execute '!python3 %'
elseif l:filetype == 'tex'
execute '!lualatex % < /dev/null'
elseif l:filetype == 'rs'
execute 'cargo run'
elseif l:filetype == 'S'
execute 'make'
else
echo "Unsupported file type: " . l:filetype
endif
endfunction
nnoremap <C-b> :call Build()<CR>