Skip to content

Commit 70bd1e3

Browse files
rhysdda-x
authored andcommitted
Use :terminal for running cargo
1 parent c04ae84 commit 70bd1e3

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

autoload/cargo.vim

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,17 @@ function! cargo#Load()
33
endfunction
44

55
function! cargo#cmd(args)
6-
execute "! cargo" a:args
6+
" Trim trailing spaces. This is necessary since :terminal command parses
7+
" trailing spaces as an empty argument.
8+
let args = substitute(a:args, '\s\+$', '', '')
9+
if has('terminal')
10+
let cmd = 'terminal'
11+
elseif has('nvim')
12+
let cmd = 'noautocmd new | terminal'
13+
else
14+
let cmd = '!'
15+
endif
16+
execute cmd 'cargo' args
717
endfunction
818

919
function! s:nearest_cargo(...) abort

0 commit comments

Comments
 (0)