From 53082c6034978b2191e8ce5b8e4f03805e3ef018 Mon Sep 17 00:00:00 2001 From: Michael Campagnaro Date: Mon, 1 May 2023 04:50:36 -0400 Subject: [PATCH] Tweak some vim build/run stuff around jai --- vimrc | 54 ++++++++++++++++++++++++++++++------------------------ 1 file changed, 30 insertions(+), 24 deletions(-) diff --git a/vimrc b/vimrc index 980eb0b..5901d6a 100644 --- a/vimrc +++ b/vimrc @@ -1187,11 +1187,17 @@ function! Build(optimized=0, silent=0) if a:optimized == 1 echo "Compiling release build.jai" - let l:cmd .= " -release" + " @note We pass 'release' as a user command arg for the build file + " to parse. -release is a compiler arg and we don't want to use + " that. Ideally the build script would ignore that completely. + let l:cmd .= " - release" else echo "Compiling debug build.jai" endif + " @note We aren't importing the local modules because the build file + " should manage that sort of thing for us. + elseif l:ext == "jai" let l:is_jai = 1 let l:cmd = "jai % " @@ -1227,30 +1233,30 @@ function! Build(optimized=0, silent=0) endfunction function! RunProgram() - let l:ext = tolower(expand('%:e')) - if l:ext == "jai" - if filereadable(expand('%:p:r') . '.exe') - exec "AsyncRun! " . expand('%:p:r') . ".exe" - else - if tolower(expand('%:h')) == "modules" - " This is likely a jai module inside a project. Check for an " exe one directory back. - let l:files = systemlist('ls ' . expand('%:p:h') . '/../*.exe 2>/dev/null') - else - let l:files = systemlist('ls ' . expand('%:p:h') . '/*.exe 2>/dev/null') - endif - - if len(l:files) > 0 - exec "AsyncRun! " . l:files[0] - else - call PrintError("No exe found. Compile first?") - endif - endif - - elseif l:ext == "py" - exec "AsyncRun! python %" - - else + if filereadable("run") exec "AsyncRun! -post=call\\ StopRunTask() ./run %" + else + let l:ext = tolower(expand('%:e')) + if l:ext == "jai" + if filereadable(expand('%:p:r') . '.exe') + exec "AsyncRun! " . expand('%:p:r') . ".exe" + else + if tolower(expand('%:h')) == "modules" + " This is likely a jai module inside a project. Check for an " exe one directory back. + let l:files = systemlist('ls ' . expand('%:p:h') . '/../*.exe 2>/dev/null') + else + let l:files = systemlist('ls ' . expand('%:p:h') . '/*.exe 2>/dev/null') + endif + + if len(l:files) > 0 + exec "AsyncRun! " . l:files[0] + else + call PrintError("No exe found. Compile first?") + endif + endif + elseif l:ext == "py" + exec "AsyncRun! python %" + endif endif endfunction