neovim 0.3.0 → 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (53) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +8 -0
  3. data/Gemfile +1 -0
  4. data/README.md +6 -2
  5. data/Rakefile +4 -72
  6. data/bin/neovim-ruby-host +3 -2
  7. data/lib/neovim.rb +4 -16
  8. data/lib/neovim/buffer.rb +21 -0
  9. data/lib/neovim/client.rb +35 -0
  10. data/lib/neovim/host.rb +6 -4
  11. data/lib/neovim/host/loader.rb +2 -0
  12. data/lib/neovim/line_range.rb +1 -1
  13. data/lib/neovim/logging.rb +8 -7
  14. data/lib/neovim/plugin/dsl.rb +1 -1
  15. data/lib/neovim/ruby_provider.rb +7 -10
  16. data/lib/neovim/ruby_provider/buffer_ext.rb +3 -3
  17. data/lib/neovim/ruby_provider/vim.rb +6 -1
  18. data/lib/neovim/ruby_provider/window_ext.rb +3 -3
  19. data/lib/neovim/session.rb +2 -2
  20. data/lib/neovim/session/api.rb +7 -1
  21. data/lib/neovim/session/event_loop.rb +4 -12
  22. data/lib/neovim/session/serializer.rb +2 -2
  23. data/lib/neovim/tabpage.rb +6 -0
  24. data/lib/neovim/version.rb +1 -1
  25. data/lib/neovim/window.rb +19 -1
  26. data/script/generate_docs +71 -0
  27. data/{bin → script}/j2mp +0 -0
  28. data/{bin → script}/mp2j +0 -0
  29. data/spec/acceptance/neovim-ruby-host_spec.rb +1 -6
  30. data/spec/acceptance/ruby_provider_spec.rb +17 -33
  31. data/spec/helper.rb +42 -37
  32. data/spec/neovim/buffer_spec.rb +1 -1
  33. data/spec/neovim/client_spec.rb +1 -1
  34. data/spec/neovim/current_spec.rb +1 -1
  35. data/spec/neovim/host/loader_spec.rb +2 -0
  36. data/spec/neovim/host_spec.rb +25 -5
  37. data/spec/neovim/line_range_spec.rb +2 -2
  38. data/spec/neovim/logging_spec.rb +56 -0
  39. data/spec/neovim/plugin_spec.rb +9 -0
  40. data/spec/neovim/remote_object_spec.rb +5 -1
  41. data/spec/neovim/ruby_provider/buffer_ext_spec.rb +5 -5
  42. data/spec/neovim/ruby_provider/vim_spec.rb +32 -0
  43. data/spec/neovim/ruby_provider/window_ext_spec.rb +22 -8
  44. data/spec/neovim/session/api_spec.rb +24 -5
  45. data/spec/neovim/session/event_loop_spec.rb +54 -1
  46. data/spec/neovim/session/notification_spec.rb +20 -0
  47. data/spec/neovim/session/request_spec.rb +36 -0
  48. data/spec/neovim/session/rpc_spec.rb +12 -0
  49. data/spec/neovim/session/serializer_spec.rb +14 -0
  50. data/spec/neovim/session_spec.rb +4 -4
  51. data/spec/neovim/window_spec.rb +17 -1
  52. data/spec/neovim_spec.rb +4 -20
  53. metadata +13 -4
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e51184d65bdcfaf91be38f7ed8f794d1971e2bcd
4
- data.tar.gz: e5900e2d8a0849a2b7c195a701d07b4270ccf4e0
3
+ metadata.gz: 1a871663716cf365ee1902237772dc70a9d051ef
4
+ data.tar.gz: 12633a50fa0be3804b7cdba4bae04172110ac6e9
5
5
  SHA512:
