Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Possible Feature]: Add Ruby completion #314

Closed
puremourning opened this issue Jan 19, 2016 · 28 comments
Closed

[Possible Feature]: Add Ruby completion #314

puremourning opened this issue Jan 19, 2016 · 28 comments

Comments

@puremourning
Copy link
Member

I was playing with a Vagrantfile and thought this might be worthwhile. Not urgent, but might be a fun idea.

There's a project for ruby completion: https://github.com/rsense/rsense

Looks like it:

  • has a primary HTTP+JSON interface (yay)
  • uses 1-based indices (yay)
  • supports code completion (yay)
  • has no other cool features yet (boo)
  • doesn't seem to be actively developed (boo)

Might be worth checking out.

@vheon
Copy link
Contributor

vheon commented Jan 19, 2016

We had an issue for this in ycm-core/YouCompleteMe#1502.

  • has no other cool features yet (boo)
  • doesn't seem to be actively developed (boo)

A couple things to consider:

I was playing with a Vagrantfile

For ycmd?? If so, show me yours and I'll show you mine 😝

@puremourning
Copy link
Member Author

Hah. Didn't spot that @vheon thanks. Makes sense to have one for ycmd, where it belongs :)

For ycmd?? If so, show me yours and I'll show you mine

Well, yes. But mostly because I am investigating a whole bunch of Configuration Management and DevOps options at work and thought I would use ycmd as a small test case. Work application is, give or take, infinity times more complex. And ymcd something else I know well >:)

Given my knowledge of vagrant + salt is everything i've learned today. here;s where I got to:

Vagrant.configure(2) do |config|
  config.vm.box = "parallels/ubuntu-14.04"
  config.vm.provision :salt do |salt|
    salt.masterless = true
    salt.minion_config = "salt/minon"
    salt.run_highstate = true
  end
end

top.sls:

# vi: ft=sls sw=2
file_client: local

base:
  '*':
    - cmake
    - clang
    - mono
    - gocode
    - node
    - rust
   # TODO: different python versions ?
    - python
    - virtualenv

So, err... Not far. Not even far enough to know what the above state thingy is likely to do :)

PS. What's an if_ruby ? You mean the plugin requires vim built with ruby? If so, yeah yet-another-advantage-out-of-process-plugins with all the infrastructure for free.

Given my experience with the Tern completer, I estimate adding an rsense completer to ycmd, including tests, to be a few hours work for a working prototype. Assuming sense works etc.

@vheon
Copy link
Contributor

vheon commented Jan 19, 2016

I went for the bash provisioning directly to avoid adding another "language"/dependency but with salt/puppet/chef/name-your-favorite-provisioner it would be surely more maintainable.

PS. What's an if_ruby ? You mean the plugin requires vim built with ruby?

Yes it needs a vim which is compiled with the ruby interface. On Mac OS X is easy (if not the default) but neovim still don't have it because they have change how to do the interface layer.

If so, yeah yet-another-advantage-out-of-process-plugins with all the infrastructure for free.

Well the https://github.com/vim-ruby/vim-ruby uses both information from vim directly and evaluate on the fly some code to get some autocompletion.

@vheon
Copy link
Contributor

vheon commented Jan 19, 2016

Other things to note about rsense:

  • internally it uses the JRuby Parser which is all Java.
  • I don't know if it supports Windows

@puremourning
Copy link
Member Author

Yeah, my main goal was learning the capabilities of salt/puppet/chef/ansible.

@jwilm
Copy link
Contributor

jwilm commented Jan 19, 2016

I've got a little experience working with the ruby.vim plugin, and I've also looked at rsense. ruby.vim does a decent job of providing completions, but not perfect. Aside from being seemingly abandoned, there was no evidence that rsense would provide a better experience for completions than ruby.vim.

To have a compelling story for Ruby in YCM we need to minimally achieve what the rust.vim plugin has done with completions, and add good find_definition support. Most Vim users in the Ruby community still rely on ctags for GoTo, but the experience really sucks. It can actually be really hard to provide good GoTo in ruby since the language is so dynamic; things like class_eval are common, and method_missing obviously will prevent many things from showing up unless we are actually evaling ruby code. This is a component that still needs to be built.

I would really like to see rubymine level support for Ruby in YCM, but I think we've got a lot of work to do!

@vheon
Copy link
Contributor

vheon commented Jan 19, 2016

I would really like to see rubymine level support for Ruby in YCM, but I think we've got a lot of work to do!

Well rubymine level would be really hard! we're talking of a whole team of people working full time with a base foundation that is IntelliJ IDEA. Whoever will build something like that I think many people would be really grateful :)

@jwilm
Copy link
Contributor

jwilm commented Jan 19, 2016

We have the advantage of a base foundation of YCM and an ecosystem of opensource semantic analysis tools for various languages. I think most of the languages supported by YCM are very professional quality even though we're not all working full time on this. Most of the YCM languages are made possible by third party plugins who have already done a lot of the work. In the case of C family of languages, Val and the YCM team have done that work. The point I was trying to make with my previous comment was, for the case of ruby, there is no third party library we can just drop in to get us 90% of the way there.

