vim-solargraph


Ⅰ. 插件描述

vim plugin (wrapper) for Solargraph gem - IDE tools for the Ruby language.

Ⅱ. 基本信息

创建日期:  2017-08-25
使用用户:  1
Github星:  47
插件作者:  HackHowToFaq

Ⅲ. 安装方法

使用Vundle管理器安装

在你的.vimrc下添加:
Plugin 'hackhowtofaq/vim-solargraph'
… 然后在Vim中运行以下命令:
:source %
:PluginInstall

对于Vundle版本 < 0.10.2,请用上面的Bundle替换Plugin。

使用NeoBundle管理器安装

在你的.vimrc下添加:
NeoBundle 'hackhowtofaq/vim-solargraph'
… 然后在Vim中运行以下命令:
:source %
:NeoBundleInstall

使用VimPlug管理器安装

在你的.vimrc下添加:
Plug 'hackhowtofaq/vim-solargraph'
… 然后在Vim中运行以下命令:
:source %
:PlugInstall

使用Pathogen管理器安装

在终端中运行以下命令:
cd ~/.vim/bundle
git clone https://github.com/hackhowtofaq/vim-solargraph

Ⅳ. 文档说明

vim-solargraph

vim plugin (wrapper) for Solargraph - IDE tools for the Ruby language.

NOTES

Please consider this as a first prototype pre ALPHA version, just to prove that it can be done.

I am not familiar with vimscript, so most of vimscript code is trial and error + a lot of googling.
This plugin was written in 10 hours after the initial idea (first commit).

INSTALLATION

I've tested this only on Linux. If you think you can make it work on Windows or Mac please submit a patch.

Prerequisites (my setup)

  • Install Ruby (2.4.1)
  • Compile vim with +ruby support
  • gem install json rest-client solargraph
  • Install dbakker/vim-projectroot

vim-plug

Add the following

Plug 'hackhowtofaq/vim-solargraph'

Manual (Not ready yet)

Download vim-solargraph.tar.gz from GitHub, extract it, and copy the contents to your ~/.vim directory.

neocomplete

If you are using neocomplete keep reading.

The following is my neocomplete setup. I am still experimenting, trying to find the optimal settings for ruby code.

        " neocomplete {

        " Neosnipet
        " Note: It must be "imap" and "smap".  It uses <Plug> mappings.
        " SuperTab like snippets' behavior.
        imap <expr><TAB> neosnippet#expandable_or_jumpable() ?
                    \ "\<Plug>(neosnippet_expand_or_jump)"
                    \: pumvisible() ? "\<C-n>" : "\<TAB>"
        smap <expr><TAB> neosnippet#expandable_or_jumpable() ?
                    \ "\<Plug>(neosnippet_expand_or_jump)"
                    \: "\<TAB>"

        let g:acp_enableAtStartup = 0
        let g:neocomplete#enable_at_startup = 1
        let g:neocomplete#auto_completion_start_length = 1
        let g:neocomplete#enable_refresh_always = 1
        let g:neocomplete#enable_fuzzy_completion = 0
        let g:neocomplete#enable_smart_case = 1
        let g:neocomplete#enable_auto_delimiter = 1
        let g:neocomplete#enable_auto_select = 1
        let g:neocomplete#enable_underbar_completion = 1
        let g:neocomplete#enable_camel_case_completion  =  1

        if !exists('g:neocomplete#force_omni_input_patterns')
            let g:neocomplete#force_omni_input_patterns = {}
        endif
        let g:neocomplete#force_omni_input_patterns.ruby = '[^. *\t]\.\w*\|\h\w*::'

        " Define keyword.
        if !exists('g:neocomplete#keyword_patterns')
            let g:neocomplete#keyword_patterns = {}
        endif
        let g:neocomplete#keyword_patterns['default'] = '\h\w*'

        " Enable heavy omni completion.
        if !exists('g:neocomplete#sources#omni#input_patterns')
            let g:neocomplete#sources#omni#input_patterns = {}
        endif

        if !exists('g:neocomplete#same_filetypes')
            let g:neocomplete#same_filetypes = {}
        endif
        let g:neocomplete#same_filetypes.ruby = 'eruby'

        let g:neocomplete#data_directory = $HOME . '/.vim/cache/neocomplete'

        " Enable omni-completion.
        autocmd Filetype ruby,eruby setlocal omnifunc=solargraph#CompleteSolar

        " } neocomplete

WORKSPACE (solargraph)

A folder having one of the following entries in it, is assumed to be the workspace folder.

['.projectroot', '.git', '.hg', '.svn', '.bzr', '_darcs', 'build.xml']

USAGE

OR

  • Create file a.rb and paste
# a.rb
class A
  def testInstanceA
  end

  def self.testClassA
  end
end
  • Create file b.rb and paste
# b.rb
class B
  def testInstanceB
  end

  def self.testClassB
  end
end
  • Start solargraph server $ solargraph server
  • Create file test.rb
# test.rb

ca = A.new
A.te   # <---- You should see testClassA
ca.te  # <---- You should see testInstanceA


cb = B.new
B.te  # <---- You should see testClassB
cb.te # <---- You should see testInstanceB

Without neocomplete use CTRL+x CTRL+o shortcut to autocomplete after the dot .

AUTHOR

George Lazaridis <glaz330-vim@yahoo.com>

添加新评论