Does Sublime Text Have Support for Ruby API (Auto-Complete)

Does Sublime Text have support for Ruby API (auto-complete)?

Sublime Text 2 has some degree of auto-complete functionality right out of the box. If you want to kick it up a notch, the Sublime CodeIntel plugin is probably the closest thing to intelli-sense that we have for Sublime Text w/ Ruby, supporting:

  • Jump to Symbol Definition - Jump to the file and line of the definition of a symbol.
  • Imports autocomplete - Shows autocomplete with the available modules/symbols in real time.
  • Function Call tooltips - Displays information in the status bar about the working function.

Auto-complete:

sample auto-complete / intelli-sense


Symbol definition:

sample symbol definition

Would output the following to the status bar:

Info: Passes each element of
the collection to the given block. The method returns true if the
block ever returns a value other than false or nil. If the block is
not given, Ruby adds an implicit block of { |obj| obj } that will
cause any? to return true if at least one of the collection members is
not false or nil.


If you run into install/usage issues:

At the time of posting this answer, I couldn't get the tool-tips to work and the auto-complete doesn't support external gems, and I also had some issues with installing via package installer. If you run into issues installing try manually cloning the repo into your packages folder. For me this was located at ~/.config/sublime-text-2/Packages/.

If you successfully install and are still having issues getting it running at that point, try re-building as mentioned in the plugin's read-me. Also check out the fix mentioned here:

https://github.com/SublimeCodeIntel/SublimeCodeIntel/issues/249#issuecomment-19763941

Sublime3, ruby programming, autocomplete - show a class' methods (like java, actually)

Sublime is a text editor, is not an IDE. In the Java world you are likely used to write your code with IDE (such as Netbeans, Eclipse, Intellij IDEA), I have never seen Java developers using a pure text editor.

There are some IDE for Ruby. However, the highly dynamic and loosely typed nature of Ruby makes it really hard to provide an accurate IntelliSense code completion. Both the assumption that the Ruby community pretends to be pure, or Ruby-people do not understand Java-coding idea are simply wrong. Several Ruby developers approached the language from Java, therefore they are perfectly aware of how the Java world works.

If you feel more comfortable with an IDE, try to search for a Ruby one. RubyMine is a great product, and if you come from Java world you may already be familiar with Intellij IDEA. There are also plugins for Netbeans and Eclipse, but the runtime evaluation capabilities of RubyMine are far superior and it's also the most up-to-date.

Most of text editors, such as TextMate, Sublime Text, Atom, etc understands Ruby and provide Ruby syntax highlighting and additional features, some of them even autocompletion, but IDE-level features as you would expect from the Java world.

SublimeText2 auto complete wrong for ruby do block

maybe you should try dob, that is for do..end block snippet

or you can create this snippet your self:

<snippet>
<content><![CDATA[
do
$1
end
]]></content>
<tabTrigger>do</tabTrigger>
<scope>source.ruby</scope>
<description>do..end</description>
</snippet>

then you can use do tab to insert the do block which has no variable

Sublime Text 3 - Create tab autocomplete

You can used this plugin to to this.

For examples:

ERB tags           | er | <% %>
print ERB tags | pe | <%= %>
print ERB comment | pc | <%# %>

https://github.com/matthewrobertson/ERB-Sublime-Snippets

Is there bundle for textmate or sublime text 2 that will show me what value a ruby method returns?

No, there is not. For a method to return a value, you need to execute that method, passing in any appropriate parameters and operating on the current state of the object instance. Further, the value of a method may change depending on object state and parameters. How would the text editor have any idea what these would be?

The only time that "return value for a method" makes sense is during debugging, when you have stopped execution and are evaluating a particular method invocation. Neither TextMate nor Sublime Text are IDEs, and thus do not provide line-based debugging.

How to setup Ctags for Sublime Text 3

/usr/local/bin may be in your shell's $PATH, but it is not getting picked up by Sublime. To fix this, edit ~/Library/Application Support/Sublime Text 3/Packages/User/CTags.sublime-settings and change the "command" setting to "/usr/local/bin/ctags_for_ruby". Also, unless you are using the system Ruby in /usr/bin, you might want to edit the first line of /usr/local/bin/ctags_for_ruby from #/usr/bin/env ruby to the direct path of your Ruby interpreter - you can find this by running which ruby on the command line.

Efficiently Using SublimeText with SublimeClang for CMake/C++ Projects

I use Sublime Text 2 with CMake and SublimeClang. I also use SublimeGDB. My build directory is under [project root]/build. Have a look at my project file and see if it helps you:

{
"folders":
[
{
"path": "."
}
],

"build_systems":
[
{
"name": "Build",
"cmd": [ "make", "-C", "build" ],
"file_regex": "/([^/:]+):(\\d+):(\\d+): "
}
],

"settings":
{
"sublimegdb_commandline": "gdb --interpreter=mi myapp",
"sublimegdb_workingdir": "build",

"sublimeclang_options" :
[
"-Wno-reorder"
],
"sublimeclang_options_script": "${project_path:scripts/compileflags.rb} ${project_path:build}"
}
}

The compileflags.rbscript is used to search for flags.make files in the CMake build tree which is where CMake keeps its compile flags. These flags are needed so that SublimeClang knows where to find your includes.

Here is that script, located under scripts/:

#!/usr/bin/env ruby

# Searches for a flags.make in a CMake build tree and prints the compile flags.

def search_dir(dir, &block)
Dir.foreach(dir) do |filename|
next if (filename == ".") || (filename == "..")
path ="#{dir}/#{filename}"
if File.directory?(path)
search_dir(path, &block)
else
search_file(path, &block)
end
end
end

def search_file(filename)
return if File.basename(filename) != "flags.make"

File.open(filename) do |io|
io.read.scan(/[a-zA-Z]+_(?:FLAGS|DEFINES)\s*=\s*(.*)$/) do |match|
yield(match.first.split(/\s+/))
end
end
end

root = ARGV.empty? ? Dir.pwd : ARGV[0]
params = to_enum(:search_dir, root).reduce { |a, b| a | b }
puts params


Related Topics



Leave a reply



Submit