mirror of
https://github.com/amix/vimrc
synced 2025-06-16 09:35:01 +08:00
Update rust.vim from deprecated repo to rust-lang repo and add to update_plugins.py (#410)
This commit is contained in:
@ -2,64 +2,36 @@
|
||||
" Compiler: Cargo Compiler
|
||||
" Maintainer: Damien Radtke <damienradtke@gmail.com>
|
||||
" Latest Revision: 2014 Sep 24
|
||||
" For bugs, patches and license go to https://github.com/rust-lang/rust.vim
|
||||
|
||||
if exists('current_compiler')
|
||||
finish
|
||||
finish
|
||||
endif
|
||||
runtime compiler/rustc.vim
|
||||
let current_compiler = "cargo"
|
||||
|
||||
let s:save_cpo = &cpo
|
||||
set cpo&vim
|
||||
|
||||
if exists(':CompilerSet') != 2
|
||||
command -nargs=* CompilerSet setlocal <args>
|
||||
command -nargs=* CompilerSet setlocal <args>
|
||||
endif
|
||||
|
||||
if exists('g:cargo_makeprg_params')
|
||||
execute 'CompilerSet makeprg=cargo\ '.escape(g:cargo_makeprg_params, ' \|"').'\ $*'
|
||||
execute 'CompilerSet makeprg=cargo\ '.escape(g:cargo_makeprg_params, ' \|"').'\ $*'
|
||||
else
|
||||
CompilerSet makeprg=cargo\ $*
|
||||
CompilerSet makeprg=cargo\ $*
|
||||
endif
|
||||
|
||||
" Allow a configurable global Cargo.toml name. This makes it easy to
|
||||
" support variations like 'cargo.toml'.
|
||||
let s:cargo_manifest_name = get(g:, 'cargo_manifest_name', 'Cargo.toml')
|
||||
" Ignore general cargo progress messages
|
||||
CompilerSet errorformat+=
|
||||
\%-G%\\s%#Downloading%.%#,
|
||||
\%-G%\\s%#Compiling%.%#,
|
||||
\%-G%\\s%#Finished%.%#,
|
||||
\%-G%\\s%#error:\ Could\ not\ compile\ %.%#,
|
||||
\%-G%\\s%#To\ learn\ more\\,%.%#,
|
||||
\%-Gnote:\ Run\ with\ \`RUST_BACKTRACE=%.%#,
|
||||
\%.%#panicked\ at\ \\'%m\\'\\,\ %f:%l
|
||||
|
||||
function! s:is_absolute(path)
|
||||
return a:path[0] == '/' || a:path =~ '[A-Z]\+:'
|
||||
endfunction
|
||||
|
||||
let s:local_manifest = findfile(s:cargo_manifest_name, '.;')
|
||||
if s:local_manifest != ''
|
||||
let s:local_manifest = fnamemodify(s:local_manifest, ':p:h').'/'
|
||||
augroup cargo
|
||||
au!
|
||||
au QuickfixCmdPost make call s:FixPaths()
|
||||
augroup END
|
||||
|
||||
" FixPaths() is run after Cargo, and is used to change the file paths
|
||||
" to be relative to the current directory instead of Cargo.toml.
|
||||
function! s:FixPaths()
|
||||
let qflist = getqflist()
|
||||
let manifest = s:local_manifest
|
||||
for qf in qflist
|
||||
if !qf.valid
|
||||
let m = matchlist(qf.text, '(file://\(.*\))$')
|
||||
if !empty(m)
|
||||
let manifest = m[1].'/'
|
||||
" Manually strip another slash if needed; usually just an
|
||||
" issue on Windows.
|
||||
if manifest =~ '^/[A-Z]\+:/'
|
||||
let manifest = manifest[1:]
|
||||
endif
|
||||
endif
|
||||
continue
|
||||
endif
|
||||
let filename = bufname(qf.bufnr)
|
||||
if s:is_absolute(filename)
|
||||
continue
|
||||
endif
|
||||
let qf.filename = simplify(manifest.filename)
|
||||
call remove(qf, 'bufnr')
|
||||
endfor
|
||||
call setqflist(qflist, 'r')
|
||||
endfunction
|
||||
endif
|
||||
let &cpo = s:save_cpo
|
||||
unlet s:save_cpo
|
||||
|
Reference in New Issue
Block a user