GithubHelp home page GithubHelp logo

language-ruby's Introduction

Atom and all repositories under Atom will be archived on December 15, 2022. Learn more in our official announcement

Ruby language support in Atom

ci Dependency Status

Adds syntax highlighting and snippets to Ruby files in Atom.

Originally converted from the Ruby TextMate bundle.

Contributions are greatly appreciated. Please fork this repository and open a pull request to add snippets, make grammar tweaks, etc.

language-ruby's People

Contributors

50wliu avatar alhadis avatar ben3eee avatar caleb531 avatar chbk avatar citrus avatar darangi avatar daviwil avatar elifoster avatar grantr avatar hd-deman avatar hediyi avatar hgoodman avatar izuzak avatar jasonrudolph avatar kachick avatar kevinsawicki avatar lee-dohm avatar mamenama avatar maxbrunsfeld avatar mnquintana avatar nikhilofthesouth avatar npezza93 avatar rmosolgo avatar ryansobol avatar sadick254 avatar tobiashm avatar torn4dom4n avatar yuriihabrusiev avatar zoo1 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

language-ruby's Issues

Parentheses in Default Parameter Mess Up Highlighting

Having a default parameter use a ) messes up syntax highlighting. I tried to fix the issue myself but just don't have enough experience with the code to find out how to deal with it. Interestingly enough it doesn't happen if the ) is in a string and it doesn't happen with other recursive tokens like %(te(s)t)

screen shot 2014-12-26 at 9 26 21 pm

Comment not working when @ symbol

Starting in language-ruby v0.39.0, some comments are not highlighted right. It seems to be when the hash is followed by a space, @ symbol, and a Ruby method.

Here is an example:

# @attr

Incorrectly highlighted regex

this code has broken highlighting - note the red closing slash on the regex and wash of redness below it

screen shot 2014-08-12 at 12 20 10 pm

new_node = node.to_s.gsub(/{(\w+)}/) { "<a href=\"/docs\/#{context[:doc_version]}\/api\/classes\/#{$1}\">#{$1}</a>" }

Regexp syntax issues

I'm using the regex railroad diagram package and noticed that many ruby regexps stopped working a while back. Seems to be an issue only with ruby. I also noticed that regexps are syntax highlighted differently depending on where they occur.

This is not syntax highlighted (railroad doesn't work):

"hello".gsub(/[aeiou]/, '*') 

This is highlighted (railroad works):

x = /[aeiou]/

String Literal Syntax highlighting is broken

Consider the following code fragment, when inserted into the editor the syntax highlighitng shows all the code below the closed string as a string. This is not the case in sublime2 and other text-editors.

email.header = "[[\"Received\", \"by luna.mailgun.net with SMTP mgrt 8788212249833; Fri, 26 Apr 2013 18:50:30 +0000\"], [\"Received\", \"from [10.20.76.69] (Unknown [50.56.129.169]) by mxa.mailgun.org with ESMTP id 517acc75.4b341f0-worker2; Fri, 26 Apr 2013 18:50:29 -0000 (UTC)\"], [\"Message-Id\", \"<[email protected]>\"], [\"Date\", \"Fri, 26 Apr 2013 11:50:29 -0700\"], [\"From\", \"Bob <[email protected]>\"], [\"User-Agent\", \"Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130308 Thunderbird/17.0.4\"], [\"Mime-Version\", \"1.0\"], [\"To\", \"Alice <[email protected]>\"], [\"Subject\", \"Re: Sample POST request\"], [\"References\", \"<[email protected]>\"], [\"In-Reply-To\", \"<[email protected]>\"], [\"X-Mailgun-Variables\", \"{\\\"my_var_1\\\": \\\"Mailgun Variable #1\\\", \\\"my-var-2\\\": \\\"awesome\\\"}\"], [\"Content-Type\", \"multipart/mixed; boundary=\\\"------------020601070403020003080006\\\"\"], [\"Sender\", \"[email protected]\"]]"
email.content_type = params['Content-Type']

Duplicate prefixes in snippets

Brought into visibility after mega-commit eb6db3d, which joined them all together.

Some snippets have identical prefixes, and it looks like Atom will choose the last-defined one.
The TextMate behavior was to pop open a prompt after pressing Tab, allowing interactive selection of any of the available methods via (1, 2, ...) selection.

textmate_snippet_prompt

Scope of problem:

$ grep --color=none prefix snippets/language-ruby.cson|sort|uniq -c|sort|grep -v 1
   2     'prefix': 'Dir'
   2     'prefix': 'File'
   2     'prefix': 'eac-'
   2     'prefix': 'mod'
   3     'prefix': 'cla'

Also referenced here: http://discuss.atom.io/t/multiple-snippets-key/2297

So I'm uncertain whether the functionality will be part of Atom, or whether by the time Atom compiles and loads CSON, there's no other way to get at those keys.

Heredoc improperly highlighted.

Rails.logger.error("\s\s" + <<-STR.strip_heredoc.strip)
  #{error_.message}: #{error_.backtrace[0]}
STR

The result is that the end ) is the same color as the string. (Actually this seems to be a bug inside of Pygments too since it seems to do the same thing.)

