Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use get(g:, ...) to read config #28

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 4 additions & 21 deletions plugin/rubocop.vim
Original file line number Diff line number Diff line change
Expand Up @@ -15,35 +15,18 @@ let g:loaded_vimrubocop = 1
let s:save_cpo = &cpo
set cpo&vim

if !exists('g:vimrubocop_rubocop_cmd')
let g:vimrubocop_rubocop_cmd = 'rubocop '
endif

" Options
if !exists('g:vimrubocop_config')
let g:vimrubocop_config = ''
endif

if !exists('g:vimrubocop_extra_args')
let g:vimrubocop_extra_args = ''
endif

if !exists('g:vimrubocop_keymap')
let g:vimrubocop_keymap = 1
endif

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

function! s:RuboCopSwitches(...)
return join(s:rubocop_switches, "\n")
endfunction

function! s:RuboCop(current_args)
let l:extra_args = g:vimrubocop_extra_args
let l:extra_args = get(g:, 'vimrubocop_extra_args', '')
let l:filename = @%
let l:rubocop_cmd = g:vimrubocop_rubocop_cmd
let l:rubocop_cmd = get(g:, 'vimrubocop_rubocop_cmd', 'rubocop ')
let l:rubocop_opts = ' '.a:current_args.' '.l:extra_args.' --format emacs'
if g:vimrubocop_config != ''
if get(g:, 'vimrubocop_config', '') != ''
let l:rubocop_opts = ' '.l:rubocop_opts.' --config '.g:vimrubocop_config
endif

Expand Down Expand Up @@ -71,7 +54,7 @@ endfunction
command! -complete=custom,s:RuboCopSwitches -nargs=? RuboCop :call <SID>RuboCop(<q-args>)

" Shortcuts for RuboCop
if g:vimrubocop_keymap == 1
if get(g:, 'vimrubocop_keymap', !exists('no_plugin_maps'))
nmap <Leader>ru :RuboCop<CR>
endif

Expand Down