@@ -7,35 +7,164 @@ vim plugin (wrapper) for Solargraph - IDE tools for the Ruby language.
77NOTES
88-----
99
10- Please consider this as a first prototype ALPHA version, just to prove that it can be done.
10+ Please consider this as a first prototype ** pre ALPHA** version, just to prove that it can be done.
11+
1112I am not familiar with vimscript, so most of vimscript code is trial and error + a lot of googling.
12- This plugin was written in 10 hours after the initial idea.
13+ This plugin was written in 10 hours after the initial idea (first commit) .
1314
1415
1516INSTALLATION
1617------------
1718
18- TODO
19+ I've tested this only on Linux. If you think you can make it work on Windows or Mac please submit a patch.
20+
21+
22+ ### Prerequisites (my setup)
23+
24+
25+ * Install Ruby (2.4.1)
26+ * Compile vim with ` +ruby ` support
27+ * ` gem install json rest-client solargraph `
28+ * Install [ dbakker/vim-projectroot] ( https://github.com/dbakker/vim-projectroot )
29+
1930
2031#### vim-plug
2132
33+ Add the following
34+
35+ ` Plug 'hackhowtofaq/vim-solargraph' `
36+
37+
38+ ### Manual (Not ready yet)
39+
40+ Download ` vim-solargraph.tar.gz ` from GitHub, extract it, and copy the contents to your ` ~/.vim ` directory.
41+
42+
43+ ### neocomplete
44+
45+ If you are using [ neocomplete] ( https://github.com/Shougo/neocomplete.vim ) keep reading.
46+
47+ The following is my neocomplete setup. I am still experimenting, trying to find the optimal settings for ruby code.
48+
49+ ``` vim
50+ " neocomplete {
51+
52+ " Neosnipet
53+ " Note: It must be "imap" and "smap". It uses <Plug> mappings.
54+ " SuperTab like snippets' behavior.
55+ imap <expr><TAB> neosnippet#expandable_or_jumpable() ?
56+ \ "\<Plug>(neosnippet_expand_or_jump)"
57+ \: pumvisible() ? "\<C-n>" : "\<TAB>"
58+ smap <expr><TAB> neosnippet#expandable_or_jumpable() ?
59+ \ "\<Plug>(neosnippet_expand_or_jump)"
60+ \: "\<TAB>"
61+
62+ let g:acp_enableAtStartup = 0
63+ let g:neocomplete#enable_at_startup = 1
64+ let g:neocomplete#auto_completion_start_length = 1
65+ let g:neocomplete#enable_refresh_always = 1
66+ let g:neocomplete#enable_fuzzy_completion = 0
67+ let g:neocomplete#enable_smart_case = 1
68+ let g:neocomplete#enable_auto_delimiter = 1
69+ let g:neocomplete#enable_auto_select = 1
70+ let g:neocomplete#enable_underbar_completion = 1
71+ let g:neocomplete#enable_camel_case_completion = 1
72+
73+ if !exists('g:neocomplete#force_omni_input_patterns')
74+ let g:neocomplete#force_omni_input_patterns = {}
75+ endif
76+ let g:neocomplete#force_omni_input_patterns.ruby = '[^. *\t]\.\w*\|\h\w*::'
77+
78+ " Define keyword.
79+ if !exists('g:neocomplete#keyword_patterns')
80+ let g:neocomplete#keyword_patterns = {}
81+ endif
82+ let g:neocomplete#keyword_patterns['default'] = '\h\w*'
83+
84+ " Enable heavy omni completion.
85+ if !exists('g:neocomplete#sources#omni#input_patterns')
86+ let g:neocomplete#sources#omni#input_patterns = {}
87+ endif
88+
89+ if !exists('g:neocomplete#same_filetypes')
90+ let g:neocomplete#same_filetypes = {}
91+ endif
92+ let g:neocomplete#same_filetypes.ruby = 'eruby'
93+
94+ let g:neocomplete#data_directory = $HOME . '/.vim/cache/neocomplete'
95+
96+ " Enable omni-completion.
97+ autocmd Filetype ruby,eruby setlocal omnifunc=solargraph#CompleteSolar
98+
99+ " } neocomplete
100+ ```
101+
102+
103+ WORKSPACE (solargraph)
104+ ---------
105+
106+ A folder having one of the following entries in it, is assumed to be the workspace folder.
107+
108+ ```
109+ ['.projectroot', '.git', '.hg', '.svn', '.bzr', '_darcs', 'build.xml']
110+ ```
111+
112+
113+
114+ USAGE
115+ -----
116+
117+ * Download something big : P [ discourse] ( https://github.com/discourse/discourse/archive/v1.8.5.tar.gz ) ?
118+
119+ OR
120+
121+ * Create file ` a.rb ` and paste
122+
123+ ``` ruby
124+ # a.rb
125+ class A
126+ def testInstanceA
127+ end
128+
129+ def self .testClassA
130+ end
131+ end
132+ ```
133+
134+ * Create file ` a.rb ` and paste
135+
136+ ``` ruby
137+ # b.rb
138+ class B
139+ def testInstanceB
140+ end
141+
142+ def self .testClassB
143+ end
144+ end
145+ ```
22146
147+ * Start solargraph server ` $ solargraph server `
23148
24149
25- ### Vim package
150+ * Create file ` test.rb `
26151
27- $
28- $
29- $ git clone https://github.com/
152+ ``` ruby
153+ # test.rb
30154
155+ ca = A .new
156+ A .te # <---- You should see testClassA
157+ ca.te # <---- You should see testInstanceA
31158
32159
33- ### Manual
160+ cb = B .new
161+ B .te # <---- You should see testClassB
162+ cb.te # <---- You should see testInstanceB
34163
35- Download ` vim-solargraph.tar.gz ` from GitHub, extract it, and copy the contents
36- to your ` ~/.vim ` directory.
164+ ```
37165
38166
167+ Without ` neocomplete ` use ` CTRL+x CTRL+o ` shortcut to autocomplete after the dot ` . `
39168
40169
41170
0 commit comments