Skip to content

Commit 1e2e2ac

Browse files
author
Damien Radtke
committed
Some improvements to the Cargo compiler file.
1 parent 59e750f commit 1e2e2ac

File tree

1 file changed

+19
-9
lines changed

1 file changed

+19
-9
lines changed

src/etc/vim/compiler/cargo.vim

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
" Vim compiler file
22
" Compiler: Cargo Compiler
33
" Maintainer: Damien Radtke <[email protected]>
4-
" Latest Revision: 2014 Sep 18
4+
" Latest Revision: 2014 Sep 24
55

66
if exists("current_compiler")
77
finish
@@ -12,18 +12,18 @@ if exists(":CompilerSet") != 2
1212
command -nargs=* CompilerSet setlocal <args>
1313
endif
1414

15-
CompilerSet errorformat&
15+
CompilerSet errorformat=%A%f:%l:%c:\ %m,%-Z%p^,%-C%.%#
1616
CompilerSet makeprg=cargo\ $*
1717

1818
" Allow a configurable global Cargo.toml name. This makes it easy to
1919
" support variations like 'cargo.toml'.
20-
if !exists('g:cargo_toml_name')
21-
let g:cargo_toml_name = 'Cargo.toml'
20+
if !exists('g:cargo_manifest_name')
21+
let g:cargo_manifest_name = 'Cargo.toml'
2222
endif
2323

24-
let s:toml_dir = fnamemodify(findfile(g:cargo_toml_name, '.;'), ':p:h').'/'
24+
let s:local_manifest = fnamemodify(findfile(g:cargo_manifest_name, '.;'), ':p:h').'/'
2525

26-
if s:toml_dir != ''
26+
if s:local_manifest != ''
2727
augroup cargo
2828
au!
2929
au QuickfixCmdPost make call s:FixPaths()
@@ -33,15 +33,25 @@ if s:toml_dir != ''
3333
" to be relative to the current directory instead of Cargo.toml.
3434
function! s:FixPaths()
3535
let qflist = getqflist()
36+
let manifest = s:local_manifest
3637
for qf in qflist
3738
if !qf['valid']
39+
let m = matchlist(qf['text'], '\v.*\(file://(.*)\)$')
40+
if len(m) > 0
41+
let manifest = m[1].'/'
42+
" Manually strip another slash if needed; usually just an
43+
" issue on Windows.
44+
if manifest =~ '^/[A-Z]*:/'
45+
let manifest = manifest[1:]
46+
endif
47+
endif
3848
continue
3949
endif
4050
let filename = bufname(qf['bufnr'])
41-
if stridx(filename, s:toml_dir) == -1
42-
let filename = s:toml_dir.filename
51+
if filereadable(filename)
52+
continue
4353
endif
44-
let qf['filename'] = simplify(s:toml_dir.bufname(qf['bufnr']))
54+
let qf['filename'] = simplify(manifest.filename)
4555
call remove(qf, 'bufnr')
4656
endfor
4757
call setqflist(qflist, 'r')

0 commit comments

Comments
 (0)