forked from vim-test/vim-test
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmamba.vim
More file actions
59 lines (50 loc) · 1.42 KB
/
mamba.vim
File metadata and controls
59 lines (50 loc) · 1.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
if !exists('g:test#python#mamba#file_pattern')
let g:test#python#mamba#file_pattern = '_spec\.py$'
endif
function! test#python#mamba#test_file(file)
if fnamemodify(a:file, ':t') =~# g:test#python#mamba#file_pattern
if exists('g:test#python#runner')
return g:test#python#runner ==# 'mamba'
else
return executable("mamba")
endif
endif
endfunction
function! test#python#mamba#build_position(type, position) abort
if a:type ==# 'nearest'
let name = s:nearest_test(a:position)
if !empty(name)
return [a:position['file'].':'.name]
else
return [a:position['file']]
endif
elseif a:type ==# 'file'
return [a:position['file']]
else
return []
endif
endfunction
function! test#python#mamba#build_args(args, color) abort
let args = a:args
if !a:color
let args = ['--color=no'] + args
endif
return args
endfunction
function! test#python#mamba#executable() abort
let pipenv_prefix = ""
if filereadable("Pipfile")
let pipenv_prefix = "pipenv run "
elseif filereadable("poetry.lock")
let pipenv_prefix = "poetry run "
elseif filereadable("pdm.lock")
let pipenv_prefix = "pdm run "
elseif filereadable("uv.lock")
let pipenv_prefix = "uv run "
endif
return pipenv_prefix . "mamba"
endfunction
function! s:nearest_test(position) abort
let name = test#base#nearest_test(a:position, g:test#python#patterns)
return get(name['test'], 0, '')
endfunction