1
0
mirror of https://github.com/SpaceVim/SpaceVim.git synced 2025-02-21 09:03:44 +08:00
SpaceVim/autoload/SpaceVim/layers/test.vim
Alessio Linares a3342e0dbe Enable test layer configuration (#2669)
* Enable test layer configuration

* test layer settings separator changed from - to _
2019-04-02 21:07:25 +08:00

52 lines
1.9 KiB
VimL

"=============================================================================
" 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/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)
let g:test#custom_strategies = {'spacevim': function('SpaceVim#plugins#runner#open')}
let g:test#strategy = 'spacevim'
endfunction
function! SpaceVim#layers#test#set_variable(var) abort
let l:override = get(a:var, 'override_config', {})
if !empty(l:override)
for l:option in keys(l:override)
let l:varname = 'test#'.substitute(l:option, '_', '#', 'g')
execute 'let g:'.l:varname.' = '."'".l:override[l:option]."'"
endfor
endif
endfunction