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 committed Sep 8, 2015
1 parent b8f3d39 commit 213f286
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
14 changes: 14 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 @@ -87,3 +90,14 @@ 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~ | check current file |
| ~SPC m r a d~ | check current directory |
| ~SPC m r a p~ | check current project |
| ~SPC m r a F~ | autocorrect current file |
| ~SPC m r a D~ | autocorrect current directory |
| ~SPC m r a P~ | autocorrect current project |
17 changes: 16 additions & 1 deletion layers/!lang/ruby/packages.el
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,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 @@ -116,6 +117,20 @@
(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 "mrap" 'rubocop-check-project)
(evil-leader/set-key-for-mode 'enh-ruby-mode "mrad" 'rubocop-check-directory)
(evil-leader/set-key-for-mode 'enh-ruby-mode "mraf" 'rubocop-check-current-file)
(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

0 comments on commit 213f286

Please sign in to comment.