setlocal ts=4 sts=4 sw=4 expandtab set formatprg=rustfmt " set makeprg=cargo\ clippy set errorformat= \%-G, \%-Gerror:\ aborting\ %.%#, \%-Gerror:\ Could\ not\ compile\ %.%#, \%Eerror:\ %m, \%Eerror[E%n]:\ %m, \%Wwarning:\ %m, \%Inote:\ %m, \%C\ %#-->\ %f:%l:%c, \%E\ \ left:%m,%C\ right:%m\ %f:%l:%c,%Z function! RustMake() abort set makeprg=nix-shell\ --run\ \"cargo\ build\" silent! make set makeprg=nix-shell\ --run\ \"cargo\ clippy\" silent! make endfunction nnoremap r :call RustMake() silent! redraw cwindow if exists('*RustFmtSimple') finish endif function! RustFmtSimple() abort let s = winsaveview() bufdo! silent! !rustfmt % bufdo! edit call winrestview(s) endfunction augroup SimpleRustFmt autocmd! autocmd BufWritePost *.rs call RustFmtSimple() augroup END