vim build and run updates
This commit is contained in:
parent
d664ba882c
commit
2e07b0c85f
48
vimrc
48
vimrc
|
@ -1152,46 +1152,67 @@ function! StopRunTask()
|
|||
endfunction
|
||||
|
||||
function! Build(optimized=0, silent=0)
|
||||
let l:ext = tolower(expand('%:e'))
|
||||
let l:parent_dir = expand('%:p:h')
|
||||
let l:async_cmd = "AsyncRun! "
|
||||
if a:silent
|
||||
let l:async_cmd .= "-post=call\\ HideAsyncResults() "
|
||||
endif
|
||||
|
||||
let l:is_jai = 0
|
||||
let l:cmd = ""
|
||||
if filereadable(l:parent_dir . "/build.jai")
|
||||
|
||||
let l:ext = tolower(expand('%:e'))
|
||||
let l:current_dir = expand('%:h')
|
||||
let l:parent_dir = expand('%:p:h')
|
||||
|
||||
" Check if this is a jai module with a build.jai one directory back. This
|
||||
" only works when the file is directly inside the modules folder.
|
||||
let l:jai_module_with_build = (tolower(l:current_dir) == "modules") && filereadable(l:current_dir . "/../build.jai")
|
||||
|
||||
if (l:jai_module_with_build == 1) || filereadable(l:parent_dir . "/build.jai")
|
||||
" Jai build file
|
||||
let l:is_jai = 1
|
||||
let l:cmd = "jai " . l:parent_dir . "/build.jai "
|
||||
let l:cmd = "jai " . l:parent_dir . "/"
|
||||
|
||||
if l:jai_module_with_build == 1
|
||||
let l:cmd .= "../build.jai"
|
||||
else
|
||||
let l:cmd .= "build.jai"
|
||||
endif
|
||||
|
||||
if a:optimized == 1
|
||||
echo "Compiling release build.jai"
|
||||
let l:cmd .= " -release"
|
||||
else
|
||||
echo "Compiling debug build.jai"
|
||||
endif
|
||||
|
||||
elseif l:ext == "jai"
|
||||
let l:is_jai = 1
|
||||
let l:cmd = "jai % "
|
||||
|
||||
if a:optimized == 1
|
||||
echo "Compiling release " . expand('%:t')
|
||||
let l:cmd .= " -release"
|
||||
else
|
||||
echo "Compiling debug " . expand('%:t')
|
||||
endif
|
||||
|
||||
" If there's a local modules/ directory then we'll import it.
|
||||
if isdirectory(l:parent_dir . "/modules")
|
||||
let l:cmd .= " -import_dir modules"
|
||||
endif
|
||||
|
||||
else
|
||||
let l:cmd .= './build* '
|
||||
if a:optimized == 1
|
||||
let l:cmd .= ' -o'
|
||||
endif
|
||||
endif
|
||||
|
||||
if l:is_jai
|
||||
let l:cmd .= ' '.g:campo_jai_build_args
|
||||
endif
|
||||
|
||||
" I was originally passing -save=2 to AsyncRun! in order to save all
|
||||
" modified files (it just does a `silent! wall` call), but I want ctags to
|
||||
" be generated so we're handling the save ourselves.
|
||||
|
@ -1199,18 +1220,29 @@ function! Build(optimized=0, silent=0)
|
|||
exec l:async_cmd . l:cmd
|
||||
endfunction
|
||||
|
||||
function! RunExe()
|
||||
if tolower(expand('%:e')) == "jai"
|
||||
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
|
||||
exec "AsyncRun! -post=call\\ StopRunTask() ./run %"
|
||||
endif
|
||||
|
@ -1237,8 +1269,8 @@ nnoremap <silent><F8> :call Build(0, 1)<cr>
|
|||
nnoremap <leader>bb :call Build(1)<cr>
|
||||
|
||||
" Execute run script
|
||||
nnoremap <silent><leader>br :call RunExe()<cr>
|
||||
nnoremap <silent><F9> :call RunExe()<cr>
|
||||
nnoremap <silent><leader>br :call RunProgram()<cr>
|
||||
nnoremap <silent><F9> :call RunProgram()<cr>
|
||||
|
||||
nnoremap <leader>bs :AsyncStop<cr>
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user