Skip to content

Instantly share code, notes, and snippets.

@chemzqm
Last active February 21, 2016 13:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chemzqm/db037d3b212ccecf0c8c to your computer and use it in GitHub Desktop.
Save chemzqm/db037d3b212ccecf0c8c to your computer and use it in GitHub Desktop.
" 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