Vim/Neovim ruby autocompletion with help of solargraph and vim language server
This plugin is based on following blog post by Jamie Schembri.
Tested on:
- Arch Linux (Manjaro)
- Ruby 2.6.*
This plugin supports linux only
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
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:
- railsreporters: []domains: []plugins: []By default completion can be triggered with CTRL-X + CTRL-O
Follwing optional variables are available for your .vimrc
letg:ruby_autocomplete_solargraph='<path to solragraph bin>'" If you dont use rvm the path should be like:" ~/.gem/ruby/<ruby version>/bin/solargraphAdd following in your .vimrc:
letg:completor_ruby_omni_trigger='([$\w]{1,}|\.[\w]*|::[$\w]*)$'MUComplete and Supertab
On default configuration pushich TAB should do the trick.
letg:neocomplete#sources#omni#input_patterns = {
\ "ruby" : '[^. *\t]\.\w*\|\h\w*::',
\}For additional information write follwing in Vim:
:helpruby-autocomplete
Sometimes the solargraph socket server will not start by default than you need to restart vim.
- Async startup of solargraph instead of synchronous waiting time
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.
- vim-solargraph
- vim-monster
- deoplete-solargraph (deoplete only)
