GithubHelp home page GithubHelp logo

hackhowtofaq / vim-solargraph Goto Github PK

View Code? Open in Web Editor NEW
44.0 7.0 2.0 7 KB

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

License: MIT License

Vim Script 52.60% Ruby 47.40%
vim vim-scripts vim-plugins ruby-language

vim-solargraph's Introduction

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 [email protected]

vim-solargraph's People

Contributors

hackhowtofaq avatar huyvohcmc avatar

Stargazers

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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Forkers

rajibahmed jkeam

vim-solargraph's Issues

vim-solargraph does not work with Ruby 2.5.0

Hello, I'm on Arch Linux and I use the very new Ruby version 2.5.0

I've tested vim-solargraph and found several problems with a newer solargraph gem (v 0.28.1).

  • solagraph server command does not exist anymore, know you can start it with solargraph socket
  • solagraph moved from Port 7657 to Port 7658

I have tried to fix the problem myself and changed the port in plugin/main.rb to 7658 but when I start the server and open a ruby file vim will crash completely.

I've installed all gems correctly and my vim 8.1 has ruby support

Is there any plan for the future to change the plugin to the new solargraph socket?

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.