From f3ea7c8003c7a65de29c2f4e0e1bf0d592dd0ad8 Mon Sep 17 00:00:00 2001 From: Syndamia Date: Sun, 28 Jan 2024 16:05:38 +0200 Subject: [.vimrc] Reworked entire vimrc --- .vim/miniplugins/code_terminal.vim | 85 -------------------------------------- 1 file changed, 85 deletions(-) delete mode 100644 .vim/miniplugins/code_terminal.vim (limited to '.vim/miniplugins/code_terminal.vim') diff --git a/.vim/miniplugins/code_terminal.vim b/.vim/miniplugins/code_terminal.vim deleted file mode 100644 index 4ddc1ae..0000000 --- a/.vim/miniplugins/code_terminal.vim +++ /dev/null @@ -1,85 +0,0 @@ -" Program in which build actions are executed. If no value, build commands are executes as bash commands. -" This is only really useful in languages with interpreters -let g:codeenvs = { -\ 'scheme' : 'racket', -\ 'lisp' : 'rlwrap sbcl --noinform', -\ } - -" The following two dictionaries support certain substitutions: -" %F - location of current file (relative path) -" %D - directory of current file (full path) - -" Building the current file only -let g:codebuildsingle = { -\ 'scheme' : '(enter! "%F")', -\ 'cpp' : "g++ -g -pedantic '%F' && ./a.out", -\ 'yacc' : 'bison -t -d %F', -\ 'lex' : 'flex %F', -\ 'haskell' : 'runhaskell "%F"', -\ 'lisp' : '(load "%F")', -\ } -" Building all files in the directory (and subdirectories) of the current file -let g:codebuildproject = { -\ 'cpp' : "g++ -g -pedantic '%D/'**/*.cpp && ./a.out" -\ } - -noremap :call CodeTerminal(g:codebuildsingle) -noremap :call CodeTerminal(g:codebuildproject) -inoremap :call CodeTerminal(g:codebuildsingle) -inoremap :call CodeTerminal(g:codebuildproject) -" We assume that the last accessed window is the one with the source code, otherwise it gets complicated -tnoremap :call CodeTerminal(g:codebuildsingle) -tnoremap :call CodeTerminal(g:codebuildproject) - -au TabNew * call CTCreateTabVars() - -function! CTCreateTabVars() - let t:codetermbufnr = -1 - let t:codetermft = "" - let t:codetermhadenv = 0 -endfunction -call CTCreateTabVars() - -function! OpenCodeTerminal() - if !bufexists(t:codetermbufnr) - term - " Latest buffer is the terminal buffer we just opened - let t:codetermbufnr = bufnr("$") - " We go back to the file from which this was called - wincmd p - let t:codetermft = "" - let t:codetermhadenv = 0 - endif - - if &filetype != t:codetermft - if t:codetermhadenv - " This is kinda bad, since certain environments might not close with this only - call term_sendkeys(t:codetermbufnr, "\") - " The sleep is kinda bad, but it fixes the next term_sendkeys not working properly - sleep 500m - endif - - let t:codetermft = &filetype - if has_key(g:codeenvs, &filetype) - call term_sendkeys(t:codetermbufnr, g:codeenvs[&filetype] . "\") - let t:codetermhadenv = 1 - else - let t:codetermhadenv = 0 - endif - endif -endfunction - -function! CodeTerminal(builddict) - call OpenCodeTerminal() - - if has_key(a:builddict, &filetype) - let buildcomm = a:builddict[&filetype] . "\" - let buildcomm = substitute(buildcomm, "%F", @%, "") - let buildcomm = substitute(buildcomm, "%D", expand('%:p:h'), "") - call term_sendkeys(t:codetermbufnr, buildcomm) - echo "[CodeTerminal] Sent build command!" - else - call term_sendkeys(t:codetermbufnr, "\\") - echo "[CodeTerminal] No value in build dictionary!" - endif -endfunction -- cgit v1.2.3