Last active
July 7, 2021 02:22
-
-
Save gosukiwi/3d4f57a8a39048370ad85218befd595d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
" Use |:RubocopAutocorrect[!]| to autocorrect the current file using Rubocop. | |
" Note that this will save the file before running the autocorrects. If ! is | |
" given, it will use unsafe autocorrects. | |
augroup ruby | |
autocmd! | |
autocmd FileType ruby command! -bang RubocopAutocorrect silent! call RubyRubocopAutocorrect(expand('<bang>') == '!')<CR> | |
augroup END | |
function! RubyRubocopAutocorrect(unsafe) abort | |
let flag = a:unsafe ? '-A' : '-a' | |
write | call system('rubocop ' . flag . ' ' . expand('%:p')) | edit | |
endfunction |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment