GithubHelp home page GithubHelp logo

shadowsith / vim-ruby-autocomplete Goto Github PK

View Code? Open in Web Editor NEW
14.0 1.0 1.0 13 KB

Vim sub plugin for LanguageClient-neovim and solargraph completion server

License: MIT License

Vim Script 100.00%
vim-plugin autocompletion ruby solargraph omnicompletion completor deoplete

vim-ruby-autocomplete's Introduction

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.

vim-ruby-autocomplete's People

Contributors

fwolfst avatar shadowsith avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

fwolfst

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.