diff --git a/autoload/SpaceVim/layers/test.vim b/autoload/SpaceVim/layers/test.vim new file mode 100644 index 000000000..243e036ef --- /dev/null +++ b/autoload/SpaceVim/layers/test.vim @@ -0,0 +1,40 @@ +"============================================================================= +" test.vim --- test layer file for SpaceVim +" Copyright (c) 2018 Shidong Wang & Contributors +" Author: Shidong Wang < wsdjeg at 163.com > +" URL: https://spacevim.org +" License: GPLv3 +"============================================================================= + +"" +" @section github, layer-test +" @parentsection layers +" This layer allows to run tests on SpaceVim +" +" @subsection Mappings +" > +" Mode Key Function +" ------------------------------------------------------------- +" normal SPC k n run nearest test +" normal SPC k f run test file +" normal SPC k s run test suite +" normal SPC k l run the latest test +" normal SPC k v visits the last run test file +" < + +function! SpaceVim#layers#test#plugins() abort + return [ + \ ['janko-m/vim-test'], + \ ] +endfunction + +function! SpaceVim#layers#test#config() abort + let g:_spacevim_mappings_space.k = get(g:_spacevim_mappings_space, 'k', {'name' : '+Test'}) + + call SpaceVim#mapping#space#def('nnoremap', ['k', 'n'], 'TestNearest', 'nearest', 1) + call SpaceVim#mapping#space#def('nnoremap', ['k', 'f'], 'TestFile', 'file', 1) + call SpaceVim#mapping#space#def('nnoremap', ['k', 's'], 'TestSuite', 'suite', 1) + call SpaceVim#mapping#space#def('nnoremap', ['k', 'l'], 'TestLast', 'last', 1) + call SpaceVim#mapping#space#def('nnoremap', ['k', 'v'], 'TestVisit', 'visit', 1) +endfunction + diff --git a/doc/SpaceVim.txt b/doc/SpaceVim.txt index defa7ae25..26301d61f 100644 --- a/doc/SpaceVim.txt +++ b/doc/SpaceVim.txt @@ -72,8 +72,9 @@ CONTENTS *SpaceVim-contents* 28. lang#xml...................................|SpaceVim-layer-lang-xml| 29. operator...................................|SpaceVim-layer-operator| 30. shell.........................................|SpaceVim-layer-shell| - 31. tmux...........................................|SpaceVim-layer-tmux| - 32. tools#dash...............................|SpaceVim-layer-tools-dash| + 31. test...........................................|SpaceVim-layer-test| + 32. tmux...........................................|SpaceVim-layer-tmux| + 33. tools#dash...............................|SpaceVim-layer-tools-dash| 7. API........................................................|SpaceVim-api| 1. cmdlinemenu................................|SpaceVim-api-cmdlinemenu| 2. data#dict....................................|SpaceVim-api-data-dict| @@ -1284,6 +1285,23 @@ For more info, read |deol| and |vimshell|. VARIABLE default_shell +============================================================================== +TEST *SpaceVim-layer-test* + +This layer allow to run tests directly on SpaceVim +This layer is not added by default. To include +it, add `[[layers]] name = "test"` to your `~/.SpaceVim.d/init.toml`. + +MAPPINGS + +> + Mode Key Function + ----------------------------------------------- + normal SPC k n Run nearest test + normal SPC k f Run test file + normal SPC k s Run test suite + normal SPC k l Run last test + normal SPC k v Visit the last test file ============================================================================== TMUX *SpaceVim-layer-tmux* diff --git a/docs/layers.md b/docs/layers.md index 4bb309881..a62360281 100644 --- a/docs/layers.md +++ b/docs/layers.md @@ -132,6 +132,7 @@ enable = false | [shell](shell/) | This layer provide shell support in SpaceVim | | [sudo](sudo/) | sudo layer provides ability to read and write file elevated privileges in SpaceVim | | [tags](tags/) | This layer provide tags manager for project | +| [tests](tests/) | This layer allows to run tests directly on SpaceVim | | [tmux](tmux/) | This layers adds extensive support for tmux | | [tools#dash](tools/dash/) | This layer provides Dash integration for SpaceVim | | [tools](tools/) | This layer provides some tools for vim | diff --git a/docs/layers/test.md b/docs/layers/test.md new file mode 100644 index 000000000..726cb5074 --- /dev/null +++ b/docs/layers/test.md @@ -0,0 +1,38 @@ +--- +title: "SpaceVim test layer" +description: "This layer allows to run tests directly on SpaceVim" +--- + +# [Available Layers](../) >> test + + + +- [Description](#description) +- [Install](#install) +- [Key bindings](#key-bindings) + + + +## Description + +This layers allow to run tests directly on Vim. + +## Install + +To use this configuration layer, add following snippet to your custom configuration file. + +```toml +[[layers]] + name = "test" +``` + +## Key bindings + +| Key Binding | Description | +| ----------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `SPC k n` | Run nearest test | +| `SPC k f` | Run test file | +| `SPC k s` | Runs the whole test suite (if the current file is a test file, runs that framework's test suite, otherwise determines the test framework from the last run test). | +| `SPC k l` | Runs the last test | +| `SPC k v` | Visits the test file from which you last run your tests (useful when you're trying to make a test pass, and you dive deep into application code and close your test buffer to make more space, and once you've made it pass you want to go back to the test file to write more tests) | +