Pasting heredoc doesn't auto indent correctly

  1. Paste heredoc:
sql = <<-SQL
  blah1
  blah2
SQL
  1. Expect:
sql = <<-SQL
  blah1
  blah2
SQL
  1. Actual:
sql = <<-SQL
blah1
blah2
SQL

Note the missing indention for blah1 and blah2. I've noticed it with other things in ruby as well like certain blocks and if/else statements.

Minor issue with syntax highlighting

Thanks for an awesome editor! โ›ต

Multi-line array using %{ ... } seems to break highlighting. No biggie, though.

screen shot 2014-07-03 at 20 15 16

[ EDIT: I'm blind!! I missed the w in %w]

Treat Guardfile* as Ruby code

language-ruby does a good job loading Guardfiles as Ruby code. In large projects, I like to name these Guardfile-test, Guardfile-lint, Guardfile-doc, etc. Could we please treat Guardfile* as Ruby code, so these files are colorized as well?

Different keyword for function and class definitions.

Some syntaxes (like Solarized Dark and Solarized Light) need special highlight for function and class definitions.

The problem is that I can't find a way to differentiate the blocks ends from functions and classes ends.

Is there a way to do:

class Foo
    def bar
        [].each do |e|
        end # normal end (no special color) ๐Ÿ‘
    end # <--- Special class (close def)
end # <--- Special class (close class)

I'd be happy to try to help if you're open to some help.

pound should assume user is interpolating if used within double quotes

When a user highlights something in a double quote string and presses pound it should assume the use wants to interpolate. Right now it replaces the highlighted text with a pound symbol.

Pressing pound within a double quoted string should also assume the user intends to interpolate.

e.g.

"#{}"
" Good morning #{user} It is good to see you."

question: indentation for multi-line method params?

hi,

auto-indent for the following yields:

    result = Foo.bar
    (
    from_month: from_month,
    to_month: to_month
    )

is there any way to coax auto-indent to yield the parameters indented like so...?:

    result = Foo.bar
    (
      from_month: from_month,
      to_month: to_month
    )

similarly, the following yields like so:

    result = Foo.bar(from_month: from_month,
    to_month: to_month)

i might have expected something like:

    result = Foo.bar(from_month: from_month,
                     to_month: to_month)

regards,
tony...

Manually creating array with more than 23 elements syntax highlight problem

class Green
   def initialize(value = ['1','2','3','4','5','6','7','8','9','10','11','12','13','14','15','16','17','18','19','20','21','22','23','PROBLEM'])
      @array = value
   end
   def why_green
      puts "everyhing is green"
      puts "Unitl the next apostrophe"
      '
   end
   def not_green
      puts "Syntax is now correct"
   end
end

syntax highlighting - strings - issue related to `%%`

It seems to create multiple nested string syntax highlights... and since my theme uses a semi-transparent background for the string highlights, you can clearly see that they are piling up on top of each other because they get darker and darker throughout the file:
image

On closer inspection, it looks like it's related to the characters %%- and %%=.
And in case it helps, this is a .erb file, and the <%% is meant to escape the ERB tag so that it will output the <% characters for use in an underscore template.
image
image
image

Moved from atom/atom#3940

Regexp's lose syntax highlighting when comma or other added.

Properly Highlighted:

LineRegexps = [
    /Invalid\suser\s.*\sfrom/
]

if val =~ /Invalid\suser\s.*\sfrom/
  # Do Work Son
end

Loses syntax highlighting:

LineRegexps = [
    /Invalid\suser\s.*\sfrom/,
]

if val =~ /Invalid\suser\s.*\sfrom/ \
    || other
  # Do work Son
end

Regexp with interpolation results in comments.

(self.dup).downcase.gsub(/#{REMOVE_FROM_STRING}/, ""). \
   gsub(/_/, "-").gsub(/\s+/, "-").gsub(/-+/, "-")

Single and multiple line regexp like the above results in everything past the # being a comment.

'do' snippet recurs when deleteing block arguments

When trying to write argument-less blocks, by deleting the |variable| code that is generated and then pressing tab again, a new |variable| argument is created and a new end is inserted.

atom-ruby

I am expecting the 2nd tab to result in the cursor dropping into the block. I am 99.9% sure this used to function as expected, and mirror how TextMate 1/2 deals with this:

textmate-ruby

I am currently using Atom 0.136.0, atom/language-ruby 0.39.0 and running on OSX 10.9.4.

I checked the console whilst doing this, but no errors were occuring.

Regexp with some kinds of interpolation get transformed into comments.

Full example:

module EnvyGeeks
  module Get extend self
    def ips(cidr = "192.168.1.0/24")
      # Technically we don't need the select but we should defensively double chck.
      `ip route show #{cidr}`.each_line.select { |v| v =~ /scope link/ }.map do |v|
        IPAddr.new(v.match(/(?:src )(#{Regexp.escape(cidr.gsub(/\/\d+\Z/, "").gsub(/\.\d+\Z/, ""))}\.\d+)/)[1])
      end
    end
  end
end

Ternary regexp does not get highlighted.

The following loses all regexp syntax highlighting.

hello =~ /world/ ? hello : world

For some reason it actually ends up marking it as an arithmetic operator.

Add automatic `end`

It would be interesting to add the ability to automatically add end in the next line when writing new:

  • classes
  • modules
  • methods
  • blocks
  • conditional statements
  • etc.

Thanks.

Method highlighting inconsistency & miscellaneous bugs

I'm testing Atom from a Sublime Text background. I've noticed two main highlighting differences:

  • Anything starting with a capital letter is now highlighted the same way as constants (purple) instead of like classes (cyan)
  • Methods are randomly highlighted in cyan/white, instead of just white (prime example #select vs #reject)

The former seemed like a nice change but it doesn't always detect constants correctly so I think it should default to class styling. The latter is the most important thing to address though, I've never seen any highlighter do this.

Windows 7
Atom 0.136.0
Monokai 0.8.0
Language Ruby 0.39.0

I'm using the Monokai theme and describing things in terms of those colours and how Sublime Text handles it, but lots of these are legacy issues from TextMate that Atom has inherited (which were otherwise fixed in Sublime and its ruby packages). Please read the screenshot:
Screenshot
Gist

I can break this down into 11 tickets if needed, it was just convenient for me to display and annotate it all in a single image.

Wrong highlighting

Both with and without soft wrapping enabled, atom --safe fails to highlight this file.

screen shot 2014-10-06 at 4 47 52 pm

Running atom 0.135.0 with Language Ruby 0.38.0 on MacOS X 10.9.5

Local variables?

Why every type of variables except local ones supported, is this intended or ...?

invalid regex parsing

value1 = value2 / (1.0 - (percentage / 100.0))

Moved over from #47 after releasing it was different that that issue.

case when, case # when and generic casing tabbing broken.

Atom seems to always want to de-indent when in a case statement in Ruby. It was bad that it always broke the way I like to tab single-line whens but it got worse when I started commenting above the when statement it would then tab behind the case resulting in:

  case true

  # Comment
when arguments then do_work(son)
  end

It would be nice if language-ruby respected our custom tabbing and didn't try to enforce crazy rules, please, because I like my single line whens to look like:

case true
  when argument then do_work(son)
end

But editing always breaks the tabbing in some way especially when you start commenting.

Multi-line regexs are not highlighted as regexs

After #41, I thought to check if multiline regexs are supported by the regex highlighting, and they're not.

screen shot 2014-07-08 at 17 43 08

Can't think of a simple way to detect the difference between the opening of a multi-line regex and a simple /, though, given that a file may have multiple /, all unrelated.

Using 0.32.0.

auto indent not working as expected

I ran into a situation where Auto Indent results in a wrong indent. I could reduce the example code to the following:

class Example
  private

  def attribute_and_value(attribute, value)
    "%s: %s" % [human_attribute_name(attribute),
      value]
  end
end

After calling Auto Indent it will look like this:

class Example
  private

  def attribute_and_value(attribute, value)
    "%s: %s" % [human_attribute_name(attribute),
      value]
    end
  end

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.