6
- metadata.gz: 908119d756874c8d76e42056e2a99e009c0dc19dde6c865e9d0cbee9e33b4b1c485d08e9bf54fbfdf374f00518461122c3fe66b5119612b56afb6383319e5a9b
7
- data.tar.gz: 097c4a2565b01b6b6cb785601de2f526ec3c7b091f7fcd054b2ab87ea5d05acb27815f8abda84b665bcbc9e1ba4dde1883ed4fc88249d34cbafd2f26eab09f5a
6
+ metadata.gz: c262cb6913bb815a9a084d1e3684d77a5179a12ca358dad3b6b3d042e3226eebf6e92a6eeaefd5fbcc244e7de0118e692dce6dac21c84d86c15e815984f7c0ab
7
+ data.tar.gz: d0dabaa8e50df29e425d102bd386ea9578de6c3ebe0f7f9e8ec93a40434fc68c29c1174ed495fa57dc530fc96f566dca1d7a328de41e59a8efd5e74f26b11ee7
@@ -1,3 +1,11 @@
1
+ # 0.3.1
2
+ - Remove window caching to fix incompatibilities with command-t
3
+ - Add `Vim` module alias
4
+ - Fix `Window.count` and `Window.[]` to work with tabpages
5
+ - Fix `EventLoop.child` bug with repeated arguments
6
+ - Fix `Window#cursor=` incompatibilities
7
+ - Make `Neovim.attach_child` have default argv of `["nvim"]`
8
+
1
9
  # 0.3.0
2
10
  - Mark `Plugin::DSL#rpc` private
3
11
  - Rename Session constants:
data/Gemfile CHANGED
@@ -6,6 +6,7 @@ group :development do
6
6
  gem "coveralls"
7
7
  gem "pry-byebug"
8
8
  else
9
+ gem "term-ansicolor", "1.3.2"
9
10
  gem "coveralls", "0.8.13"
10
11
  gem "pry-debugger"
11
12
  end
data/README.md CHANGED
@@ -1,9 +1,11 @@
1
1
  # Neovim Ruby
2
2
 
