Skip to content

Instantly share code, notes, and snippets.

@copoer
Last active September 6, 2023 21:19
Show Gist options
  • Select an option

  • Save copoer/ff242be1da092788c9175575977c9b2a to your computer and use it in GitHub Desktop.

Select an option

Save copoer/ff242be1da092788c9175575977c9b2a to your computer and use it in GitHub Desktop.
build
"Compile Code
map <F5> :call CompileRunGcc()<CR>
func! CompileRunGcc()
exec "w"
if &filetype == 'markdown'
exec "!pandoc -s -o $(basename % .md).pdf % && zathura $(basename % .md).pdf &"
elseif &filetype == 'c'
exec "!gcc -pthread -lm % -o %<"
exec "!time ./%<"
elseif &filetype == 'tex'
exec "!pdflatex % && biber %:r && pdflatex % && { pgrep zathura || zathura %:r.pdf & }; sleep 0.5"
exec "redraw!"
elseif &filetype == 'cpp'
exec "!g++ % -o %<"
exec "!time ./%<"
elseif &filetype == 'java'
exec "!clear && javac % && time java -cp %:p:h %:t:r"
elseif &filetype == 'sh'
exec "!time bash %"
elseif &filetype == 'python'
exec "!time python %"
elseif &filetype == 'html'
exec "!firefox % &"
elseif &filetype == 'go'
exec "GoRun"
elseif &filetype == 'rust'
exec "!cargo run %<"
elseif &filetype == 'groff'
exec "!groff -ms % -T pdf > $(basename % .ms).pdf && { pgrep zathura || zathura %:r.pdf & }; sleep 0.5"
elseif &filetype == 'rust'
exec "!cargo run"
endif
endfunc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment