Code Monkey home page Code Monkey logo

Comments (10)

inkyvoxel avatar inkyvoxel commented on May 29, 2024 6

Sorry if this is the wrong place to ask (or a silly question in general), but what is the likelihood of ruby-lsp completions becoming as thorough as the completions in irb and rails console? I find both of those tools have incredibly fast and detailed completions. After using them, I am often left longing for my text editor to work in the same way.

Example of irb giving an immense list of methods I can call on a string:

irb

Example of rails console giving a list of all the methods I can call on my Active Record model:

rails-console

Is this something that ruby-lsp and vscode-ruby-lsp could eventually achieve? Or are completions like this the responsibility of a different sort of tool?

from ruby-lsp.

vinistock avatar vinistock commented on May 29, 2024 3

Not a silly question at all! I'm not sure how these new IRB completions work internally, but they are indeed very useful - and it would be a great experience for the Ruby LSP.

I think it could be achieved, but it does require some exploration to understand how it's done. Maybe it could even be shared between IRB and the Ruby LSP? I'll add this idea to the issue description.

from ruby-lsp.

inkyvoxel avatar inkyvoxel commented on May 29, 2024 3

Not a silly question at all! I'm not sure how these new IRB completions work internally, but they are indeed very useful - and it would be a great experience for the Ruby LSP.

I think it could be achieved, but it does require some exploration to understand how it's done. Maybe it could even be shared between IRB and the Ruby LSP? I'll add this idea to the issue description.

That is exciting! Thanks for considering it.

I was curious how the completions work in the tools I mentioned:

I am new to Ruby, so this may just be fluff 😁 Hopefully it can start some discussion in the future. I am interested in learning more!

from ruby-lsp.

vinistock avatar vinistock commented on May 29, 2024 1

Yes, one is for automatic formatting and the other one is to provide completion options (since we can't know ahead of time which method the user is looking for).

from ruby-lsp.

vinistock avatar vinistock commented on May 29, 2024 1

It would indeed be much more accurate, but I think it would be unbearably slow for large Rails applications. Also, it would require the LSP to know how to boot the application, since it may not necessarily be a Rails app.

If we can figure out a way to offer completions based on static analysis only, it should be a lot faster, more maintainable and application agnostic.

from ruby-lsp.

st0012 avatar st0012 commented on May 29, 2024

@vinistock is #253 part of this ticket?

from ruby-lsp.

vinistock avatar vinistock commented on May 29, 2024

@st0012 no, onTypeFormatting is for formatting code as the user is typing - like automatically adding the end or adjusting indentation. This ticket is for completion on method invocations.

from ruby-lsp.

st0012 avatar st0012 commented on May 29, 2024

offer to add end on other keywords, such as while, until, for

Ah ok. I saw #253 adds end keyword so I assumed they are the same as the above.
I guess the difference is #253 always append a word based on pattern, but this one is to provide completion options?

from ruby-lsp.

gobijan avatar gobijan commented on May 29, 2024

I think a while ago JetBrains had an experimental completion plugin for Rubymine that instantiated the application in the background and offered completions based on what is available in the runtime. This was actually painfully slow. But given Ruby's character of meta programming this is probably the only approach that can offer 100% accurate code completion.
Feel free to correct me when there are better approaches available to have exact autocompletion.

from ruby-lsp.

eyar avatar eyar commented on May 29, 2024

it would be unbearably slow for large Rails applications

Wouldn't it be possible to cache all models and their methods, and just modify the cache on changes? doesn't sound like a huge list.

from ruby-lsp.

Related Issues (20)

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.