vim-test icon indicating copy to clipboard operation
vim-test copied to clipboard

fail to test if base dir is not in workspace folder

Open y1rn opened this issue 4 years ago • 5 comments

as subject. if vim base dir is parent of workspace path. test doesn't work. neovim lsp can get workspaceFolder path

y1rn avatar Jul 20 '21 09:07 y1rn

+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

gagara avatar Dec 01 '21 18:12 gagara

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?

ceuk avatar Dec 07 '21 10:12 ceuk

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.

gagara avatar Dec 07 '21 10:12 gagara

oh nice! autcmd would be possible without any additional modifications to this plugin I would imagine.

ceuk avatar Dec 08 '21 14:12 ceuk

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

gagara avatar Dec 11 '21 14:12 gagara