Skip to content
This repository has been archived by the owner on Jul 31, 2023. It is now read-only.

Support YARD type annotations #118

Closed
perlun opened this issue Feb 7, 2017 · 17 comments
Closed

Support YARD type annotations #118

perlun opened this issue Feb 7, 2017 · 17 comments
Labels
feature-request Adds currently unsupported functionality

Comments

@perlun
Copy link

perlun commented Feb 7, 2017

Your environment

  • vscode-ruby version:
  • Ruby version: 2.3.3p222
  • VS Code version: 1.9.0
  • Operating System: macOS
  • Hardware (optional):

Make sure you have ruby, ruby-debug-ide and ruby-debug-basex19 installed before submitting your issue -- thank you !

Expected behavior

Being able for "go to definition" to know the types of parameters and variables.

Actual behavior

It does its best, but sometimes guesses wildly (finds a symbol with the same name in some other file).

Steps to reproduce the problem

N/A


Visual Studio Code is one of the better editors available these days, especially because of its Language Server support. It works well for statically typed languages like TypeScript and C#; you can get an awesome editing experience. Work is also ongoing with doing the same for Rust: https://github.com/jonathandturner/rls_vscode

However, the Ruby experience is still not as great as with these languages. You have done an awesome job given the preconditions (a dynamically typed language with very little type annotations etc). I still think that we could (and should) find ways to make it even better.

There are in fact type annotations in Ruby, https://github.com/lsegal/yard. So maybe we should just add support for parsing the YARD comments and using them to provide an even richer editing experience: if they are available, they should be assumed to be reliable.

What do you think? Getting proper "optional typing" in Ruby seems unlikely (https://bugs.ruby-lang.org/issues/9999, https://tonyarcieri.com/an-open-letter-to-matz-on-ruby-type-systems), even though I sincerely hope I'm wrong here - adding optional typing would be the single most important improvement to the language as it stands right now IMHO. Anyway, that's not the scope for this GH issue. 😄

The point here is to rather use whatever we have right now (= YARD comments) and try to utilize them. What do you think of this? (Note: I'm not saying that it's an easy task, I have no idea on how much work it is. I just want to put forward the idea here and start a discussion around it.)

@HookyQR
Copy link
Contributor

HookyQR commented Feb 8, 2017

Hey @perlun, I'm working on a Ruby Language Server at the moment. Not as part of this repo though. I'll be (eventually) releasing it as a ruby2 extension. Been quite busy lately though. I'll be (trying to) use as much stuff that's already out there as I can. The server side is written in ruby this time, so that will be easier.

@perlun
Copy link
Author

perlun commented Feb 8, 2017

@HookyQR Sounds great! If possible, try to coordinate your efforts with the vscode-ruby extension; it doesn't make sense to have two extensions that does 50% of what we want, it's much nicer if we can have a single extension that does it all.

@HookyQR
Copy link
Contributor

HookyQR commented Feb 8, 2017

Most of the code here is mine. It will effectively be an upgrade. 😉

@perlun
Copy link
Author

perlun commented Feb 11, 2017

Most of the code here is mine. It will effectively be an upgrade.

OK, cool. 😄 Looking forward to see that effort being launched, please keep us posted!

@sqs
Copy link

sqs commented Jun 6, 2017

@HookyQR Any updates on your Ruby language server? Very eager to see it. 😄

@didacusAbella
Copy link

@HookyQR I found this repo with a relative vscode extension that implement a ruby language Server. Why not try to use it instead of create a new one?

@perlun
Copy link
Author

perlun commented Jun 18, 2017

@didacusAbella looks promising. Have you tried it?

@didacusAbella
Copy link

a little but lacks encore in some features. When i tried it, the server wasn't able to autocomplete inside methods and when i require some external ruby file apart from stdlib. Compared to rcodetools I can affirm that are to same level now.

@grunxen
Copy link

grunxen commented Jun 24, 2017

@perlun This extension uses YARD to provide code completions.

@didacusAbella
Copy link

@grunxen the extension is very useful. It would be great if this extension will be integrated into the language server that @HookyQR is creating.

@rebornix rebornix added the feature-request Adds currently unsupported functionality label Aug 13, 2017
@baelter
Copy link

baelter commented Sep 17, 2017

I would like to contribute to making the language server happen. @HookyQR @mtsmfm. Where should we focus our effort?

@HookyQR
Copy link
Contributor

HookyQR commented Sep 17, 2017

Hey guys, I'm sorry to say I don't contribute here anymore, mainly due to a recent podcast by @rebornix about it - which was somewhat misleading and self serving.

I'm not actively working on a language server either, although I did see one somewhere on GitHub, albeit (unnecessarily) forcibly wrapped in a Docker instance. Try searching for that and pull the LSP out of the Docker as a start.

I still use it myself, and welcome any improvements that come. Please don't make it worse while you're making it better. 😉

Good luck.

@mtsmfm
Copy link

mtsmfm commented Sep 18, 2017

@baelter

Hi, I'm the author of language_server gem.

It has a lot of todos!
mtsmfm/language_server-ruby#19

If you want to write your own language server, you can use language_server-protocol gem

Anyway, this issue isn't suitable place to have a discussion about my gem so please move mtsmfm/language_server-ruby#19 or create a new issue on my repo🙏

@HookyQR

(unnecessarily) forcibly wrapped in a Docker instance

If you mentioned my gem, it can run without docker 😄

https://github.com/mtsmfm/language_server-ruby#ruby-gem-1

@HookyQR
Copy link
Contributor

HookyQR commented Sep 18, 2017

Awesome, thanks @mtsmfm. Looks like that's the place to go.

@wingrunr21
Copy link
Collaborator

Closing for issue cleanup. Apologies if this is still an issue. We are working to improve the core extension experience.

@AlexWayfer
Copy link

Closing for issue cleanup. Apologies if this is still an issue. We are working to improve the core extension experience.

What? Where can I see the progress with YARD syntax?

@wingrunr21
Copy link
Collaborator

wingrunr21 commented Apr 3, 2018

Right now there isn't/won't be progress on YARD syntax. There are more core issues with the extension than this functionality. If you need completion support, there are a few other options such as using solarized as documented in the README or @gurgeous's Bust A Gem project

Sorry, trying to get a handle on things and get this extension in a happy place

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
feature-request Adds currently unsupported functionality
Projects
None yet
Development

No branches or pull requests

10 participants