You're definitely right.. many people would be very grateful, including myself. I'm just questioning at this point whether we can do much that is a big value add over something like ruby.vim.

@vheon
Copy link
Contributor

vheon commented Jan 19, 2016

The point I was trying to make with my previous comment was, for the case of ruby, there is no third party library we can just drop in to get us 90% of the way there.

That was my point. I thought that rsense would be good enough for the job but since I don't have much experience with it or ruby in general and you said that it wasn't that good (or at least not good enough to switch from ruby-vim) so I don't know how much can we do about it.

@jwilm
Copy link
Contributor

jwilm commented Jan 19, 2016

I was actually saying it's not clear that it's better (it might be, for completions). That coupled with the fact of no find-definition support, it's a hard sell to me.

@puremourning
Copy link
Member Author

Just found this un-sent. I wrote this on tuesday i think...

@vheon FYI/FWIW I managed to get my salt all shaken and with:

$ vagrant up --provision
<wait ages>
$ vagrant ssh
vagrant$ ls
ycmd

You get a fully built ycmd in that directory on which almost all of the tests pass when running ./run_tests.py --skip-build.

impressive tech.

@vheon
Copy link
Contributor

vheon commented Jan 24, 2016

I'm using https://gist.github.com/vheon/1e43fb45cb90e1fae928 and the only issue I got is that if I run the whole test it passes, but if I run it again the go tests fail. I have the <wait ages> problem too due to the sudo apt-get update -yq command which I don't even know if is really necessary.

@Valloric
Copy link
Member

I welcome better ruby semantic completion; @jwilm does bring up a good point that what we bring in should be better than ruby.vim. OTOH, if we have it in ycmd, we instantly bring semantic completion support for ruby to other editors like emacs etc. I don't know how good rsense is personally; worth checking out.

For the parallel discussion about Vagrant, I've personally used it quite a bit for other stuff and dear lord is it absolutely fantastic. I have nothing but praise for that tool.

@Valloric
Copy link
Member

Also worth noting, we've had many users file issues on YCM about ruby.vim completion (through our omnifunc integration) crashing Vim. Something is funky with that thing and the problems persist to this day. So if we could replace it, we would probably make quite a few users very happy.

@puremourning
Copy link
Member Author

FYI - I made a prototype of this which works after a fashion, but:

  • rsense is seriously slow in starting up leading to lots of timeouts when opening a new file
  • rsense only offers basic completions (no other features)
  • rsense is not actively developed it would seem
  • rsense does not have any "dirty buffers" support.
  • it's really hard to get rsense to actually start up without relying on being installed globally on the user's system and I don't ruby enough to make it work properly :)

So I'm thinking that unfortunately, unless we invest quite heavily in improving rsense, then I don't think this is totally viable.

ycm-ruby-rsense-demo-1

@Valloric
Copy link
Member

Valloric commented Apr 3, 2016

So I'm thinking that unfortunately, unless we invest quite heavily in improving rsense, then I don't think this is totally viable.

That's that then for rsense. :)

@micbou
Copy link
Collaborator

micbou commented Oct 14, 2017

Once PR #857 is merged, we may consider LanguageServer.

@crisidev
Copy link

@puremourning do you mind to share your work on integrating ycmd with rsense? I know it is not a perfect solution, but I would like to take a look to it.

@puremourning
Copy link
Member Author

Jeez, that was a long time ago. If it isn't in a branch in my fork, then it is long gone

@crisidev
Copy link

@puremourning thanks. I searched but unfortunately the branch seems gone. I am playing with eclim and ycmd with ruby, which works quite well. I just need to figure out how to automate a bit project creation and library inclusion..

@numbcoder
Copy link

@puremourning I find this https://github.com/castwide/solargraph
It's looks better than rsense

@bstaletic
Copy link
Collaborator

YCM now supports plugging LSP servers, so if someone wants to test the ruby server, just add the following to vimrc:

let g:ycm_language_server = [{
    \ 'name': 'ruby',
    \ 'filetypes': [ 'ruby' ],
    \ 'cmdline': [ command_line ]
    \ } ]

@puremourning
Copy link
Member Author

I am trying solargraph again, but it is crashing and has a buggy LSP implementation.

@puremourning
Copy link
Member Author

Solargraph is fixed (was a ycmd bug actually!), works with the generic LSP server per @bstaletic great work, so closing this.

If there's sufficient community support for "native" (i.e. tested and supported) ruby completion in ycmd we can open a new issue to track that. Judging by the responses on this one, I don't see that it is a high priority.

@crisidev
Copy link

Is there any documentation on how to setup solargraph?

@puremourning
Copy link
Member Author

@bstaletic included what you need above.

we're considering adding a community-supported wiki page for non-core completers.

@crisidev
Copy link

Oh, I thought that was just a snippet not the real config. Thanks!

@puremourning
Copy link
Member Author

This is WIP, but it might help you: https://github.com/ycm-core/lsp-examples

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

8 participants