Gems autocomplete in text editor

Asked

Viewed 386 times

0

Personal is it possible to get an autocomplete experience in some free text editor, similar to what Rubymine does by indexing the Gems code? I tried several alternatives in vscode, like using cTag, but I can only go to the Gem setting (opening another screen), no autocomplete!

The vim possesses such a resource?

  • pro vscode has https://github.com/castwide/vscode-solargraph

1 answer

0

All the dynamism of Ruby complicates the autocomplete. So much so that the rubistas are already accustomed to not having a tool of code Completion as has Java and C#.

When there is no language proficiency or API, in your case the Gems, which is working, Vim ends up losing to the Ides.

Still, there are some tools that bring the autocomplete for Ruby, as is the case with Solargraph. Just install Gem using gem install solargraph and install the plugin for Vim, which is still in beta. It also has the extension for Visual Studio Code. Just have Gem installed in the system.

Everything gets even more complicated when you are using Rails, which makes the autoload of the files at runtime. Solargraph often does not see this require and can’t do the autocomplete.

If you are using Docker, Gem must be installed locally, not within container.

  • vnbrs exactly! I use solargraph in vscode and with it only the complete ruby itself and had seen this question of require! I have little time studying Rails, I have had contact with other dynamic languages and it seems to me another factor that makes it difficult is the fact that Gems are in usr and not in a vendor folder, as does Aravel for example. This way the text editors cannot do indexing! As for vim, I was wondering why irb/Pry can complete activerecords methods for example?

  • The IRB and not even Pry have Rails autocomplete. Only the Rails console, which loads everything and calls a REPL in the Rails context. If I’m not mistaken, it has a self-conmplete, but it is very weak.

  • Exactly! I ended up changing. The way, for now, will be to develop with the Rails guide open! (and with the documentation of Gems).

  • I’ll tell you, the Rails Apis are easy and often you even guess how to do things! With Solargraph vc even gets some Active Record autocomplete. Another thing is to lean on the documentation and leave a Rails console open.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.