|
19 | 19 | CompilerSet makeprg=cargo\ $*
|
20 | 20 | endif
|
21 | 21 |
|
22 |
| -" Allow a configurable global Cargo.toml name. This makes it easy to |
23 |
| -" support variations like 'cargo.toml'. |
24 |
| -let s:cargo_manifest_name = get(g:, 'cargo_manifest_name', 'Cargo.toml') |
25 |
| - |
26 |
| -function! s:is_absolute(path) |
27 |
| - return a:path[0] == '/' || a:path =~ '[A-Z]\+:' |
28 |
| -endfunction |
29 |
| - |
30 | 22 | " Ignore general cargo progress messages
|
31 | 23 | CompilerSet errorformat+=
|
32 | 24 | \%-G%\\s%#Downloading%.%#,
|
33 | 25 | \%-G%\\s%#Compiling%.%#,
|
34 | 26 | \%-G%\\s%#Finished%.%#,
|
35 | 27 | \%-G%\\s%#error:\ Could\ not\ compile\ %.%#,
|
36 | 28 | \%-G%\\s%#To\ learn\ more\\,%.%#
|
37 |
| - |
38 |
| -let s:local_manifest = findfile(s:cargo_manifest_name, '.;') |
39 |
| -if s:local_manifest != '' |
40 |
| - let s:local_manifest = fnamemodify(s:local_manifest, ':p:h').'/' |
41 |
| - augroup cargo |
42 |
| - au! |
43 |
| - au QuickfixCmdPost make call s:FixPaths() |
44 |
| - augroup END |
45 |
| - |
46 |
| - " FixPaths() is run after Cargo, and is used to change the file paths |
47 |
| - " to be relative to the current directory instead of Cargo.toml. |
48 |
| - function! s:FixPaths() |
49 |
| - let qflist = getqflist() |
50 |
| - let manifest = s:local_manifest |
51 |
| - for qf in qflist |
52 |
| - if !qf.valid |
53 |
| - let m = matchlist(qf.text, '(file://\(.*\))$') |
54 |
| - if !empty(m) |
55 |
| - let manifest = m[1].'/' |
56 |
| - " Manually strip another slash if needed; usually just an |
57 |
| - " issue on Windows. |
58 |
| - if manifest =~ '^/[A-Z]\+:/' |
59 |
| - let manifest = manifest[1:] |
60 |
| - endif |
61 |
| - endif |
62 |
| - continue |
63 |
| - endif |
64 |
| - let filename = bufname(qf.bufnr) |
65 |
| - if s:is_absolute(filename) |
66 |
| - continue |
67 |
| - endif |
68 |
| - let qf.filename = simplify(manifest.filename) |
69 |
| - call remove(qf, 'bufnr') |
70 |
| - endfor |
71 |
| - call setqflist(qflist, 'r') |
72 |
| - endfunction |
73 |
| -endif |
0 commit comments