Skip to content

Instantly share code, notes, and snippets.

@zhangchiqing
Created March 28, 2016 00:56
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 zhangchiqing/a7dd8ae1a1789aac5403 to your computer and use it in GitHub Desktop.
Save zhangchiqing/a7dd8ae1a1789aac5403 to your computer and use it in GitHub Desktop.
vim shortcut to bind <leader>d to run doctest for typescript file
nnoremap <leader>d :call <SID>RunDoctest()<cr>
function! s:RunDoctest()
if &filetype == "typescript"
cexpr system('tsc ' . expand('%:p') . '&& doctest --module commonjs ' . substitute(expand('%:p'), ".ts", ".js", ""))
endif
if &filetype == "javascript"
cexpr system('doctest --module commonjs ' . expand('%:p'))
endif
copen
endfunction
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment