From 3e6db7f70753c0a3efc2c2b5623af4dd64e332eb Mon Sep 17 00:00:00 2001 From: Jon Maciel Date: Thu, 29 Oct 2020 15:33:05 -0300 Subject: [PATCH] feat: add a condition to outputs the rubocop_result just if not empty. It also helps to to add on BufWritePost --- plugin/rubocop.vim | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/plugin/rubocop.vim b/plugin/rubocop.vim index 2d98d4e..1147ed3 100644 --- a/plugin/rubocop.vim +++ b/plugin/rubocop.vim @@ -54,18 +54,22 @@ 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 - " Shortcuts taken from Ack.vim - git://github.com/mileszs/ack.vim.git - exec "nnoremap q :ccl" - exec "nnoremap t T" - exec "nnoremap T TgT" - exec "nnoremap o " - exec "nnoremap go " - exec "nnoremap h K" - exec "nnoremap H Kb" - exec "nnoremap v HbJt" - exec "nnoremap gv HbJ" + + if !empty(l:rubocop_results) + cexpr l:rubocop_results + copen + + " Shortcuts taken from Ack.vim - git://github.com/mileszs/ack.vim.git + exec "nnoremap q :ccl" + exec "nnoremap t T" + exec "nnoremap T TgT" + exec "nnoremap o " + exec "nnoremap go " + exec "nnoremap h K" + exec "nnoremap H Kb" + exec "nnoremap v HbJt" + exec "nnoremap gv HbJ" + endif endfunction command! -complete=custom,s:RuboCopSwitches -nargs=? RuboCop :call RuboCop()