1

I've got a vim

VIM - Vi IMproved 8.2 (2019 Dec 12, compiled Sep 17 2020 21:54:53)

on ManjaroLinux (Arch + kde) and I'm using rvm to run my rubies. The ruby I am using now is:

=> ruby-2.7.2 [ x86_64 ]

The problem I'm facing is lack of rubocop linting in the code (the rubocop executable can't be found by vim).

:! which rubocop
which: no rubocop in (/home/kaczor/.rvm/gems/ruby-2.7.2/bin:/home/kaczor/.rvm/gems/ruby-2.7.2@global/bin:/home/kaczor/.rvm/rubies/ruby-2.7.2/bin:/home/kaczor/.rvm/bin:/home/kaczor/.local/bin:/home/kaczor/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl:/var/lib/snapd/snap/bin)

I've got the ALE plugin (https://github.com/dense-analysis/ale) which should actually handle the code linting (and it did right after I've installed the rubocop - but not any more).

The problem is where my rubocop is located—it is located in: vendor/bundle/ruby/2.7.0/bin/rubocop (the folder is a part of the project).

So I should add a next path to the $PATH visible by vim ?
Or maybe there is a way to tell vim to use rvm (like call bundle exec rubocop) ? I can see that the exec is defined in my config file here:
~/.vim/bundle/ale/ale_linters/ruby/rubocop.vim

How can I add this path to ALE/vim to load it ? It would be nice if the path would be universal (so if I change the project to something different it would still work).

1 Answer 1

5

Based on :help rubocop, I would do let g:ale_ruby_rubocop_executable = 'bundle' in your config somewhere:

g:ale_ruby_rubocop_executable                   *g:ale_ruby_rubocop_executable*
                                                *b:ale_ruby_rubocop_executable*
  Type: String
  Default: `'rubocop'`

  Override the invoked rubocop binary. Set this to `'bundle'` to invoke
  `'bundle` `exec` rubocop'.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.