Skip to content

Commit

Permalink
Vim: Add custom command RunMake for smart Make
Browse files Browse the repository at this point in the history
RunMake[!] will invoke either Make or Make! according to the
following criteria:

* If bang is given (i.e. RunMake!), run Make!
* For specified types such as latex or pandoc, run Make!
  (for disturbanceless background, by dispatch.vim)
* Otherwise, run Make (see output of cmake in the splitted pane)

This command is mapped to <F5> and <leader><F5>.
  • Loading branch information
wookayin committed Apr 18, 2015
1 parent ad470dc commit 43c8735
Showing 1 changed file with 18 additions and 5 deletions.
23 changes: 18 additions & 5 deletions vim/vimrc
Original file line number Diff line number Diff line change
Expand Up @@ -181,16 +181,29 @@ vnoremap > >gv

" [F5] Make and Build
" smartly dispatch according to filetype
function! s:run_make(bang)
let l:silent_filetypes = ['tex', 'pandoc']
" (1) bang given, force background
if a:bang == "!" | Make!
" (2) for specified filetypes, use background
elseif index(l:silent_filetypes, &filetype) >= 0 | Make!
" (3) otherwise, make with foreground shown
else | Make
end
endfunction
command! -nargs=0 -bang RunMake call s:run_make("<bang>")

if isdirectory(expand("~/.vim/plugged/vim-dispatch"))
" use vim-dispatch if exists

" <F5>: run make, with asynchronously or headless
map <F5> <ESC>:w<CR>:Make!<CR>
imap <F5> <ESC>:w<CR>:Make!<CR>a
" <F5>: run make, asynchronously or split windows (dispatch)
map <F5> <ESC>:w<CR>:RunMake<CR>
imap <F5> <ESC>:w<CR>:RunMake<CR>a
" <leader-F5>: run make with visible progress (split window in tmux)
map <leader><F5> <ESC>:w<CR>:Make<CR>
imap <leader><F5> <ESC>:w<CR>:Make<CR>a
map <leader><F5> <ESC>:w<CR>:RunMake!<CR>
imap <leader><F5> <ESC>:w<CR>:RunMake!<CR>a
" <F6>: show quickfix window (scroll bottom)
map <F6> :Copen<CR>G
Expand Down

0 comments on commit 43c8735

Please sign in to comment.