Last active
February 21, 2016 13:43
-
-
Save chemzqm/db037d3b212ccecf0c8c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
" vim:set et sw=2 ts=2 tw=78 nofen: | |
if exists('did_neorun_loaded') || v:version < 700 || !has('nvim') | |
finish | |
endif | |
let did_neorun_loaded = 1 | |
command! -nargs=? Nrun :call s:TernimalRun(<q-args>) | |
function! s:TernimalRun(cmd) | |
execute 'belowright 5new' | |
call termopen(a:cmd, { | |
\ 'on_exit': function('s:OnExit'), | |
\ 'buffer_nr': bufnr('%'), | |
\}) | |
call setbufvar('%', 'is_autorun', 1) | |
execute 'wincmd p' | |
endfunction | |
function! s:OnExit(job_id, status, event) dict | |
if a:status == 0 | |
execute 'silent! bd! '.self.buffer_nr | |
endif | |
endfunction | |
function! TernimalRun(cmd, dir) | |
execute 'belowright 5new' | |
execute 'lcd ' . a:dir | |
call termopen(a:cmd, { | |
\ 'on_exit': function('s:OnExit'), | |
\ 'buffer_nr': bufnr('%'), | |
\}) | |
call setbufvar('%', 'is_autorun', 1) | |
execute 'wincmd p' | |
endfunction |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment