Recommendation for Emacs/Ruby setup - ruby

So far I'm very happy with my Clojure/Emacs setup but failed to come even close to this experience when using Ruby. I tried the enhanced ruby mode (no syntax highlighting) and robe (which fails with a syntax error as soon as the console is started). I would really appreciate any tips where to find some proper guidelines on how to configure Emacs for Ruby.
BTW: I do not need any Rails support. Just plain Ruby support.

I find the following setup quite good:
ruby-mode from Emacs 24.4 or above - it's quite an improvement over the one in Emacs 24.3
inf-ruby - a way to run irb/pry inside Emacs
smartparens - superb handling of delimiters like (), [], {}, do/end, etc.
yari - ri interface for Emacs
ruby-tools - adds commands to turn a string to symbol, symbol to string, single to double quote string, double to single quote string, clear string, interpolate and more...
flycheck + RuboCop for on-the-fly linting and code style checking
AFAIK many rubyists are also using yasnippet. I've given up on trying to find a good "intelli-sense" alternative for Ruby in Emacs, but other than that I'd say the above setup is quite solid. It's pretty much what you'd get by using Prelude's Ruby module.

This isn't a real answer since I'm not a Ruby user but I am tied into the Emacs community and these things have shown up on my radar before
http://www.emacswiki.org/emacs/RubyLanguage (the wiki, although sometimes out of date, is a good place to start from for queries like this).
http://crypt.codemancers.com/posts/2013-09-26-setting-up-emacs-as-development-environment-on-osx/ was recently on HN and has a detailed setup.
Sacha Chua's chat with Avdi Grimm mentions a few of the tools that Avdi uses for his Ruby work.

Related

Where can I compile my ruby code?

I started programming on ruby at codecademy but where can I compile my codes on doing a website?
When I was making some lessons on C I used codeblocks to run codes. I know any text editor can run a HTML code. So what about ruby?
Thank you.
I'll take a stab at answering the question that I think you're asking, but I'm not 100% sure here.
Ruby is an interpreted language (what does that mean? Not a whole lot nowadays. If you'd like a more in depth discussion on the distinction or lack thereof between interpreting vs compiling, read Jorg's comments below). To execute ruby code, you'll need to install ruby. Fortunately for you, this is freely available on any major platform. If you're on something unix-y (eg, linux or mac), I'd strongly recommend installing ruby via something like rvm or rbenv. If you're on windows, you can either go the cygwin route and pretend it's a unix-y environment, or there are prebuilt installers out there. Googling 'install ruby' should have some sites that can help you at or near the top of the search results.

Vim's Ruby option is not enabled

I just started learning Ruby and I ran this command:
vim --version
The output looks like this (look at the yellow circle):
Which means that my Vim does not include the 'ruby' function.
But it seems my Vim supports Ruby fairly well:
q1: Is there any problem with my Ruby programming with the -ruby?
q2: How can I enable Ruby function in Vim?
The functionality on the second screenshot is given by installing the vim-ruby plugin.
The internal Ruby support is to allow people to write plugins and scripts for Vim using Ruby and it's not strictly necessary for what you seem to want to accomplish.
If you REALLY want to add Ruby support, you can always build Vim from source (or get a package with it already built). I suggest you to look into Vim's homepage for more info on this matter.
The difference you are missing is between using Vim to program in a language such as Ruby, and using a given language to program Vim.
Writing Ruby code using Vim is enabled by Vim's native syntax files, as well as various third-party plugins available for Vim. This is the case for many, many languages, not only those mentioned in the :version screen (Perl, Python, and Ruby). You can use Vim to write code in C, Scala, PHP, Javascript, and many other languages, with support for syntax highlighting, smart indenting, and so on.
Writing Vim functions and plugins can only be done in a small set of languages. Natively, Vim code is always written in its own language, Vimscript. However, Vimscript is notoriously difficult to deal with, and most people will not already know it. So Vim also has the ability to use plugins written in other languages, such as Python or Ruby. This enables people to use a more familiar language for plugin development.
However, using those languages requires binding to an interpreter for the language, and this must be decided at the time Vim is compiled. The :version screen is telling you that for your installation of Vim, the Ruby support was not enabled, so you can not write plugins using Ruby, nor can you use any available plugins which were written in Ruby.
Notice that +python is present, so you can use Python plugins (but -python3 is there too, meaning that you do not have Python 3.x support built in).

how do I install ruby-mode for emacs

I have just installed emacs for fedora.I want to use emacs to write ruby. What are the tools,extensions needed that provide me code hinting,code completion type features for ruby ?
ruby-mode is already included from Emacs 23 onwards. It's also available via ELPA though. Some other things you might be interested in are integrating RVM, feature-mode (Cucumber), rspec-mode, ruby-electric, inf-ruby, rinari (for Rails) etc. Here's my current Emacs configuration for Ruby development:
https://github.com/citizen428/emacs.d/blob/master/config/ruby-conf.el
I also wrote a blog post on this topic once, it's a bit outdated and my config has changed since then, but it's better documented and maybe helps you in getting started:
http://www.citizen428.net/blog/2010/07/06/emacs-for-rubyists
If you use yasnippet you can find Ruby completions here: https://github.com/bmaland/yasnippet-ruby-mode
If you are completely new to Emacs, you might want to start out with Emacs Prelude or the Starter Kit:
Emacs Prelude
emacs-starter-kit

Simple Ruby Editor?

This editor isn't intended for me. It's intended for teaching someone else Ruby. I largely use Emacs when writing Ruby. Does anyone know of an editor that
indents the current line correctly when you press tab,
can indent the whole file correctly (keyboard shortcut would be nice),
has syntax highlighting for Ruby,
other than that works kind of like Windows Notepad (maybe with a toolbar of icons),
has a built in terminal (not absolutely required),
has multiple editor tabs,
and works on Windows, Linux, or both?
Or anything somewhat close?
Edit:
I'm also going to add that I'd like to be available for free (legally for an indefinite period of time). Open source wouldn't hurt.
Check Notepad++
I don't think that jEdit has a built-in terminal, but I believe it does everything else you need. It's implemented in Java, so it should run on any platform for which a JVM exists, including Windows and Linux.
Since it's about teaching ruby RedCar and Diakonos are good choices. They have most of the features you mention and as a bonus both are written in Ruby.
If you are not a die hard fan of emacs, then there's always vim and its plugins for any programming language. Here's one for Ruby: rails.vim : Ruby on Rails: easy file navigation, enhanced syntax highlighting, and more
If you are new to vim, this cheat sheet should help you: vim graphical cheat sheet
I like gedit - it doesn't have a terminal, but should work fine for the other requirements. It can run on Windows with Cygwin.
For a full-blown IDE, Aptana Studio is great. It meets your requirements.
If your main goal is to teach then you could try using Hackety Hack. It is somewhat weak at times, but I found it fun and simple to use, but then again I already knew ruby pretty well.
For a beginner being able to run the programs easily is very important so you want something where irb and ruby can be run very simply. Aptana seems to be a pretty good IDE for this sort of thing, but I have never used it myself aside for web development.
Aside from those two I suggest Notepad++... Also the free KomodoEdit might be worth a look. Personally I say teach the other person emacs, but then again shrug

Going Ruby: Straight to IronRuby?

I just started to learn Ruby and as a .Net developer, I'm wondering if I should just go straight ahead and use IronRuby, without trying some pure Ruby first.
What do you think? Will I be missing anything?
-- rauchy
I would use pure ruby (Matz Ruby Interpreter (MRI)) to start off. My understanding is that iron ruby is not quite ready yet.
If you are looking for a good book my current favorite (over pickaxe) is http://www.amazon.com/gp/product/0596516177 by matz and flanagan, the book is very concise well written paragraphs and they provide great examples (in 1.8.* and 1.9)
Enjoy! :D
Use pure Ruby first, IR isn't quite finished yet. Check out http://poignantguide.net/ruby/ - even though it's quite strange, it's a very good introduction
Ruby has a somewhat unique syntax and style that you'll pick up more quickly by working with other people's ruby code. You could certainly learn this while using IronRuby just as well as in any other implementation of the ruby language. (Although, you may run into trouble with some more obscure syntax or libraries with IronRuby; it's not a 100% complete implementation, yet.)
One interesting resource for learning idiomatic ruby is http://www.rubyquiz.com/.
I know this is an old question, but I'd like to say that four years later (today), the JRuby implementation is certainly far enough advanced to be worth starting with.

Resources