From 0be9fb93ee30c9a3610311a572608a9cd9edf79f Mon Sep 17 00:00:00 2001 From: Michael Campagnaro Date: Wed, 3 Aug 2016 00:31:01 -0400 Subject: [PATCH] Add vim command for running a build script --- vimrc | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/vimrc b/vimrc index 3034798..d5cd412 100644 --- a/vimrc +++ b/vimrc @@ -152,6 +152,40 @@ map pn :sp ~/.personal-files/brain/writing/stack.txt map sn :sp ~/.personal-files/documents/software-notes/clojure.md map rn :sp ~/.work-files/dive-networks/files/notes/refactoring-notes.md +""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +" Run build script +""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +function! RunBuildScript() + let l:existing_buf = bufwinnr("__build_output_log__") + let l:current_buf = bufnr("%") + + " Save current buffer in case there are unsaved changes + write + + if l:existing_buf > 0 + exe l:existing_buf . "wincmd w" + "execute 'botright sb' l:existing_buf + else + botright sp __build_output_log__ + resize 10 + " NOTE: this would throw an error if running the build in the output + " buffer, even though a check is done here to find an existing buffer + " before making a new one. Strange. + "setlocal buftype=nofile + endif + + " Clear the buffer + normal! ggdG + + " Output compile log into buffer + let l:output = system("./build") + call append(0, split(l:output, '\v\n')) + + exe l:current_buf . "wincmd w" +endfunction + +nnoremap b :call RunBuildScript() +nnoremap bb :bw! """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " Lisp