0.3.0 • Published 10 months ago

@yaegassy/coc-vitest v0.3.0

Weekly downloads
-
License
MIT
Repository
github
Last release
10 months ago

coc-vitest

Vitest for coc.nvim

coc-vitest-demo

Install

CocInstall:

:CocInstall @yaegassy/coc-vitest

scoped packages

vim-plug:

Plug 'yaegassy/coc-vitest', {'do': 'yarn install --frozen-lockfile'}

Configuration options

  • vitest.enable: Enable coc-vitest extension, default: true
  • vitest.terminal.enableSplitRight: Use vertical belowright for vitest terminal window, default: false
  • vitest.codelens.enable: Enable codelens, default: true
  • vitest.codelens.title: CodeLens title. Can be changed to any display, default: ">> [Run Vitest]"
  • vitest.watch: Run tests in watch mode, default: false

Commands

:CocCommand CommandName

e.g.: :CocCommand vitest.projectTest

  • vitest.projectTest: Run Vitest for current project
  • vitest.fileTest: Run Vitest for current file
  • vitest.singleTest: Run Vitest for single (nearest) test

Example of Vim command and key mapping:

Vim commands can be defined and executed or key mappings can be set and used.

" Run Vitest for current project
command! -nargs=0 Vitest :call CocAction('runCommand', 'vitest.projectTest')

" Run Vitest for current file
command! -nargs=0 VitestCurrent :call  CocAction('runCommand', 'vitest.fileTest', ['%'])

" Run Vitest for single (nearest) test
nnoremap <leader>te :call CocAction('runCommand', 'vitest.singleTest')<CR>

CodeLens (Neovim only)

Feature:

CodeLens appears above the test name in the *.test.ts and *.spec.ts files. Currently, import.meta.vitest is not supported.

coc-settings.json:

By default, codeLens.enable is set to false, which disables it.

Change the setting to true to enable it.

{
  "codeLens.enable": true
}

Example key mapping (CodeLens related):

nmap <silent> gl <Plug>(coc-codelens-action)

Misc:

"CodeLens" does not work with "Vim8" due to coc.nvim specifications.

vitest.singleTest commands are available, so please use them.

Similar coc.nvim extension

Thanks

License

MIT


This extension is built with create-coc-extension