Skip to content

Commit

Permalink
Adding rubocop to ruby layer
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel Luna authored and syl20bnr committed Nov 27, 2015
1 parent 3624ff2 commit 3d64532
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
10 changes: 10 additions & 0 deletions layers/+lang/ruby/README.org
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +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]]

* 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 @@ -39,6 +40,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 @@ -94,3 +96,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 |
15 changes: 14 additions & 1 deletion layers/+lang/ruby/packages.el
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@
flycheck
robe
ruby-test-mode
ruby-tools))
ruby-tools
rubocop
))

(if ruby-enable-enh-ruby-mode
(add-to-list 'ruby-packages 'enh-ruby-mode)
Expand Down Expand Up @@ -157,6 +159,17 @@
(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)
: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 ruby-mode)
Expand Down

0 comments on commit 3d64532

Please sign in to comment.