├── langs ├── test.bash ├── bash_run.py ├── javascript_run.py ├── R_run.py ├── dart_run.py ├── lua_run.py ├── perl_run.py ├── ruby_run.py ├── zsh_run.py ├── julia_run.py ├── python_run.py ├── sql_run.py ├── v_run.py ├── d_run.py ├── go_run.py ├── rust_run.py ├── c_family_run.py └── qbasic_run.py ├── .gitignore ├── display.py └── README.md /langs/test.bash: -------------------------------------------------------------------------------- 1 | echo "wow this is zsh" 2 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | __pycache__/ 2 | langs/__pycache__/ 3 | -------------------------------------------------------------------------------- /langs/bash_run.py: -------------------------------------------------------------------------------- 1 | import subprocess 2 | 3 | def bash_run(file_name): 4 | cmd = f"bash {file_name}" 5 | cmd = "".join(cmd).split() 6 | subprocess.run(cmd) 7 | 8 | -------------------------------------------------------------------------------- /langs/javascript_run.py: -------------------------------------------------------------------------------- 1 | import subprocess 2 | 3 | def javascript_run(file_name): 4 | cmd = f"node {file_name}" 5 | cmd = "".join(cmd).split() 6 | subprocess.run(cmd) 7 | 8 | -------------------------------------------------------------------------------- /langs/R_run.py: -------------------------------------------------------------------------------- 1 | import subprocess 2 | import display 3 | 4 | def R_run(file_name): 5 | cmd = f"Rscript {file_name}" 6 | cmd = "".join(cmd).split() 7 | display.print_run() 8 | subprocess.run(cmd) 9 | 10 | -------------------------------------------------------------------------------- /langs/dart_run.py: -------------------------------------------------------------------------------- 1 | import subprocess 2 | import display 3 | 4 | 5 | def dart_run(file_name): 6 | cmd = f"dart {file_name}" 7 | cmd = "".join(cmd).split() 8 | display.print_run() 9 | subprocess.run(cmd) 10 | -------------------------------------------------------------------------------- /langs/lua_run.py: -------------------------------------------------------------------------------- 1 | import subprocess 2 | import display 3 | 4 | 5 | def lua_run(file_name): 6 | cmd = f"lua {file_name}" 7 | cmd = "".join(cmd).split() 8 | display.print_run() 9 | subprocess.run(cmd) 10 | -------------------------------------------------------------------------------- /langs/perl_run.py: -------------------------------------------------------------------------------- 1 | import subprocess 2 | import display 3 | 4 | 5 | def perl_run(file_name): 6 | cmd = f"perl {file_name}" 7 | cmd = "".join(cmd).split() 8 | display.print_run() 9 | subprocess.run(cmd) 10 | -------------------------------------------------------------------------------- /langs/ruby_run.py: -------------------------------------------------------------------------------- 1 | import subprocess 2 | import display 3 | 4 | 5 | def ruby_run(file_name): 6 | cmd = f"ruby {file_name}" 7 | cmd = "".join(cmd).split() 8 | display.print_run() 9 | subprocess.run(cmd) 10 | -------------------------------------------------------------------------------- /langs/zsh_run.py: -------------------------------------------------------------------------------- 1 | import subprocess 2 | import display 3 | 4 | 5 | def zsh_run(file_name): 6 | cmd = f"zsh {file_name}" 7 | cmd = "".join(cmd).split() 8 | display.print_run() 9 | subprocess.run(cmd) 10 | -------------------------------------------------------------------------------- /langs/julia_run.py: -------------------------------------------------------------------------------- 1 | import subprocess 2 | import display 3 | 4 | def julia_run(file_name): 5 | cmd = f"julia {file_name}" 6 | cmd = "".join(cmd).split() 7 | display.print_run() 8 | subprocess.run(cmd) 9 | 10 | -------------------------------------------------------------------------------- /langs/python_run.py: -------------------------------------------------------------------------------- 1 | import subprocess 2 | import display 3 | 4 | 5 | def python_run(file_name): 6 | cmd = f"python {file_name}" 7 | cmd = "".join(cmd).split() 8 | display.print_run() 9 | subprocess.run(cmd) 10 | -------------------------------------------------------------------------------- /langs/sql_run.py: -------------------------------------------------------------------------------- 1 | import display 2 | ## NOT worked 3 | # import subprocess 4 | 5 | # def sql_run(file_name): 6 | # cmd = f"mysql < {file_name} --table " 7 | # cmd = "".join(cmd).split() 8 | # subprocess.run(cmd) 9 | 10 | import os 11 | 12 | 13 | def sql_run(file_name): 14 | cmd = f"mysql < {file_name} --table " 15 | display.print_run() 16 | os.system(cmd) 17 | -------------------------------------------------------------------------------- /display.py: -------------------------------------------------------------------------------- 1 | import os 2 | 3 | 4 | # colors 5 | RESET = "\033[0m" 6 | BLACK = "\033[0;30;0m" 7 | GREEN = "\033[0;32m" 8 | RED = "\033[0;31;47m" 9 | 10 | cols, rows = os.get_terminal_size() 11 | 12 | 13 | def print_das(): 14 | for _ in range(cols): 15 | print(f"{BLACK}─{RESET}", end='') 16 | print("") 17 | 18 | 19 | def print_run(): 20 | xx = "Running Program" 21 | xx = xx.center(int(cols)) 22 | print(xx) 23 | print_das() 24 | 25 | 26 | def sucess_msg(): 27 | xx = f" Compilation {GREEN}Successful ✔{RESET}" 28 | xx = xx.center(int(cols)) 29 | print_das() 30 | print(xx) 31 | print_das() 32 | 33 | 34 | def failed_msg(): 35 | xx = f" Compilation {RED}Failed ❌{RESET}" 36 | xx = xx.center(int(cols)) 37 | print_das() 38 | print(xx) 39 | print_das() 40 | -------------------------------------------------------------------------------- /langs/v_run.py: -------------------------------------------------------------------------------- 1 | import subprocess 2 | import display 3 | 4 | 5 | def v_exec(): 6 | cmd = f"{file_name_no_extc_with_loc}" 7 | if output_location != "None": 8 | cmd = f"{output_location}{file_name_no_extc}" 9 | cmd = "".join(cmd).split() 10 | 11 | try: 12 | display.print_run() 13 | subprocess.run(cmd) 14 | print("\n\n") 15 | except FileNotFoundError: 16 | print(f"compiled file, {file_name_no_extc_with_loc}, \033[91mnot found") 17 | 18 | 19 | def v_build(): 20 | cmd = f"v {file_name_with_location} -o {file_name_no_extc} " 21 | if output_location != "None": 22 | cmd = f"v {file_name_with_location} -o {output_location}{file_name_no_extc}" 23 | cmd = "".join(cmd).split() 24 | 25 | status = subprocess.run(cmd) 26 | 27 | if status.returncode == 0: 28 | display.sucess_msg() 29 | if status.returncode != 0: 30 | display.failed_msg() 31 | exit(1) 32 | 33 | 34 | def v_buildexec(): 35 | v_build() 36 | v_exec() 37 | 38 | 39 | def v_run(program_name, conditions, output_loc="None"): 40 | build, run, build_run = conditions 41 | global file_name, file_name_no_extc, output_location, file_name_with_location, file_name_no_extc_with_loc 42 | file_name = program_name.split("/")[-1] 43 | file_name_no_extc = file_name.split(".")[0] # getting rid of extension 44 | file_name_no_extc_with_loc = program_name.split(".")[0] 45 | file_name_with_location = program_name 46 | output_location = str(output_loc) 47 | 48 | if run == 1 and build == 0: 49 | v_exec() 50 | if run == 1 and build == 1: 51 | v_buildexec() 52 | if build == 1 and run == 0: 53 | v_build() 54 | if build_run == 1: 55 | v_buildexec() 56 | -------------------------------------------------------------------------------- /langs/d_run.py: -------------------------------------------------------------------------------- 1 | import subprocess 2 | import display 3 | 4 | 5 | def d_exec(): 6 | cmd = f"{file_name_no_extc_with_loc}" 7 | if output_location != "None": 8 | cmd = f"{output_location}{file_name_no_extc}" 9 | cmd = "".join(cmd).split() 10 | 11 | try: 12 | 13 | display.print_run() 14 | subprocess.run(cmd) 15 | print("\n\n") 16 | except FileNotFoundError: 17 | print(f"compiled file, {file_name_no_extc_with_loc}, \033[91mnot found") 18 | 19 | 20 | def d_build(): 21 | cmd = f"dmd {file_name_with_location} -of={file_name_no_extc}" 22 | if output_location != "None": 23 | cmd = f"dmd {file_name_with_location} -of={output_location}{file_name_no_extc}" 24 | cmd = "".join(cmd).split() 25 | 26 | status = subprocess.run(cmd) 27 | 28 | if status.returncode == 0: 29 | display.sucess_msg() 30 | if status.returncode != 0: 31 | display.failed_msg() 32 | exit(1) 33 | 34 | 35 | def d_buildexec(): 36 | d_build() 37 | d_exec() 38 | 39 | 40 | def d_run(program_name, conditions, output_loc="None"): 41 | build, run, build_run = conditions 42 | global file_name, file_name_no_extc, output_location, file_name_with_location, file_name_no_extc_with_loc 43 | file_name = program_name.split("/")[-1] 44 | file_name_no_extc = file_name.split(".")[0] # getting rid of extension 45 | file_name_no_extc_with_loc = program_name.split(".")[0] 46 | file_name_with_location = program_name 47 | output_location = str(output_loc) 48 | 49 | if run == 1 and build == 0: 50 | d_exec() 51 | if run == 1 and build == 1: 52 | d_buildexec() 53 | if build == 1 and run == 0: 54 | d_build() 55 | if build_run == 1: 56 | d_buildexec() 57 | 58 | -------------------------------------------------------------------------------- /langs/go_run.py: -------------------------------------------------------------------------------- 1 | import subprocess 2 | import display 3 | 4 | 5 | def go_exec(): 6 | cmd = f"{file_name_no_extc_with_loc}" 7 | if output_location != "None": 8 | cmd = f"{output_location}{file_name_no_extc}" 9 | cmd = "".join(cmd).split() 10 | 11 | try: 12 | display.print_run() 13 | subprocess.run(cmd) 14 | print("\n\n") 15 | except FileNotFoundError: 16 | print(f"compiled file, {file_name_no_extc_with_loc}, \033[91mnot found") 17 | 18 | def go_build(): 19 | cmd = f"go build -o {file_name_no_extc} {file_name_with_location}" 20 | if output_location != "None": 21 | cmd = f"go build -o {output_location}{file_name_no_extc} {file_name_with_location}" 22 | cmd = "".join(cmd).split() 23 | 24 | status = subprocess.run(cmd) 25 | 26 | if status.returncode == 0: 27 | display.sucess_msg() 28 | if status.returncode != 0: 29 | display.failed_msg() 30 | exit(1) 31 | 32 | 33 | def go_buildexec(): 34 | go_build() 35 | go_exec() 36 | 37 | 38 | def go_run(program_name, conditions, output_loc="None"): 39 | build, run, build_run = conditions 40 | global file_name, file_name_no_extc, output_location, file_name_with_location, file_name_no_extc_with_loc 41 | file_name = program_name.split("/")[-1] 42 | file_name_no_extc = file_name.split(".")[0] # getting rid of extension 43 | file_name_no_extc_with_loc = program_name.split(".")[0] 44 | file_name_with_location = program_name 45 | output_location = str(output_loc) 46 | 47 | if run == 1 and build == 0: 48 | go_exec() 49 | if run == 1 and build == 1: 50 | go_buildexec() 51 | if build == 1 and run == 0: 52 | go_build() 53 | if build_run == 1: 54 | go_buildexec() 55 | 56 | -------------------------------------------------------------------------------- /langs/rust_run.py: -------------------------------------------------------------------------------- 1 | import subprocess 2 | import display 3 | 4 | 5 | def rust_exec(): 6 | cmd = f"{file_name_no_extc_with_loc}" 7 | if output_location != "None": 8 | cmd = f"{output_location}{file_name_no_extc}" 9 | cmd = "".join(cmd).split() 10 | 11 | try: 12 | display.print_run() 13 | subprocess.run(cmd) 14 | print("\n\n") 15 | except FileNotFoundError: 16 | print(f"compiled file, {file_name_no_extc_with_loc}, \033[91mnot found") 17 | 18 | 19 | def rust_build(): 20 | cmd = f"rustc {file_name_with_location} -o {file_name_no_extc}" 21 | if output_location != "None": 22 | cmd = f"rustc {file_name_with_location} -o {output_location}{file_name_no_extc}" 23 | cmd = "".join(cmd).split() 24 | 25 | status = subprocess.run(cmd) 26 | 27 | if status.returncode == 0: 28 | display.sucess_msg() 29 | if status.returncode != 0: 30 | display.failed_msg() 31 | exit(1) 32 | 33 | 34 | def rust_buildexec(): 35 | rust_build() 36 | rust_exec() 37 | 38 | 39 | def rust_run(program_name, conditions, output_loc="None"): 40 | build, run, build_run = conditions 41 | global file_name, file_name_no_extc, output_location, file_name_with_location, file_name_no_extc_with_loc 42 | file_name = program_name.split("/")[-1] 43 | file_name_no_extc = file_name.split(".")[0] # getting rid of extension 44 | file_name_no_extc_with_loc = program_name.split(".")[0] 45 | file_name_with_location = program_name 46 | output_location = str(output_loc) 47 | 48 | if run == 1 and build == 0: 49 | rust_exec() 50 | if run == 1 and build == 1: 51 | rust_buildexec() 52 | if build == 1 and run == 0: 53 | rust_build() 54 | if build_run == 1: 55 | rust_buildexec() 56 | 57 | -------------------------------------------------------------------------------- /langs/c_family_run.py: -------------------------------------------------------------------------------- 1 | import subprocess 2 | import display 3 | 4 | 5 | def c_family_exec(): 6 | cmd = f"{file_name_no_extc_with_loc}" 7 | if output_location != "None": 8 | cmd = f"{output_location}{file_name_no_extc}" 9 | cmd = "".join(cmd).split() 10 | 11 | try: 12 | display.print_run() 13 | subprocess.run(cmd) 14 | print("\n\n") 15 | except FileNotFoundError: 16 | print(f"compiled file, {file_name_no_extc_with_loc}, \033[91mnot found") 17 | 18 | 19 | def c_family_build(): 20 | cmd = f"gcc -Wall -ggdb {file_name_with_location} -o {file_name_no_extc} -lstdc++ -lm -msse3 -fdiagnostics-generate-patch" 21 | if output_location != "None": 22 | cmd = f"gcc -Wall -ggdb {file_name_with_location} -o {output_location}{file_name_no_extc} -lstdc++ -lm -msse3 -fdiagnostics-generate-patch" 23 | cmd = "".join(cmd).split() 24 | 25 | status = subprocess.run(cmd) 26 | 27 | if status.returncode == 0: 28 | display.sucess_msg() 29 | if status.returncode != 0: 30 | display.failed_msg() 31 | exit(1) 32 | 33 | 34 | def c_family_buildexec(): 35 | c_family_build() 36 | c_family_exec() 37 | 38 | 39 | def c_family_run(program_name, conditions, output_loc="None"): 40 | build, run, build_run = conditions 41 | global file_name, file_name_no_extc, output_location, file_name_with_location, file_name_no_extc_with_loc 42 | file_name = program_name.split("/")[-1] 43 | file_name_no_extc = file_name.split(".")[0] # getting rid of extension 44 | file_name_no_extc_with_loc = program_name.split(".")[0] 45 | file_name_with_location = program_name 46 | output_location = str(output_loc) 47 | 48 | if run == 1 and build == 0: 49 | c_family_exec() 50 | if run == 1 and build == 1: 51 | c_family_buildexec() 52 | if build == 1 and run == 0: 53 | c_family_build() 54 | if build_run == 1: 55 | c_family_buildexec() 56 | 57 | -------------------------------------------------------------------------------- /langs/qbasic_run.py: -------------------------------------------------------------------------------- 1 | import subprocess 2 | 3 | 4 | def qbasic_exec(): 5 | cmd = f"{file_name_no_extc_with_loc}" 6 | if output_location != "None": 7 | cmd = f"{output_location}{file_name_no_extc}" 8 | cmd = "".join(cmd).split() 9 | 10 | try: 11 | 12 | print("████████████████ RUNNING PROGRAM ████████████████") 13 | subprocess.run(cmd) 14 | print("\n\n") 15 | except FileNotFoundError: 16 | print(f"compiled file, {file_name_no_extc_with_loc}, \033[91mnot found") 17 | 18 | 19 | def qbasic_build(): 20 | cmd = f"/home/lazy/codeDNA/confiFILES/programmingLANGUAGE/qb64/qb64 -x {file_name_with_location} -o {file_name_no_extc}" 21 | if output_location != "None": 22 | cmd = f"/home/lazy/codeDNA/confiFILES/programmingLANGUAGE/qb64/qb64 -x {file_name_with_location} -o {output_location}{file_name_no_extc}" 23 | cmd = "".join(cmd).split() 24 | 25 | status = subprocess.run(cmd) 26 | 27 | if status.returncode == 0: 28 | print("__________________________________________") 29 | print("✔\tCompilation Successful") 30 | print("__________________________________________") 31 | if status.returncode != 0: 32 | print("__________________________________________") 33 | print("❌\tCompilation Failed") 34 | print("__________________________________________") 35 | exit(1) 36 | 37 | 38 | def qbasic_buildexec(): 39 | qbasic_build() 40 | qbasic_exec() 41 | 42 | 43 | def qbasic_run(program_name, conditions, output_loc="None"): 44 | build, run, build_run = conditions 45 | global file_name, file_name_no_extc, output_location, file_name_with_location, file_name_no_extc_with_loc 46 | file_name = program_name.split("/")[-1] 47 | file_name_no_extc = file_name.split(".")[0] # getting rid of extension 48 | file_name_no_extc_with_loc = program_name.split(".")[0] 49 | file_name_with_location = program_name 50 | output_location = str(output_loc) 51 | 52 | if run == 1 and build == 0: 53 | qbasic_exec() 54 | if run == 1 and build == 1: 55 | qbasic_buildexec() 56 | if build == 1 and run == 0: 57 | qbasic_build() 58 | if build_run == 1: 59 | qbasic_buildexec() 60 | 61 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # LAZY-BUILDER 2 | 3 | Lazy-Builder is a python script for buinding or running any programming language('s file) in vim by mapping lazy-builder script in vimrc(for vim), init.vim(for neo-vim) file. 4 | 5 | ### logic 6 | logic of lazy-build is simple. it just analyse the extension of file which you want to build/run.If programming language is Interpreted, it ran the file as interpreted language OR if programming language is Compiled, it ran the/build file as compliled language 7 | 8 | ## Uses 9 | 10 | 11 | ``` 12 | usage: python build.py [-h] [-r] [-b] [-br] [-o] program_name 13 | 14 | positional arguments: 15 | program_name File/Program that you want to RUN/BUILD (eg. hello.c, calculate.py, auto.sh) 16 | 17 | optional arguments: 18 | -h, --help show this help message and exit 19 | -r 0 or 1, 1 means RUN and 0(default) means don't RUN the program 20 | -b 0 or 1, 1 means BUILD and 0(default) means don't BUILD the program 21 | -br 0 or 1, 1 means BUILD and RUN and 0 means don't BUILD and RUN the program 22 | -o location for output of compiled language (eg. /home/user/folder1/) 23 | 24 | ``` 25 | 26 | ## Using with vim/neo-vim 27 | you can use lazy-build with vim by mapping as shown in below example: 28 | 29 | [ NOTE: first install [vim-floaterm](https://github.com/voldikss/vim-floaterm) plugin 30 | OR 31 | if you don't want to install vim-floaterm plugin, go with [this](https://github.com/shaeinst/lazy-builder/tree/main) branch and follow [this](https://github.com/shaeinst/lazy-builder/tree/main#using-with-vimneo-vim) example of mapping (which use builtin split option) 32 | ] 33 | ``` 34 | " Run program file when leader+r is pressed 35 | nnoremap r :w :FloatermNew 36 | \ python /home/user/folder/lazy-builder/build.py -o /home/user/.cache/build_files/ -r 1 % 37 | 38 | " build the program file when leader+b is pressed 39 | nnoremap b :w :FloatermNew 40 | \ time 41 | \ python /home/user/folder/lazy-builder/build.py -o /home/user/.cache/build_files/ -b 1 % 42 | 43 | " build and then run the program when leader+o is pressed 44 | nnoremap o :w :FloatermNew 45 | \ time 46 | \ python /home/user/folder/lazy-builder/build.py -o /home/user/.cache/build_files/ -br 1 % 47 | ``` 48 | replace the following location to the location where you downloaded/cloned lazy-builder repositories 49 | ``` 50 | /home/user/folder/lazy-builder/build.py 51 | ``` 52 | replace this location to your desired location where you want to put the output/build/compiled files. 53 | ``` 54 | /home/user/.cache/build_files/ 55 | ``` 56 | or if you want the compiled file to stay in it's parent directory(from where it's compiled) then remove "-o /home/user/.cache/build_files/" from binding 57 | 58 | 59 | 60 | # currently supported languages 61 | ``` 62 | [ Compiled Languages ] 63 | c/c++ 64 | D 65 | go 66 | qbasic 67 | rust 68 | V 69 | 70 | [ Interpreted Languages ] 71 | bash 72 | javascript 73 | julia 74 | perl 75 | python 76 | R 77 | sql 78 | zsh 79 | 80 | [ more comming soon...] 81 | ``` 82 | # to-do 83 | add more language support 84 | 85 | ## Screenshots 86 | ### running python program 87 | ![running python file using lazy-builder script](https://github.com/shaeinst/media/raw/main/images/github-repositories/lazy-builder/running_python_program.png) 88 | 89 | ### compiling c++ program 90 | ![running python file using lazy-builder script](https://github.com/shaeinst/media/raw/main/images/github-repositories/lazy-builder/comiling.png) 91 | 92 | ### running c++ program 93 | ![running python file using lazy-builder script](https://github.com/shaeinst/media/raw/main/images/github-repositories/lazy-builder/running_c%2B%2B_program.png) 94 | 95 | ### compiling and then running c++ program 96 | ![running python file using lazy-builder script](https://github.com/shaeinst/media/raw/main/images/github-repositories/lazy-builder/compile_and_running.png) 97 | --------------------------------------------------------------------------------