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

Adding rubocop to ruby layer #2949

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
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
11 changes: 11 additions & 0 deletions layers/+lang/ruby/README.org
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
- [[#key-bindings][Key bindings]]
- [[#ruby-enh-ruby-mode-robe-inf-ruby-ruby-tools][Ruby (enh-ruby-mode, robe, inf-ruby, ruby-tools)]]
- [[#ruby-test-mode][ruby-test-mode]]
- [[#rubocop][rubocop]]

* Description

Expand All @@ -32,6 +33,7 @@ based on your version manager):

- =pry= and =pry-doc= are required for *jump to definition* and *code documentation* (=robe-mode=)
- =ruby_parser= is required for *goto-step_definition* in =feature-mode=
- =rubocop= is required for rubocop integration

You can install the gems in the context of your current project by
adding them to the =Gemfile=, e.g.:
Expand Down Expand Up @@ -64,6 +66,7 @@ Possible values are =rbenv= and =rvm=.

** Ruby (enh-ruby-mode, robe, inf-ruby, ruby-tools)


| Key binding | Description |
|-------------+---------------------------------------------|
| ~SPC m g g~ | go to definition (robe-jump) |
Expand All @@ -88,3 +91,11 @@ a couple of useful keybindings:
|-------------+---------------------|
| ~SPC m t b~ | run test file |
| ~SPC m t t~ | run test at pointer |

** rubocop

| Key binding | Description |
|---------------+-------------------------------|
| ~SPC m r a F~ | autocorrect current file |
| ~SPC m r a D~ | autocorrect current directory |
| ~SPC m r a P~ | autocorrect current project |
14 changes: 13 additions & 1 deletion layers/+lang/ruby/packages.el
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
flycheck
robe
ruby-test-mode
ruby-tools))
ruby-tools
rubocop))

(when ruby-version-manager
(add-to-list 'ruby-packages ruby-version-manager))
Expand Down Expand Up @@ -127,6 +128,17 @@
(evil-leader/set-key-for-mode 'enh-ruby-mode "mtb" 'ruby-test-run)
(evil-leader/set-key-for-mode 'enh-ruby-mode "mtt" 'ruby-test-run-at-point))))

(defun ruby/init-rubocop ()
(use-package rubocop
:defer t
:init (add-hook 'enh-ruby-mode-hook 'rubocop-mode)
:config
(progn
(evil-leader/set-key-for-mode 'enh-ruby-mode "mraD" 'rubocop-autocorrect-directory)
(evil-leader/set-key-for-mode 'enh-ruby-mode "mraP" 'rubocop-autocorrect-project)
(evil-leader/set-key-for-mode 'enh-ruby-mode "mraF" 'rubocop-autocorrect-current-file)
)))

(when (configuration-layer/layer-usedp 'auto-completion)
(defun ruby/post-init-company ()
(spacemacs|add-company-hook enh-ruby-mode)
Expand Down