mirror of
https://github.com/jimeh/.emacs.d.git
synced 2026-02-19 13:46:41 +00:00
Add basic rubocop compilation commands for ruby-mode
And remove old and very hacked together rubocop auto-correct on save module.
This commit is contained in:
@@ -7,7 +7,7 @@
|
||||
'(magit-commit-arguments (quote ("-S")))
|
||||
'(package-selected-packages
|
||||
(quote
|
||||
(zoom-window yasnippet-snippets yari yaml-mode which-key web-mode use-package toggle-quotes thrift string-inflection smex smartparens smart-shift smart-mode-line slim-mode seeing-is-believing scss-mode sass-mode rust-playground ruby-tools ruby-refactor ruby-compilation rspec-mode robe rjsx-mode resize-window rainbow-mode racer prettier-js plantuml-mode php-mode phi-search neotree multiple-cursors move-dup markdown-mode magit-gh-pulls lua-mode linum-relative json-mode imenu-anywhere ido-vertical-mode ido-completing-read+ highlight-symbol highlight-indentation highlight-indent-guides helm-swoop helm-projectile helm-open-github helm-gtags helm-describe-modes helm-descbinds helm-ag go-projectile go-playground gitignore-mode github-browse-file gitconfig-mode git-timemachine git-link full-ack flycheck-rust flycheck-gometalinter fill-column-indicator feature-mode expand-region exec-path-from-shell evil eslintd-fix editorconfig dumb-jump doom-themes dockerfile-mode direx diminish diff-hl company-go coffee-mode cargo buffer-move browse-kill-ring anzu ace-window))))
|
||||
(zoom-window yasnippet-snippets yari yaml-mode which-key web-mode use-package toggle-quotes thrift string-inflection smex smartparens smart-shift smart-mode-line slim-mode seeing-is-believing scss-mode sass-mode rust-playground ruby-tools ruby-refactor ruby-compilation rubocop rspec-mode robe rjsx-mode resize-window rainbow-mode racer prettier-js plantuml-mode php-mode phi-search neotree multiple-cursors move-dup markdown-mode magit-gh-pulls lua-mode linum-relative json-mode imenu-anywhere ido-vertical-mode ido-completing-read+ highlight-symbol highlight-indentation highlight-indent-guides helm-swoop helm-projectile helm-open-github helm-gtags helm-describe-modes helm-descbinds helm-ag go-projectile go-playground gitignore-mode github-browse-file gitconfig-mode git-timemachine git-link full-ack flycheck-rust flycheck-gometalinter fill-column-indicator feature-mode expand-region exec-path-from-shell evil eslintd-fix editorconfig dumb-jump doom-themes dockerfile-mode direx diminish diff-hl company-go coffee-mode cargo buffer-move browse-kill-ring anzu ace-window))))
|
||||
(custom-set-faces
|
||||
;; custom-set-faces was added by Custom.
|
||||
;; If you edit it by hand, you could mess it up, so be careful.
|
||||
|
||||
@@ -113,6 +113,17 @@
|
||||
:config
|
||||
(rspec-install-snippets))
|
||||
|
||||
(use-package rubocop
|
||||
:defer t
|
||||
:after ruby-mode
|
||||
:bind (:map ruby-mode-map
|
||||
("C-c . f" . rubocop-check-current-file)
|
||||
("C-c . p" . rubocop-check-project)
|
||||
("C-c . d" . rubocop-check-directory)
|
||||
("C-c . F" . rubocop-autocorrect-current-file)
|
||||
("C-c . P" . rubocop-autocorrect-project)
|
||||
("C-c . D" . rubocop-autocorrect-directory)))
|
||||
|
||||
(use-package rubocopfmt
|
||||
:ensure nil ;; loaded from vendor
|
||||
:commands (rubocopfmt rubocopfmt-mode)
|
||||
|
||||
@@ -1,71 +0,0 @@
|
||||
;;; siren-rubocop.el --- jimeh's Emacs Siren: rubocop-mode configuration.
|
||||
|
||||
;;; Commentary:
|
||||
|
||||
;; Basic configuration for rubocop-mode.
|
||||
|
||||
;;; Code:
|
||||
|
||||
(use-package rubocop
|
||||
:defer t
|
||||
:bind (:map rubocop-mode-map
|
||||
("C-c C-f" . siren-rubocop-autocorrect))
|
||||
|
||||
:hook
|
||||
(rubocop-mode . siren-rubocop-mode-setup)
|
||||
(after-save . siren-rubocop-autocorrect-hook)
|
||||
|
||||
:init
|
||||
(defun siren-rubocop-mode-setup ())
|
||||
|
||||
:config
|
||||
(defgroup siren-rubocop nil
|
||||
"Rubocop options specific to Siren."
|
||||
:group 'siren)
|
||||
|
||||
(defcustom siren-rubocop-autocorrect-on-save t
|
||||
"Auto-correct files with rubocop when saving."
|
||||
:group 'siren-rubocop
|
||||
:type 'boolean)
|
||||
|
||||
(defadvice compilation-start
|
||||
(around inhibit-display
|
||||
(command &optional mode name-function highlight-regexp))
|
||||
(if (not (string-match "^\\(find\\|grep\\)" command))
|
||||
(flet ((display-buffer)
|
||||
(set-window-point)
|
||||
(goto-char))
|
||||
(fset 'display-buffer 'ignore)
|
||||
(fset 'goto-char 'ignore)
|
||||
(fset 'set-window-point 'ignore)
|
||||
(save-window-excursion
|
||||
ad-do-it))
|
||||
ad-do-it))
|
||||
|
||||
(defun siren-rubocop-autocorrect ()
|
||||
"Auto-correct with Rubocop and instantly revert buffer."
|
||||
(interactive)
|
||||
(if siren-rubocop-autocorrect-on-save
|
||||
(save-buffer)
|
||||
(siren-rubocop-autocorrect-p t)))
|
||||
|
||||
(defun siren-rubocop-autocorrect-p (force-save)
|
||||
"Auto-correct with Rubocop and instantly revert buffer.
|
||||
|
||||
If FORCE-SAVE is nil then file will not be saved before
|
||||
auto-correction is triggered."
|
||||
(if force-save (save-buffer))
|
||||
(ad-activate 'compilation-start)
|
||||
(rubocop-autocorrect-current-file)
|
||||
(ad-deactivate 'compilation-start)
|
||||
;; doesn't work, buffer just updates a few seconds later via auto-revert.
|
||||
;; (revert-buffer t t)
|
||||
)
|
||||
|
||||
(defun siren-rubocop-autocorrect-hook ()
|
||||
"Siren's Rubocop auto-correct hook."
|
||||
(if siren-rubocop-autocorrect-on-save
|
||||
(siren-rubocop-autocorrect-p nil))))
|
||||
|
||||
(provide 'siren-rubocop)
|
||||
;;; siren-rubocop.el ends here
|
||||
Reference in New Issue
Block a user