2022-03-28 15:03:21 +02:00
|
|
|
#+title: :lang ruby
|
|
|
|
#+subtitle: 1.step {|i| p "Ruby is #{i.even? ? 'love' : 'life'}"}
|
|
|
|
#+created: January 16, 2007
|
|
|
|
#+since: 1.3
|
2021-10-16 01:28:32 +02:00
|
|
|
|
|
|
|
* Description :unfold:
|
2020-03-09 02:34:02 +00:00
|
|
|
This module add Ruby and optional Ruby on Rails support to Emacs.
|
|
|
|
|
2022-09-26 02:19:42 +08:00
|
|
|
- Code completion ([[doom-package:robe]])
|
|
|
|
- Syntax checking ([[doom-package:flycheck]])
|
|
|
|
- Jump-to-definitions ([[doom-package:robe]])
|
2021-10-16 01:28:32 +02:00
|
|
|
- Bundler
|
2022-09-26 02:19:42 +08:00
|
|
|
- Rubocop integration ([[doom-package:flycheck]])
|
2021-10-16 01:28:32 +02:00
|
|
|
|
|
|
|
** Maintainers
|
|
|
|
- [[doom-user:][@hlissner]]
|
|
|
|
|
|
|
|
[[doom-contrib-maintainer:][Become a maintainer?]]
|
|
|
|
|
|
|
|
** Module flags
|
|
|
|
- +chruby ::
|
|
|
|
Enable chruby integration.
|
|
|
|
- +lsp ::
|
2022-09-26 02:19:42 +08:00
|
|
|
Enable LSP support for ~ruby-mode~. Requires [[doom-module::tools lsp]] and a langserver
|
2021-10-16 01:28:32 +02:00
|
|
|
(supports solargraph).
|
|
|
|
- +rails ::
|
|
|
|
Enable rails navigational commands, plus server+console integration.
|
|
|
|
- +rbenv ::
|
|
|
|
Enable rbenv integration.
|
|
|
|
- +rvm ::
|
|
|
|
Enable RVM (Ruby Version Manager) integration.
|
2022-04-09 18:38:04 +03:00
|
|
|
- +tree-sitter ::
|
|
|
|
Leverages tree-sitter for better syntax highlighting and structural text
|
2022-09-26 02:19:42 +08:00
|
|
|
editing. Requires [[doom-module::tools tree-sitter]].
|
2020-03-09 02:34:02 +00:00
|
|
|
|
|
|
|
** Packages
|
2022-09-26 02:19:42 +08:00
|
|
|
- [[doom-package:bundler]]
|
|
|
|
- [[doom-package:chruby]] if [[doom-module:+chruby]]
|
|
|
|
- [[doom-package:company-inf-ruby]] if :completion company
|
|
|
|
- [[doom-package:inf-ruby]]
|
|
|
|
- [[doom-package:minitest]]
|
|
|
|
- [[doom-package:rake]]
|
|
|
|
- [[doom-package:rbenv]] if [[doom-module:+rbenv]]
|
|
|
|
- [[doom-package:robe]]
|
|
|
|
- [[doom-package:rspec-mode]]
|
|
|
|
- [[doom-package:rubocop]]
|
|
|
|
- [[doom-package:rvm]] if [[doom-module:+rvm]]
|
|
|
|
- if [[doom-module:+rails]]
|
|
|
|
- [[doom-package:inflections]]
|
|
|
|
- [[doom-package:projectile-rails]]
|
2021-10-16 01:28:32 +02:00
|
|
|
|
|
|
|
** Hacks
|
|
|
|
/No hacks documented for this module./
|
|
|
|
|
|
|
|
** TODO Changelog
|
|
|
|
# This section will be machine generated. Don't edit it by hand.
|
|
|
|
/This module does not have a changelog yet./
|
|
|
|
|
2023-07-22 19:07:03 +02:00
|
|
|
|
2021-10-16 01:28:32 +02:00
|
|
|
* Installation
|
|
|
|
[[id:01cffea4-3329-45e2-a892-95a384ab2338][Enable this module in your ~doom!~ block.]]
|
|
|
|
|
|
|
|
This module requires Ruby and the Rubocop gem. It is recommended you install
|
|
|
|
both with some version manager (RVM or Rbenv).
|
|
|
|
|
|
|
|
These guides will help you install Ruby:
|
|
|
|
- [[https://gorails.com/setup/ubuntu/18.04][Ubuntu]]
|
|
|
|
- [[https://gorails.com/setup/osx/10.15-catalina][MacOS]]
|
|
|
|
- [[https://gorails.com/setup/windows/10][Windows]]
|
|
|
|
|
|
|
|
Then run ~$ gem install rubocop~ to install rubocop.
|
|
|
|
|
2022-11-19 14:51:29 +00:00
|
|
|
** Formatter
|
|
|
|
|
|
|
|
Formatting is handled using the [[doom-module::editor format]] module via [[https://prettier.io/docs/en/install.html][prettier]].
|
|
|
|
|
2021-10-16 01:28:32 +02:00
|
|
|
* TODO Usage
|
|
|
|
#+begin_quote
|
|
|
|
🔨 /This module's usage documentation is incomplete./ [[doom-contrib-module:][Complete it?]]
|
|
|
|
#+end_quote
|
|
|
|
|
2020-03-09 02:34:02 +00:00
|
|
|
** Commands
|
|
|
|
*** robe
|
2021-10-16 01:28:32 +02:00
|
|
|
| command | key / ex command | description |
|
|
|
|
|----------------------+--------------------+--------------------------------------------------------------------|
|
|
|
|
| ~robe-start~ | [[kbd:][<localleader> ']] | Open ruby lang server for auto-completions and jump to definitions |
|
|
|
|
| ~robe-rails-refresh~ | [[kbd:][<localleader> R]] | Refresh the lang server. |
|
2020-03-09 02:34:02 +00:00
|
|
|
|
|
|
|
*** projectile-rails
|
2021-10-16 01:28:32 +02:00
|
|
|
The projectile-rails prefix is [[kbd:][<localleader> r]]:
|
|
|
|
| command | key / ex command | description |
|
|
|
|
|-------------------------------+-------------------+---------------------------------------------------|
|
|
|
|
| ~projectile-rails-console~ | [[kbd:][<localleader> r r]] | Open Rails console |
|
|
|
|
| ~projectile-rails-server~ | [[kbd:][<localleader> r R]] | Open Rails server |
|
|
|
|
| ~projectile-rails-find-model~ | [[kbd:][<localleader> r m]] | Find any model of the project |
|
|
|
|
| ~projectile-rails-find-model~ | [[kbd:][<localleader> r M]] | Find the model related of currently open resource |
|
|
|
|
|
2020-03-09 02:34:02 +00:00
|
|
|
*** bundler
|
2021-10-16 01:28:32 +02:00
|
|
|
The bundler prefix is [[kbd:][<localleader> b]]:
|
|
|
|
| command | key / ex command | description |
|
|
|
|
|------------------+-------------------+---------------------|
|
|
|
|
| ~bundle-install~ | [[kbd:][<localleader> b i]] | Runs bundle install |
|
|
|
|
| ~bundle-update~ | [[kbd:][<localleader> b u]] | Runs bundle update |
|
2020-03-09 02:34:02 +00:00
|
|
|
|
|
|
|
*** rspec-mode
|
2021-10-16 01:28:32 +02:00
|
|
|
The rspec-mode prefix is [[kbd:][<localleader> t]]:
|
2020-03-09 02:34:02 +00:00
|
|
|
| command | key / ex command | description |
|
|
|
|
|-----------------------+------------------+-----------------------------------|
|
|
|
|
| ~rspec-verify~ | =SPC m t v= | Runs rspec on current file |
|
2020-05-16 18:13:44 -03:00
|
|
|
| ~rspec-verify-method~ | =SPC m t s= | Runs rspec for the item on cursor |
|
2021-10-16 01:28:32 +02:00
|
|
|
|
|
|
|
* TODO Configuration
|
|
|
|
#+begin_quote
|
|
|
|
🔨 This module has no configuration documentation yet. [[doom-contrib-module:][Write some?]]
|
|
|
|
#+end_quote
|
|
|
|
|
|
|
|
* Troubleshooting
|
|
|
|
/There are no known problems with this module./ [[doom-report:][Report one?]]
|
|
|
|
|
2023-07-22 19:07:03 +02:00
|
|
|
** Known imenu issues
|
|
|
|
These are recorded issues with ruby-mode's imenu integration that need to be
|
|
|
|
addressed upstream. PRs to fix them locally are welcome.
|
|
|
|
|
|
|
|
- Incorrectly parses methods/items after an array accessor [[https://github.com/ruby/ruby/pull/2996/files][endless method]]
|
|
|
|
definition (Ruby 3+):
|
|
|
|
#+begin_src ruby
|
|
|
|
class Foo
|
|
|
|
def bar; end
|
|
|
|
def baz; end
|
|
|
|
def [](key) = x + x
|
|
|
|
def wop; end
|
|
|
|
def gop; end
|
|
|
|
end
|
|
|
|
#+end_src
|
|
|
|
|
|
|
|
Imenu will list =Foo#bar=, =Foo#baz=, and =Foo#[]= but stops there, sometimes
|
|
|
|
listing the rest as if there were top-level.
|
|
|
|
|
|
|
|
- Does not recognize inline Struct definitions as classes:
|
|
|
|
#+begin_src ruby
|
|
|
|
Foo = Struct.new(:a, :b, :c) do
|
|
|
|
def test; end
|
|
|
|
end
|
|
|
|
#+end_src
|
|
|
|
|
|
|
|
Imenu should recognize this method as =Foo#test=, not =test=. ~class Foo <
|
|
|
|
Struct.new(...)~ is not an acceptable workaround because it creates an
|
|
|
|
intermediary class (i.e. has side-effects).
|
|
|
|
|
2021-10-16 01:28:32 +02:00
|
|
|
* Frequently asked questions
|
|
|
|
/This module has no FAQs yet./ [[doom-suggest-faq:][Ask one?]]
|
|
|
|
|
|
|
|
* TODO Appendix
|
|
|
|
#+begin_quote
|
|
|
|
🔨 This module has no appendix yet. [[doom-contrib-module:][Write one?]]
|
|
|
|
#+end_quote
|