vim-test
vim-test copied to clipboard
fail to test if base dir is not in workspace folder
as subject. if vim base dir is parent of workspace path. test doesn't work. neovim lsp can get workspaceFolder path
+1
For gradle tests it is also not possible to override -p option. e.g.:
:TestFile -p path/to/project
doesn't work. The only options is to cd to workspace before running any tests
changing directory into the sub-directory causes other plugins to start misbehaving, so I have to cd into the subdirectory then cd back up - which takes away the convenience somewhat :slightly_smiling_face: - does anyone know of a fix/workaround?
Perhaps supporting a test#subdirectory option or something?
In fact there is a test#project_root for this purpose. (see https://github.com/vim-test/vim-test#working-directory).
It would be good to have some autocmd which will update it once you switch between projects.
oh nice! autcmd would be possible without any additional modifications to this plugin I would imagine.
With coc.nvim (plugin which I use to navigate projects) following works for me:
autocmd BufEnter * :call SetVimtestProjectRoot(expand('%:p'))
function! SetVimtestProjectRoot(file)
if exists("g:WorkspaceFolders")
for f in g:WorkspaceFolders
if match(a:file, f, 0) == 0 | let g:test#project_root = f | return | endif
endfor
endif
endfunction