Skip to content

Shadowsith/vim-ruby-autocomplete

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

vim-ruby-autocomplete

Vim/Neovim ruby autocompletion with help of solargraph and vim language server

This plugin is based on following blog post by Jamie Schembri.

Demo

Demo

Tested on:

  • Arch Linux (Manjaro)
  • Ruby 2.6.*

Requirements

This plugin supports linux only

Gems

  • gem install solargraph rdoc irb rubocop yarn

Add gem bins to PATH in your .bashrc:

  • Check your ruby version!
  • PATH=$PATH:$HOME/.gem/ruby/your-ruby-version/bin

Vim Plugins

Configuration

By default the plugin will start solargraph each time if vim is opened.
Additional you can add/modify this hotkeys to refactor and go to definition:

nnoremap <F5> :call LanguageClient_contextMenu()<CR>
nnoremap <silent> K :call LanguageClient#textDocument_hover()<CR>
nnoremap <silent> gd :call LanguageClient#textDocument_definition()<CR>
nnoremap <silent> <F2> :call LanguageClient#textDocument_rename()<CR>

You can also add a .solargraph.yml to your project root folder to include/exclude ruby files or require additional gems:

---
include:
- "**/*.rb"
exclude:
- spec/**/*
- test/**/*
- vendor/**/*
require:
- rails
reporters: []
domains: []
plugins: []

Usage

By default completion can be triggered with CTRL-X + CTRL-O

Follwing optional variables are available for your .vimrc

let g:ruby_autocomplete_solargraph = '<path to solragraph bin>'
" If you dont use rvm the path should be like:
" ~/.gem/ruby/<ruby version>/bin/solargraph

Add following in your .vimrc:

let g:completor_ruby_omni_trigger = '([$\w]{1,}|\.[\w]*|::[$\w]*)$'

On default configuration pushich TAB should do the trick.

let g:neocomplete#sources#omni#input_patterns = {
\   "ruby" : '[^. *\t]\.\w*\|\h\w*::',
\}

Documentation

For additional information write follwing in Vim:

:help ruby-autocomplete

Issues

Sometimes the solargraph socket server will not start by default than you need to restart vim.

TODO

  • Async startup of solargraph instead of synchronous waiting time

See also

There are similiar plugins to vim-ruby-autocomplete but I couldn't get them to work on my systems. That was the initial idea to write this small plugin.

About

Vim sub plugin for LanguageClient-neovim and solargraph completion server

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published