Skip to content

Commit

Permalink
ruby: update RuboCop bindings
Browse files Browse the repository at this point in the history
Make them available in both ruby-mode and enh-ruby-mode
  • Loading branch information
syl20bnr committed Nov 27, 2015
1 parent 3d64532 commit 5b99a60
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 14 deletions.
17 changes: 10 additions & 7 deletions layers/+lang/ruby/README.org
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,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]]
- [[RuboCop][RuboCop]]

* Description
This layer provides support for the Ruby language with [[https://github.com/zenspider/enhanced-ruby-mode][enh-ruby-mode]] and [[https://github.com/dgutov/robe][robe-mode]].
Expand Down Expand Up @@ -97,10 +97,13 @@ a couple of useful keybindings:
| ~SPC m t b~ | run test file |
| ~SPC m t t~ | run test at pointer |

** rubocop
** 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 |
| Key binding | Description |
|---------------+------------------------------------------------------|
| ~SPC m r r f~ | Runs RuboCop on the currently visited file |
| ~SPC m r r F~ | Runs auto-correct on the currently visited file |
| ~SPC m r r d~ | Prompts from a directory on which to run RuboCop |
| ~SPC m r r D~ | Prompts for a directory on which to run auto-correct |
| ~SPC m r r p~ | Runs RuboCop on the entire project |
| ~SPC m r r P~ | Runs auto-correct on the project |
22 changes: 15 additions & 7 deletions layers/+lang/ruby/packages.el
Original file line number Diff line number Diff line change
Expand Up @@ -156,19 +156,27 @@
(spacemacs|hide-lighter ruby-test-mode)
(dolist (mode '(ruby-mode enh-ruby-mode))
(spacemacs/declare-prefix-for-mode mode "mt" "ruby/test")
(spacemacs/set-leader-keys-for-major-mode mode "tb" 'ruby-test-run)
(spacemacs/set-leader-keys-for-major-mode mode "tt" 'ruby-test-run-at-point)))))
(spacemacs/set-leader-keys-for-major-mode mode
"tb" 'ruby-test-run)
(spacemacs/set-leader-keys-for-major-mode mode
"tt" 'ruby-test-run-at-point)))))

(defun ruby/init-rubocop ()
(use-package rubocop
:defer t
:init (add-hook 'enh-ruby-mode-hook 'rubocop-mode)
:init (spacemacs/add-to-hooks 'rubocop-mode '(ruby-mode-hook
enh-ruby-mode-hook))
: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)
)))
(dolist (mode '(ruby-mode enh-ruby-mode))
(spacemacs/declare-prefix-for-mode mode "mr" "ruby/refactor")
(spacemacs/set-leader-keys-for-major-mode mode
"rrd" 'rubocop-check-directory
"rrD" 'rubocop-autocorrect-directory
"rrf" 'rubocop-check-current-file
"rrF" 'rubocop-autocorrect-current-file
"rrp" 'rubocop-check-project
"rrP" 'rubocop-autocorrect-project)))))

(when (configuration-layer/layer-usedp 'auto-completion)
(defun ruby/post-init-company ()
Expand Down

0 comments on commit 5b99a60

Please sign in to comment.