Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add basic ruby contrib layer #228

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 51 additions & 0 deletions contrib/lang/ruby/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# Ruby contribution layer for Spacemacs

## Description

This layer aims at providing support for the Ruby language using
[enh-ruby-mode][] and [robe-mode][].

## Install

To use this contribution add it to your `~/.spacemacs`

```elisp
(defvar dotspacemacs-configuration-layers '(ruby)
"List of contribution to load."
)
```

In order to take advantage of `robe-mode` you will probably need to
install the `pry` gem.
You can do that via your Gemfile:

```ruby
gem 'pry'
```

or on the command line:

```shell
$ gem install pry
```

## Key bindings

### enh-ruby-mode

<kbd>SPC m i</kbd> start REPL
<kbd>SPC m g</kbd> go to definition (robe-jump)
<kbd>SPC m d</kbd> go to Documentation
<kbd>SPC m R</kbd> reload environment (Rails)

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I updated the conventions for key bindings, it gives us:

  • nothing changes here :-)

### ruby-test-mode

ruby-test-mode comes bundled with spacemacs, but this contribution adds
a couple of useful keybindings:

<kbd>SPC m t f</kbd> run test file
<kbd>SPC m t p</kbd> run test at pointer

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I updated the conventions for key bindings, it gives us:

  • m t b to test the buffer/file
  • m t f to test the function under point


[enh-ruby-mode]: https://github.com/zenspider/enhanced-ruby-mode
[robe-mode]: https://github.com/dgutov/robe
56 changes: 56 additions & 0 deletions contrib/lang/ruby/packages.el
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
(defvar ruby-packages
'(
;; package rubys go here
rbenv
enh-ruby-mode
ruby-test-mode
robe
yaml-mode
)
"List of all packages to install and/or initialize. Built-in packages
which require an initialization must be listed explicitly in the list.")

(defvar ruby-excluded-packages '(ruby-mode))

(defun ruby/init-rbenv ()
"Initialize RBENV mode"
(use-package rbenv
:init (global-rbenv-mode)
:defer t
:config (add-hook 'enh-ruby-mode-hook
(lambda () (rbenv-use-corresponding)))))

(defun ruby/init-enh-ruby-mode ()
"Initialize Enhanced Ruby Mode"
(use-package enh-ruby-mode
:defer t
:mode (("\\(rake\\|thor\\|guard\\|gem\\|cap\\|vagrant\\)file\\'" . enh-ruby-mode)
("\\.\\(rb\\|ru\\|builder\\|rake\\|thor\\|gemspec\\)\\'" . enh-ruby-mode))))

(defun ruby/init-robe ()
"Initialize Robe mode"
(use-package robe
:defer t
:init (add-hook 'enh-ruby-mode-hook 'robe-mode)
:config (progn (evil-leader/set-key-for-mode 'enh-ruby-mode "mg" 'robe-jump)
(evil-leader/set-key-for-mode 'enh-ruby-mode "md" 'robe-doc)
(evil-leader/set-key-for-mode 'enh-ruby-mode "mR" 'robe-rails-refresh)
(evil-leader/set-key-for-mode 'enh-ruby-mode "mi" 'robe-start))))

(defun ruby/init-yaml-mode ()
"Initialize YAML mode"
(use-package yaml-mode
:config (add-hook 'yaml-mode-hook
'(lambda ()
(define-key yaml-mode-map "\C-m" 'newline-and-indent)))
:defer t
:mode (("\\.\\(yml\\|yaml\\)\\'" . yaml-mode)
("Procfile\\'" . yaml-mode))))



(defun ruby/init-ruby-test-mode ()
"Define keybindings for ruby test mode"
(use-package ruby-test-mode
:config (progn (evil-leader/set-key "mtf" 'ruby-test-run)
(evil-leader/set-key "mtp" 'ruby-test-run-at-point))))