ruby extension added
This commit is contained in:
parent
4ef4470266
commit
6d686cbc32
|
@ -4,6 +4,7 @@
|
|||
|
||||
(activate-extensions 'editor
|
||||
'development
|
||||
'web)
|
||||
'web
|
||||
'ruby)
|
||||
|
||||
(fg42-initialize)
|
||||
|
|
|
@ -29,7 +29,8 @@
|
|||
(setq company-tooltip-align-annotations 't)
|
||||
|
||||
;; Decrease delay before autocompletion popup shows
|
||||
(setq company-idle-delay 0.3)
|
||||
(setq company-idle-delay 0.1)
|
||||
(setq company-minimum-prefix-length 2)
|
||||
|
||||
;; Start autocompletion only after typing
|
||||
(setq company-begin-commands '(self-insert-command))
|
||||
|
|
|
@ -3,15 +3,25 @@
|
|||
(require 'extensions/ruby/init)
|
||||
|
||||
;; Dependencies ----------------------------------
|
||||
(depends-on 'company-ruby)
|
||||
(depends-on 'company-inf-ruby)
|
||||
(depends-on 'ruby-mode)
|
||||
(depends-on 'rbenv)
|
||||
(depends-on 'slim-mode)
|
||||
(depends-on 'haml-mode)
|
||||
|
||||
(depends-on 'inf-ruby)
|
||||
(depends-on 'ruby-tools)
|
||||
(depends-on 'yaml-mode)
|
||||
(depends-on 'ruby-electric)
|
||||
(depends-on 'bundler)
|
||||
(depends-on 'feature-mode)
|
||||
(depends-on 'rspec-mode)
|
||||
(depends-on 'projectile-rails)
|
||||
(depends-on 'robe)
|
||||
(depends-on 'yari)
|
||||
|
||||
;; Extension -------------------------------------
|
||||
(extension ruby
|
||||
:version "2.67"
|
||||
:on-initialize extension/ruby-initialize)
|
||||
:on-initialize extensions/ruby-initialize)
|
||||
|
||||
(provide 'extensions/ruby)
|
||||
|
|
|
@ -0,0 +1,108 @@
|
|||
;; Functions -------------------------------------------------
|
||||
|
||||
;;;###autoload
|
||||
(defun ruby-mode-callback ()
|
||||
(require 'bundler)
|
||||
(robe-mode t)
|
||||
|
||||
(local-set-key [f1] 'yari)
|
||||
(global-rbenv-mode)
|
||||
(global-set-key (kbd "C-c r r") 'inf-ruby)
|
||||
|
||||
(define-key ruby-mode-map (kbd "\C-c b i") 'bundle-install)
|
||||
(define-key ruby-mode-map (kbd "\C-c b u") 'bundle-update)
|
||||
(define-key ruby-mode-map (kbd "\C-c b e") 'bundle-exec)
|
||||
(define-key ruby-mode-map (kbd "\C-c b o") 'bundle-open)
|
||||
(define-key ruby-mode-map (kbd "\C-c b c") 'bundle-console)
|
||||
|
||||
(push 'company-robe company-backends)
|
||||
(eval-after-load 'rspec-mode
|
||||
'(rspec-install-snippets))
|
||||
|
||||
(setq irbparams " --inf-ruby-mode -r irb/completion")
|
||||
(setq irbpath (rbenv--expand-path "shims" "irb"))
|
||||
(setq irb (concat irbpath irbparams))
|
||||
(add-to-list 'inf-ruby-implementations (cons "ruby" irb))
|
||||
(inf-ruby-minor-mode t)
|
||||
|
||||
(eval-after-load 'company
|
||||
'(add-to-list 'company-backends 'company-inf-ruby))
|
||||
|
||||
(with-ability auto-pair
|
||||
;; Disable autopaire
|
||||
;;(autopair-global-mode -1))
|
||||
)
|
||||
|
||||
(ruby-tools-mode t)
|
||||
(ruby-electric-mode t)
|
||||
(define-key ruby-mode-map (kbd "C-.") 'insert-arrow)
|
||||
(global-set-key (kbd "C-c r r") 'inf-ruby)
|
||||
|
||||
;; Enable flycheck
|
||||
;;(flycheck-mode t)
|
||||
|
||||
;; hs mode
|
||||
;;(hs-minor-mode t)
|
||||
;; Hack autocomplete so it treat :symbole and symbole the same way
|
||||
(modify-syntax-entry ?: "."))
|
||||
|
||||
|
||||
;;;###autoload
|
||||
(defun insert-arrow ()
|
||||
(interactive)
|
||||
(delete-horizontal-space t)
|
||||
(insert " => "))
|
||||
|
||||
;;;###autoload
|
||||
(defun extensions/ruby-initialize ()
|
||||
"Web development plugin initialization."
|
||||
(message "Initializing 'ruby' extension.")
|
||||
|
||||
(ability ruby-editor ('flycheck)
|
||||
"Gives FG42 the ability to edit ruby files."
|
||||
(add-to-list 'auto-mode-alist '("\\.rake$" . ruby-mode))
|
||||
(add-to-list 'auto-mode-alist '("Gemfile$" . ruby-mode))
|
||||
(add-to-list 'auto-mode-alist '("Rakefile$" . ruby-mode))
|
||||
(add-to-list 'auto-mode-alist '("gemspec$" . ruby-mode))
|
||||
(add-to-list 'auto-mode-alist '("config.ru$" . ruby-mode))
|
||||
(add-to-list 'auto-mode-alist '("json.jbuilder$" . ruby-mode))
|
||||
|
||||
(add-to-list 'auto-mode-alist '("\\.yml$" . yaml-mode))
|
||||
(add-hook 'yaml-mode-hook
|
||||
'(lambda ()
|
||||
(define-key yaml-mode-map "\C-m" 'newline-and-indent)))
|
||||
|
||||
;; Inf Ruby configuration
|
||||
(autoload 'inf-ruby "inf-ruby" "Run an inferior Ruby process" t)
|
||||
(add-hook 'ruby-mode-hook 'ruby-mode-callback)
|
||||
(add-hook 'after-init-hook 'inf-ruby-switch-setup)
|
||||
|
||||
;; configure hs-minor-mode
|
||||
(add-to-list 'hs-special-modes-alist
|
||||
'(ruby-mode
|
||||
"\\(class\\|def\\|do\\|if\\)" "\\(end\\)" "#"
|
||||
(lambda (arg) (ruby-end-of-block)) nil))
|
||||
|
||||
(add-hook 'ruby-mode-hook 'projectile-mode))
|
||||
|
||||
|
||||
(ability slim-mode ()
|
||||
"Gives FG42 the ability to edit slim templates."
|
||||
(add-to-list 'auto-mode-alist '("\\.slim$" . slim-mode)))
|
||||
|
||||
(ability haml-mode ()
|
||||
"Gives FG42 the ability to edit haml templates."
|
||||
(add-to-list 'auto-mode-alist '("\\.haml$" . haml-mode)))
|
||||
|
||||
(ability cucumber ()
|
||||
"Gives FG42 the ability to works with Cucumber."
|
||||
(autoload 'feature-mode "feature-mode"
|
||||
"Emacs mode for editing Cucumber plain text stories")
|
||||
(add-to-list 'auto-mode-alist '("\.feature$" . feature-mode)))
|
||||
|
||||
(ability rails-projects ()
|
||||
"Gives FG42 the ability to manage rails projects."
|
||||
(add-hook 'projectile-mode-hook 'projectile-rails-on)))
|
||||
|
||||
|
||||
(provide 'extensions/ruby/init)
|
|
@ -14,8 +14,6 @@
|
|||
(depends-on 'js2-mode)
|
||||
(depends-on 'js2-refactor)
|
||||
(depends-on 'rainbow-mode)
|
||||
;(depends-on 'slim-mode)
|
||||
;(depends-on 'haml-mode)
|
||||
(depends-on 'mustache-mode)
|
||||
|
||||
;; Extension -------------------------------------
|
||||
|
|
|
@ -32,7 +32,7 @@
|
|||
to them.
|
||||
|
||||
*body* is a block of code which will run as the ability initializer code."
|
||||
(declare (doc-string 2) (indent 1))
|
||||
(declare (doc-string 2) (indent 0))
|
||||
`(if (active-ability? (intern ,(symbol-name name)))
|
||||
(when (null (delq t (mapcar 'active-ability? (quote ,deps))))
|
||||
,@body)))
|
||||
|
|
Loading…
Reference in New Issue