3
- [![Gem Version](https://badge.fury.io/rb/neovim.svg)](https://badge.fury.io/rb/neovim)
4
3
  [![Travis](https://travis-ci.org/alexgenco/neovim-ruby.svg?branch=master)](https://travis-ci.org/alexgenco/neovim-ruby)
5
- [![Coverage Status](https://coveralls.io/repos/alexgenco/neovim-ruby/badge.png)](https://coveralls.io/r/alexgenco/neovim-ruby)
4
+ [![Coverage Status](https://coveralls.io/repos/alexgenco/neovim-ruby/badge.svg)](https://coveralls.io/r/alexgenco/neovim-ruby)
6
5
  [![Code Climate](https://codeclimate.com/github/alexgenco/neovim-ruby/badges/gpa.svg)](https://codeclimate.com/github/alexgenco/neovim-ruby)
6
+ [![Gem Version](https://badge.fury.io/rb/neovim.svg)](https://badge.fury.io/rb/neovim)
7
+ [![Dependency Status](https://gemnasium.com/badges/github.com/alexgenco/neovim-ruby.svg)](https://gemnasium.com/github.com/alexgenco/neovim-ruby)
8
+ [![Inline docs](http://inch-ci.org/github/alexgenco/neovim-ruby.svg?branch=master)](http://inch-ci.org/github/alexgenco/neovim-ruby)
7
9
 
8
10
  Ruby bindings for [Neovim](https://github.com/neovim/neovim).
9
11
 
@@ -70,6 +72,8 @@ end
70
72
 
71
73
  Ruby plugins go in the `$VIMRUNTIME/rplugin/ruby` directory, and are auto-loaded after calling `:UpdateRemotePlugins`. Refer to the [`Neovim::Plugin::DSL` docs](http://www.rubydoc.info/github/alexgenco/neovim-ruby/master/Neovim/Plugin/DSL) for a more complete overview.
72
74
 
75
+ ### Legacy Plugin Support
76
+
73
77
  The Neovim gem also acts as a compatibility layer for Ruby plugins written for legacy `vim`. The `:ruby`, `:rubyfile`, and `:rubydo` commands are intended to behave the same as they did in `vim`, and their documentation can be found [here](https://neovim.io/doc/user/if_ruby.html).
74
78
 
75
79
  ## Links
data/Rakefile CHANGED
@@ -2,77 +2,9 @@ require "bundler/gem_tasks"
2
2
  require "rspec/core/rake_task"
3
3
 
4
4
  RSpec::Core::RakeTask.new(:spec)
5
+ task :default => :spec
5
6
 
6
- namespace :neovim do
7
- desc "Generate Neovim remote API docs"
8
- task :generate_docs do
9
- require "neovim"
10
- require "pathname"
11
-
12
- vim_docs = []
13
- buffer_docs = []
14
- window_docs = []
15
- tabpage_docs = []
16
- session = Neovim::Session.child(%w(nvim -u NONE -n))
17
- vim_defs = Neovim::Client.instance_methods(false)
18
- buffer_defs = Neovim::Buffer.instance_methods(false)
19
- tabpage_defs = Neovim::Tabpage.instance_methods(false)
20
- window_defs = Neovim::Window.instance_methods(false)
21
-
22
- session.request(:vim_get_api_info)[1]["functions"].each do |func|
23
- prefix, method_name = func["name"].split("_", 2)
24
-
25
- case prefix
26
- when "vim"
27
- next if vim_defs.include?(method_name.to_sym)
28
- when "buffer"
29
- next if buffer_defs.include?(method_name.to_sym)
30
- when "tabpage"
31
- next if tabpage_defs.include?(method_name.to_sym)
32
- when "window"
33
- next if window_defs.include?(method_name.to_sym)
34
- end
35
-
36
- return_type = func["return_type"]
37
- params = func["parameters"]
38
- params.shift unless prefix == "vim"
39
- param_names = params.map(&:last)
40
- param_str = params.empty? ? "" : "(#{param_names.join(", ")})"
41
- method_decl = "@method #{method_name}#{param_str}"
42
- param_docs = params.map do |type, name|
43
- " @param [#{type}] #{name}"
44
- end
45
- return_doc = " @return [#{return_type}]\n"
46
- method_doc = [method_decl, *param_docs, return_doc].join("\n")
47
- method_doc.gsub!(/ArrayOf\((\w+)[^)]*\)/, 'Array<\1>')
48
- method_doc.gsub!(/Integer/, "Fixnum")
49
-
50
- case prefix
51
- when "vim"
52
- vim_docs << method_doc
53
- when "buffer"
54
- buffer_docs << method_doc
55
- when "tabpage"
56
- tabpage_docs << method_doc
57
- when "window"
58
- window_docs << method_doc
59
- end
60
- end
61
-
62
- lib_dir = Pathname.new(File.expand_path("../lib/neovim", __FILE__))
63
- {
64
- "client.rb" => vim_docs,
65
- "buffer.rb" => buffer_docs,
66
- "tabpage.rb" => tabpage_docs,
67
- "window.rb" => window_docs,
68
- }.each do |filename, docs|
69
- path = lib_dir.join(filename)
70
- contents = File.read(path)
71
- doc_str = ["=begin", *docs, "=end"].join("\n")
72
-
73
- File.write(path, contents.sub(/=begin.+=end/m, doc_str))
74
- end
75
- end
7
+ desc "Generate Neovim remote API docs"
8
+ task :docs do
9
+ sh File.expand_path("../script/generate_docs", __FILE__)
76
10
  end
77
-
78
- task :default => :spec
@@ -1,5 +1,6 @@
1
1
  #!/usr/bin/env ruby
2
- require "neovim"
2
+
3
+ require "neovim/host"
3
4
 
4
5
  ARGV.each do |arg|
5
6
  break if arg == "--"
@@ -13,5 +14,5 @@ end
13
14
  if STDIN.tty?
14
15
  abort("Can't run neovim-ruby-host interactively.")
15
16
  else
16
- Neovim.start_host(ARGV)
17
+ Neovim::Host.run(ARGV)
17
18
  end
@@ -1,7 +1,6 @@
1
1
  require "neovim/client"
2
- require "neovim/host"
2
+ require "neovim/logging"
3
3
  require "neovim/session"
4
- require "neovim/plugin"
5
4
  require "neovim/version"
6
5
 
7
6
  # The main entrypoint to the +Neovim+ gem. It allows you to connect to a
@@ -78,25 +77,14 @@ module Neovim
78
77
  # @param argv [Array] The arguments to pass to the spawned process
79
78
  # @return [Client]
80
79
  # @see Session.child
81
- def self.attach_child(argv=[])
80
+ def self.attach_child(argv=["nvim"])
82
81
  Client.new Session.child(argv)
83
82
  end
84
83
 
85
- # Start a plugin host. This is called by the +nvim-ruby-host+ executable,
86
- # which is spawned by +nvim+ to discover and run Ruby plugins, and acts as
87
- # the bridge between +nvim+ and the plugin.
88
- #
89
- # @param rplugin_paths [Array<String>] The paths to remote plugin files
90
- # @return [void]
91
- # @see Host
92
- def self.start_host(rplugin_paths)
93
- Host.load_from_files(rplugin_paths).run
94
- end
95
-
96
84
  # Placeholder method for exposing the remote plugin DSL. This gets
97
- # temporarily overwritten in +Host#load_files+.
85
+ # temporarily overwritten in +Host::Loader#load+.
98
86
  #
99
- # @see Host#load_files
87
+ # @see Host::Loader#load
100
88
  # @see Plugin::DSL
101
89
  def self.plugin
102
90
  raise "Can't call Neovim.plugin outside of a plugin host."
@@ -151,22 +151,27 @@ module Neovim
151
151
  # The following methods are dynamically generated.
152
152
  =begin
153
153
  @method line_count
154
+ Send the +buffer_line_count+ RPC to +nvim+
154
155
  @return [Fixnum]
155
156
 
156
157
  @method get_line(index)
158
+ Send the +buffer_get_line+ RPC to +nvim+
157
159
  @param [Fixnum] index
158
160
  @return [String]
159
161
 
160
162
  @method set_line(index, line)
163
+ Send the +buffer_set_line+ RPC to +nvim+
161
164
  @param [Fixnum] index
162
165
  @param [String] line
163
166
  @return [void]
164
167
 
165
168
  @method del_line(index)
169
+ Send the +buffer_del_line+ RPC to +nvim+
166
170
  @param [Fixnum] index
167
171
  @return [void]
168
172
 
169
173
  @method get_line_slice(start, end, include_start, include_end)
174
+ Send the +buffer_get_line_slice+ RPC to +nvim+
170
175
  @param [Fixnum] start
171
176
  @param [Fixnum] end
172
177
  @param [Boolean] include_start
@@ -174,12 +179,14 @@ module Neovim
174
179
  @return [Array<String>]
175
180
 
176
181
  @method get_lines(start, end, strict_indexing)
182
+ Send the +buffer_get_lines+ RPC to +nvim+
177
183
  @param [Fixnum] start
178
184
  @param [Fixnum] end
179
185
  @param [Boolean] strict_indexing
180
186
  @return [Array<String>]
181
187
 
182
188
  @method set_line_slice(start, end, include_start, include_end, replacement)
189
+ Send the +buffer_set_line_slice+ RPC to +nvim+
183
190
  @param [Fixnum] start
184
191
  @param [Fixnum] end
185
192
  @param [Boolean] include_start
@@ -188,6 +195,7 @@ module Neovim
188
195
  @return [void]
189
196
 
190
197
  @method set_lines(start, end, strict_indexing, replacement)
198
+ Send the +buffer_set_lines+ RPC to +nvim+
191
199
  @param [Fixnum] start
192
200
  @param [Fixnum] end
193
201
  @param [Boolean] strict_indexing
@@ -195,50 +203,62 @@ module Neovim
195
203
  @return [void]
196
204
 
197
205
  @method get_var(name)
206
+ Send the +buffer_get_var+ RPC to +nvim+
198
207
  @param [String] name
199
208
  @return [Object]
200
209
 
201
210
  @method set_var(name, value)
211
+ Send the +buffer_set_var+ RPC to +nvim+
202
212
  @param [String] name
203
213
  @param [Object] value
204
214
  @return [Object]
205
215
 
206
216
  @method del_var(name)
217
+ Send the +buffer_del_var+ RPC to +nvim+
207
218
  @param [String] name
208
219
  @return [Object]
209
220
 
210
221
  @method get_option(name)
222
+ Send the +buffer_get_option+ RPC to +nvim+
211
223
  @param [String] name
212
224
  @return [Object]
213
225
 
214
226
  @method set_option(name, value)
227
+ Send the +buffer_set_option+ RPC to +nvim+
215
228
  @param [String] name
216
229
  @param [Object] value
217
230
  @return [void]
218
231
 
219
232
  @method get_number
233
+ Send the +buffer_get_number+ RPC to +nvim+
220
234
  @return [Fixnum]
221
235
 
222
236
  @method get_name
237
+ Send the +buffer_get_name+ RPC to +nvim+
223
238
  @return [String]
224
239
 
225
240
  @method set_name(name)
241
+ Send the +buffer_set_name+ RPC to +nvim+
226
242
  @param [String] name
227
243
  @return [void]
228
244
 
229
245
  @method is_valid
246
+ Send the +buffer_is_valid+ RPC to +nvim+
230
247
  @return [Boolean]
231
248
 
232
249
  @method insert(lnum, lines)
250
+ Send the +buffer_insert+ RPC to +nvim+
233
251
  @param [Fixnum] lnum
234
252
  @param [Array<String>] lines
235
253
  @return [void]
236
254
 
237
255
  @method get_mark(name)
256
+ Send the +buffer_get_mark+ RPC to +nvim+
238
257
  @param [String] name
239
258
  @return [Array<Fixnum>]
240
259
 
241
260
  @method add_highlight(src_id, hl_group, line, col_start, col_end)
261
+ Send the +buffer_add_highlight+ RPC to +nvim+
242
262
  @param [Fixnum] src_id
243
263
  @param [String] hl_group
244
264
  @param [Fixnum] line
@@ -247,6 +267,7 @@ module Neovim
247
267
  @return [Fixnum]
248
268
 
249
269
  @method clear_highlight(src_id, line_start, line_end)
270
+ Send the +buffer_clear_highlight+ RPC to +nvim+
250
271
  @param [Fixnum] src_id
251
272
  @param [Fixnum] line_start
252
273
  @param [Fixnum] line_end
@@ -105,20 +105,24 @@ module Neovim
105
105
  # The following methods are dynamically generated.
106
106
  =begin
107
107
  @method command(str)
108
+ Send the +vim_command+ RPC to +nvim+
108
109
  @param [String] str
109
110
  @return [void]
110
111
 
111
112
  @method feedkeys(keys, mode, escape_csi)
113
+ Send the +vim_feedkeys+ RPC to +nvim+
112
114
  @param [String] keys
113
115
  @param [String] mode
114
116
  @param [Boolean] escape_csi
115
117
  @return [void]
116
118
 
117
119
  @method input(keys)
120
+ Send the +vim_input+ RPC to +nvim+
118
121
  @param [String] keys
119
122
  @return [Fixnum]
120
123
 
121
124
  @method replace_termcodes(str, from_part, do_lt, special)
125
+ Send the +vim_replace_termcodes+ RPC to +nvim+
122
126
  @param [String] str
123
127
  @param [Boolean] from_part
124
128
  @param [Boolean] do_lt
@@ -126,118 +130,149 @@ module Neovim
126
130
  @return [String]
127
131
 
128
132
  @method command_output(str)
133
+ Send the +vim_command_output+ RPC to +nvim+
129
134
  @param [String] str
130
135
  @return [String]
131
136
 
132
137
  @method eval(str)
138
+ Send the +vim_eval+ RPC to +nvim+
133
139
  @param [String] str
134
140
  @return [Object]
135
141
 
136
142
  @method call_function(fname, args)
143
+ Send the +vim_call_function+ RPC to +nvim+
137
144
  @param [String] fname
138
145
  @param [Array] args
139
146
  @return [Object]
140
147
 
141
148
  @method strwidth(str)
149
+ Send the +vim_strwidth+ RPC to +nvim+
142
150
  @param [String] str
143
151
  @return [Fixnum]
144
152
 
145
153
  @method list_runtime_paths
154
+ Send the +vim_list_runtime_paths+ RPC to +nvim+
146
155
  @return [Array<String>]
147
156
 
148
157
  @method change_directory(dir)
158
+ Send the +vim_change_directory+ RPC to +nvim+
149
159
  @param [String] dir
150
160
  @return [void]
151
161
 
152
162
  @method get_current_line
163
+ Send the +vim_get_current_line+ RPC to +nvim+
153
164
  @return [String]
154
165
 
155
166
  @method set_current_line(line)
167
+ Send the +vim_set_current_line+ RPC to +nvim+
156
168
  @param [String] line
157
169
  @return [void]
158
170
 
159
171
  @method del_current_line
172
+ Send the +vim_del_current_line+ RPC to +nvim+
160
173
  @return [void]
161
174
 
162
175
  @method get_var(name)
176
+ Send the +vim_get_var+ RPC to +nvim+
163
177
  @param [String] name
164
178
  @return [Object]
165
179
 
166
180
  @method set_var(name, value)
181
+ Send the +vim_set_var+ RPC to +nvim+
167
182
  @param [String] name
168
183
  @param [Object] value
169
184
  @return [Object]
170
185
 
171
186
  @method del_var(name)
187
+ Send the +vim_del_var+ RPC to +nvim+
172
188
  @param [String] name
173
189
  @return [Object]
174
190
 
175
191
  @method get_vvar(name)
192
+ Send the +vim_get_vvar+ RPC to +nvim+
176
193
  @param [String] name
177
194
  @return [Object]
178
195
 
179
196
  @method get_option(name)
197
+ Send the +vim_get_option+ RPC to +nvim+
180
198
  @param [String] name
181
199
  @return [Object]
182
200
 
183
201
  @method out_write(str)
202
+ Send the +vim_out_write+ RPC to +nvim+
184
203
  @param [String] str
185
204
  @return [void]
186
205
 
187
206
  @method err_write(str)
207
+ Send the +vim_err_write+ RPC to +nvim+
188
208
  @param [String] str
189
209
  @return [void]
190
210
 
191
211
  @method report_error(str)
212
+ Send the +vim_report_error+ RPC to +nvim+
192
213
  @param [String] str
193
214
  @return [void]
194
215
 
195
216
  @method get_buffers
217
+ Send the +vim_get_buffers+ RPC to +nvim+
196
218
  @return [Array<Buffer>]
197
219
 
198
220
  @method get_current_buffer
221
+ Send the +vim_get_current_buffer+ RPC to +nvim+
199
222
  @return [Buffer]
200
223
 
201
224
  @method set_current_buffer(buffer)
225
+ Send the +vim_set_current_buffer+ RPC to +nvim+
202
226
  @param [Buffer] buffer
203
227
  @return [void]
204
228
 
205
229
  @method get_windows
230
+ Send the +vim_get_windows+ RPC to +nvim+
206
231
  @return [Array<Window>]
207
232
 
208
233
  @method get_current_window
234
+ Send the +vim_get_current_window+ RPC to +nvim+
209
235
  @return [Window]
210
236
 
211
237
  @method set_current_window(window)
238
+ Send the +vim_set_current_window+ RPC to +nvim+
212
239
  @param [Window] window
213
240
  @return [void]
214
241
 
215
242
  @method get_tabpages
243
+ Send the +vim_get_tabpages+ RPC to +nvim+
216
244
  @return [Array<Tabpage>]
217
245
 
218
246
  @method get_current_tabpage
247
+ Send the +vim_get_current_tabpage+ RPC to +nvim+
219
248
  @return [Tabpage]
220
249
 
221
250
  @method set_current_tabpage(tabpage)
251
+ Send the +vim_set_current_tabpage+ RPC to +nvim+
222
252
  @param [Tabpage] tabpage
223
253
  @return [void]
224
254
 
225
255
  @method subscribe(event)
256
+ Send the +vim_subscribe+ RPC to +nvim+
226
257
  @param [String] event
227
258
  @return [void]
228
259
 
229
260
  @method unsubscribe(event)
261
+ Send the +vim_unsubscribe+ RPC to +nvim+
230
262
  @param [String] event
231
263
  @return [void]
232
264
 
233
265
  @method name_to_color(name)
266
+ Send the +vim_name_to_color+ RPC to +nvim+
234
267
  @param [String] name
235
268
  @return [Fixnum]
236
269
 
237
270
  @method get_color_map
271
+ Send the +vim_get_color_map+ RPC to +nvim+
238
272
  @return [Dictionary]
239
273
 
240
274
  @method get_api_info
275
+ Send the +vim_get_api_info+ RPC to +nvim+
241
276
  @return [Array]
242
277
 
243
278
  =end