Skip to content

Instantly share code, notes, and snippets.

@kawarimidoll
Last active November 27, 2021 01:55
Show Gist options
  • Save kawarimidoll/8db8bf8a23b06f77dd0cf8fbf3315bcb to your computer and use it in GitHub Desktop.
Save kawarimidoll/8db8bf8a23b06f77dd0cf8fbf3315bcb to your computer and use it in GitHub Desktop.
Auto Run Deno in Neovim

Auto Run Deno in Neovim

Copy DenoRun in your init.vim.

When you run :DenoRun in Deno script file, deno run will be started the terminal window. If the name of the file is match with Deno test files, deno test will be started instead of deno run. It automatically add -A --no-check --unstable --watch for productivity. Use this only in your own files for your security.

This works only in Neovim, not Vim, because Vim has different terminal API.

There is an article about this in Japanese: https://zenn.dev/kawarimidoll/articles/0ff5d28fa584d6

command! DenoRun silent only | botright 12 split |
\ execute 'terminal deno ' .
\ (expand('%:t') =~ '^\(.*[._]\)\?test\.\(ts\|tsx\|js\|mjs\|jsx\)$'
\ ? 'test' : 'run')
\ . ' -A --no-check --unstable --watch ' . expand('%:p') |
\ stopinsert | execute 'normal! G' | set bufhidden=wipe |
\ execute 'autocmd BufEnter <buffer> if winnr("$") == 1 | quit! | endif' |
\ wincmd k
@kawarimidoll
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment