Skip to content

Commit

Permalink
Silent mode, no cexpr if no violation is found
Browse files Browse the repository at this point in the history
  • Loading branch information
bgutzwiller committed Jan 24, 2017
1 parent 1c57918 commit a4c9669
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions plugin/rubocop.vim
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ if !exists('g:vimrubocop_keymap')
let g:vimrubocop_keymap = 1
endif

let s:rubocop_switches = ['-l', '--lint', '-R', '--rails', '-a', '--auto-correct']
let s:rubocop_switches = ['-l', '--lint', '-R', '--rails', '-a', '--auto-correct', '-s', '--silent']

function! s:RuboCopSwitches(...)
return join(s:rubocop_switches, "\n")
Expand All @@ -41,8 +41,9 @@ endfunction
function! s:RuboCop(current_args)
let l:extra_args = g:vimrubocop_extra_args
let l:filename = @%
let l:silent = matchstr(a:current_args, '--silent\|-\<s\>')
let l:rubocop_cmd = g:vimrubocop_rubocop_cmd
let l:rubocop_opts = ' '.a:current_args.' '.l:extra_args.' --format emacs'
let l:rubocop_opts = ' '. substitute(a:current_args, '--silent\|-\<s\>', '', '').' '.l:extra_args.' --format emacs'
if g:vimrubocop_config != ''
let l:rubocop_opts = ' '.l:rubocop_opts.' --config '.g:vimrubocop_config
endif
Expand All @@ -54,8 +55,15 @@ function! s:RuboCop(current_args)
endif
let l:rubocop_output = substitute(l:rubocop_output, '\\"', "'", 'g')
let l:rubocop_results = split(l:rubocop_output, "\n")
cexpr l:rubocop_results
copen
if len(l:rubocop_results) > 0
if empty(l:silent)
cexpr l:rubocop_results
copen
end
else
echom 'Rubocop reports no violations'
endif

" Shortcuts taken from Ack.vim - git://github.com/mileszs/ack.vim.git
exec "nnoremap <silent> <buffer> q :ccl<CR>"
exec "nnoremap <silent> <buffer> t <C-W><CR><C-W>T"
Expand Down

0 comments on commit a4c9669

Please sign in to comment.