Switch from ruby-mode to enh-ruby-mode

This commit is contained in:
2015-10-04 12:01:14 +01:00
parent 28e2d19c1b
commit 3a4f458c7b
37 changed files with 252 additions and 1 deletions

73
modules/siren-enh-ruby.el Normal file
View File

@@ -0,0 +1,73 @@
;;
;; ruby
;;
(require 'siren-programming)
(siren-require-packages '(enh-ruby-mode ruby-tools inf-ruby yari))
;; Rake files are ruby, too, as are gemspecs, rackup files, and gemfiles.
(add-to-list 'auto-mode-alist '("\\.rb\\'" . enh-ruby-mode))
(add-to-list 'auto-mode-alist '("\\.rake\\'" . enh-ruby-mode))
(add-to-list 'auto-mode-alist '("Rakefile\\'" . enh-ruby-mode))
(add-to-list 'auto-mode-alist '("\\.gemspec\\'" . enh-ruby-mode))
(add-to-list 'auto-mode-alist '("\\.ru\\'" . enh-ruby-mode))
(add-to-list 'auto-mode-alist '("Gemfile\\'" . enh-ruby-mode))
(add-to-list 'auto-mode-alist '("Guardfile\\'" . enh-ruby-mode))
(add-to-list 'auto-mode-alist '("Capfile\\'" . enh-ruby-mode))
(add-to-list 'auto-mode-alist '("\\.cap\\'" . enh-ruby-mode))
(add-to-list 'auto-mode-alist '("\\.thor\\'" . enh-ruby-mode))
(add-to-list 'auto-mode-alist '("\\.rabl\\'" . enh-ruby-mode))
(add-to-list 'auto-mode-alist '("Thorfile\\'" . enh-ruby-mode))
(add-to-list 'auto-mode-alist '("Vagrantfile\\'" . enh-ruby-mode))
(add-to-list 'auto-mode-alist '("\\.jbuilder\\'" . enh-ruby-mode))
(add-to-list 'auto-mode-alist '("Podfile\\'" . enh-ruby-mode))
(add-to-list 'auto-mode-alist '("\\.podspec\\'" . enh-ruby-mode))
(add-to-list 'auto-mode-alist '("Puppetfile\\'" . enh-ruby-mode))
(add-to-list 'auto-mode-alist '("Berksfile\\'" . enh-ruby-mode))
(add-to-list 'auto-mode-alist '("Appraisals\\'" . enh-ruby-mode))
;; We never want to edit Rubinius bytecode
(add-to-list 'completion-ignored-extensions ".rbc")
(define-key 'help-command (kbd "R") 'yari)
;; Set up hs-mode (HideShow) for Ruby
(add-to-list 'hs-special-modes-alist
`(ruby-mode
,(rx (or "def" "class" "module" "do")) ;; Block start
,(rx (or "end")) ;; Block end
,(rx (or "#" "=begin")) ;; Comment start
ruby-forward-sexp nil))
;; I don't like having operators colored.
(custom-set-faces '(enh-ruby-op-face ((t nil))))
(eval-after-load 'enh-ruby-mode
'(progn
(defun siren-ruby-mode-defaults ()
(siren-prog-mode-defaults)
(ruby-tools-mode +1)
(setq tab-width 2)
(hs-minor-mode 1)
(company-mode +1)
(subword-mode +1)
(setq highlight-indentation-offset 2)
(highlight-indentation-mode)
(highlight-indentation-current-column-mode)
(setq enh-ruby-check-syntax nil)
(setq enh-ruby-deep-indent-paren nil)
(setq enh-ruby-bounce-deep-indent t)
(setq ruby-deep-arglist nil)
(setq c-tab-always-indent nil)
(setq ruby-use-encoding-map nil)
(define-key enh-ruby-mode-map (kbd "C-c C-h") 'toggle-hiding)
(define-key enh-ruby-mode-map (kbd "C-c C-l") 'goto-line))
(setq siren-ruby-mode-hook 'siren-ruby-mode-defaults)
(add-hook 'enh-ruby-mode-hook (lambda ()
(run-hooks 'siren-ruby-mode-hook)))))
(provide 'siren-enh-ruby)

View File

@@ -50,7 +50,7 @@
(require 'siren-go)
(require 'siren-makefile)
(require 'siren-markdown)
(require 'siren-ruby)
(require 'siren-enh-ruby)
(require 'siren-sass)
(require 'siren-scss)
(require 'siren-sh)

View File

View File

@@ -0,0 +1 @@
text-mode

View File

@@ -0,0 +1,4 @@
# name: each { |...| ... }
# key: each
# --
each { |${e}| $0 }

View File

@@ -0,0 +1,4 @@
# name: each_with_index { |e, i| ... }
# key: eachwi
# --
each_with_index { |${e}, ${i}| $0 }

View File

@@ -0,0 +1,4 @@
# name: map { |...| ... }
# key: map
# --
map { |${e}| $0 }

View File

@@ -0,0 +1,4 @@
# name: map_with_index { |...| ... }
# key: mapwi
# --
map_with_index { |${e}| $0 }

View File

@@ -0,0 +1,7 @@
# name: case ... end
# key: case
# --
case ${1:object}
when ${2:condition}
$0
end

View File

@@ -0,0 +1,5 @@
# name: else
# key: else
# --
else
$0

View File

@@ -0,0 +1,5 @@
# name: elsif
# key: elsif
# --
elsif ${1:condition}
$0

View File

@@ -0,0 +1,6 @@
# name: for ... end
# key: for
# --
for ${1:i} in ${2:length}
$0
end

View File

@@ -0,0 +1,6 @@
# name: unless ... end
# key: unless
# --
unless ${1:condition}
$0
end

View File

@@ -0,0 +1,5 @@
# name: when ... end
# key: when
# --
when ${condition}
$0

View File

@@ -0,0 +1,8 @@
# name: include Enumerable; def each ... end
# key: Enum
# --
include Enumerable
def each(&block)
$0
end

View File

@@ -0,0 +1,13 @@
# name: class ... end
# contributor: hitesh <hitesh.jasani@gmail.com>
# key: cla
# --
class ${1:`(let ((fn (capitalize (file-name-nondirectory
(file-name-sans-extension
(or (buffer-file-name)
(buffer-name (current-buffer))))))))
(cond
((string-match "_" fn) (replace-match "" nil nil fn))
(t fn)))`}
$0
end

View File

@@ -0,0 +1,6 @@
# name: class << self ... end
# key: clas
# --
class << ${self}
$0
end

View File

@@ -0,0 +1,6 @@
# name: def ... end
# key: def
# --
def ${1:method_name}
$0
end

View File

@@ -0,0 +1,6 @@
# name: def self. ... end
# key: defs
# --
def self.${1:method_name}
$0
end

View File

@@ -0,0 +1,6 @@
# name: do |variable| ... end
# key: do
# --
do $1
$0
end

View File

@@ -0,0 +1,13 @@
# name: module ... end
# contributor: hitesh <hitesh.jasani@gmail.com>, jimeh <contact@jimeh.me>
# key: mod
# --
module ${1:`(let ((fn (capitalize (file-name-nondirectory
(file-name-sans-extension
(or (buffer-file-name)
(buffer-name (current-buffer))))))))
(cond
((string-match "_" fn) (replace-match "" nil nil fn))
(t fn)))`}
$0
end

View File

@@ -0,0 +1,5 @@
# name: ruby debugger
# key: bug
# --
require 'ruby-debug'
debugger$0

View File

@@ -0,0 +1,4 @@
# name: puts debug
# key: pd
# --
puts "\n>>>>>> ${1:name}: ${2:#{${3:variable}${4:.inspect}}}\n"$0

View File

@@ -0,0 +1,5 @@
# name: pp ...
# key: pp
# --
require 'pp'
pp $0

View File

@@ -0,0 +1,4 @@
# name: puts ...; pp ...
# key: ppd
# --
puts "\n>>>>>> ${1:name}:"; pp $0

View File

@@ -0,0 +1,4 @@
# name: STDOUT.puts debug
# key: spd
# --
STDOUT.puts "\n>>>>>> ${1:name}: ${2:#{${3:variable}${4:.inspect}}}\n"$0

View File

@@ -0,0 +1,4 @@
# name: Given(...)
# key: Given
# --
Given(/^${1:match}$/)$0

View File

@@ -0,0 +1,4 @@
# name: Then(...)
# key: Then
# --
Then(/^${1:match}$/)$0

View File

@@ -0,0 +1,4 @@
# name: When(...)
# key: When
# --
When(/^${1:match}$/)$0

View File

@@ -0,0 +1,4 @@
# name: context '...'
# key: con
# --
context "$1"$0

View File

@@ -0,0 +1,4 @@
# name: describe '...'
# key: des
# --
describe "$1"$0

View File

@@ -0,0 +1,4 @@
# name: expect(...).to be ...
# key: eb
# --
expect($1).to be $0

View File

@@ -0,0 +1,4 @@
# name: expect(...).to eq(...)
# key: ee
# --
expect($1).to eq($0)

View File

@@ -0,0 +1,4 @@
# name: expect(...).to ...
# key: ex
# --
expect($1).to $0

View File

@@ -0,0 +1,4 @@
# name: require '...'
# key: re
# --
require '$1'$0

View File

@@ -0,0 +1,4 @@
# name: require '...'
# key: req
# --
require '$1'$0

View File

@@ -0,0 +1,7 @@
# name: attributes(:name => :name, :market_name => "")
# key: atr
# --
attributes(
:name => :${1:name},
:market_name => "$0"
)