neovim 0.0.5 → 0.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +5 -2
  3. data/CHANGELOG.md +11 -0
  4. data/README.md +15 -4
  5. data/Rakefile +64 -4
  6. data/bin/j2mp +8 -0
  7. data/bin/mp2j +8 -0
  8. data/lib/neovim.rb +100 -17
  9. data/lib/neovim/api.rb +84 -0
  10. data/lib/neovim/async_session.rb +74 -21
  11. data/lib/neovim/buffer.rb +111 -4
  12. data/lib/neovim/client.rb +175 -4
  13. data/lib/neovim/current.rb +19 -8
  14. data/lib/neovim/event_loop.rb +55 -10
  15. data/lib/neovim/host.rb +21 -8
  16. data/lib/neovim/line_range.rb +55 -15
  17. data/lib/neovim/logging.rb +4 -0
  18. data/lib/neovim/manifest.rb +11 -3
  19. data/lib/neovim/msgpack_stream.rb +53 -19
  20. data/lib/neovim/notification.rb +2 -0
  21. data/lib/neovim/plugin.rb +12 -87
  22. data/lib/neovim/plugin/dsl.rb +81 -0
  23. data/lib/neovim/plugin/handler.rb +43 -0
  24. data/lib/neovim/remote_object.rb +64 -0
  25. data/lib/neovim/request.rb +4 -2
  26. data/lib/neovim/session.rb +167 -16
  27. data/lib/neovim/tabpage.rb +24 -2
  28. data/lib/neovim/version.rb +1 -1
  29. data/lib/neovim/window.rb +92 -2
  30. data/neovim.gemspec +1 -1
  31. data/spec/acceptance/neovim-ruby-host_spec.rb +16 -8
  32. data/spec/helper.rb +11 -3
  33. data/spec/neovim/api_spec.rb +40 -0
  34. data/spec/neovim/async_session_spec.rb +19 -25
  35. data/spec/neovim/current_spec.rb +64 -4
  36. data/spec/neovim/event_loop_spec.rb +18 -27
  37. data/spec/neovim/host_spec.rb +20 -1
  38. data/spec/neovim/manifest_spec.rb +0 -2
  39. data/spec/neovim/msgpack_stream_spec.rb +5 -6
  40. data/spec/neovim/{object_spec.rb → remote_object_spec.rb} +1 -4
  41. data/spec/neovim/session_spec.rb +18 -26
  42. data/spec/neovim_spec.rb +2 -3
  43. data/spec/support.rb +5 -5
  44. metadata +13 -6
  45. data/lib/neovim/api_info.rb +0 -27
  46. data/lib/neovim/object.rb +0 -40
@@ -5,7 +5,7 @@ module Neovim
5
5
  RSpec.describe MsgpackStream do
6
6
  shared_context "msgpack stream behavior" do
7
7
  it "sends and receives data" do
8
- stream = MsgpackStream.new(event_loop)
8
+ msgpack_stream = MsgpackStream.new(event_loop)
9
9
  client_messages = []
10
10
 
11
11
  server_thread = Thread.new do
@@ -17,14 +17,13 @@ module Neovim
17
17
  server.close
18
18
  end
19
19
 
20
- fiber = Fiber.new do
21
- msg_cb = Proc.new { |msg| Fiber.yield(msg) }
22
- stream.send([1]).run(msg_cb)
20
+ server_message = nil
21
+ msgpack_stream.write([1]).run do |message|
22
+ server_message = message
23
+ msgpack_stream.shutdown
23
24
  end
24
25
 
25
- server_message = fiber.resume
26
26
  server_thread.join
27
-
28
27
  expect(server_message).to eq([2])
29
28
  expect(client_messages).to eq([MessagePack.pack([1])])
30
29
  end
@@ -1,10 +1,7 @@
1
1
  require "helper"
2
- require "neovim/buffer"
3
- require "neovim/tabpage"
4
- require "neovim/window"
5
2
 
6
3
  module Neovim
7
- RSpec.describe Object do
4
+ RSpec.describe RemoteObject do
8
5
  context Window do
9
6
  let(:window) { Neovim.attach_child(["-n", "-u", "NONE"]).current.window }
10
7
 
@@ -5,12 +5,12 @@ require "fileutils"
5
5
  module Neovim
6
6
  RSpec.describe Session do
7
7
  shared_context "session behavior" do
8
- it "supports functions with async=false" do
8
+ it "supports requests" do
9
9
  expect(session.request(:vim_strwidth, "foobar")).to be(6)
10
10
  end
11
11
 
12
- it "supports functions with async=true" do
13
- expect(session.request(:vim_input, "jk")).to be(2)
12
+ it "supports notifications" do
13
+ expect(session.notify(:vim_input, "jk")).to be(nil)
14
14
  end
15
15
 
16
16
  it "raises an exception when there are errors" do
@@ -25,11 +25,19 @@ module Neovim
25
25
  expect(session.request(:vim_get_current_line)).to eq(large_str)
26
26
  end
27
27
 
28
- describe "#api_methods_for_prefix" do
29
- it "returns relevant functions without a prefix" do
30
- methods = session.api_methods_for_prefix("vim_")
31
- expect(methods).to include(:strwidth)
28
+ it "subscribes to events" do
29
+ session.request(:vim_subscribe, "my_event")
30
+ session.request(:vim_command, "call rpcnotify(0, 'my_event', 'foo')")
31
+
32
+ messages = []
33
+ session.run do |msg|
34
+ messages << msg
35
+ session.shutdown
32
36
  end
37
+
38
+ expect(messages.first).to be_a(Notification)
39
+ expect(messages.first.method_name).to eq("my_event")
40
+ expect(messages.first.arguments).to eq(["foo"])
33
41
  end
34
42
  end
35
43
 
@@ -56,12 +64,7 @@ module Neovim
56
64
  Process.waitpid(nvim_pid)
57
65
  end
58
66
 
59
- let(:session) do
60
- event_loop = EventLoop.tcp("0.0.0.0", nvim_port)
61
- stream = MsgpackStream.new(event_loop)
62
- async = AsyncSession.new(stream)
63
- Session.new(async)
64
- end
67
+ let(:session) { Session.tcp("0.0.0.0", nvim_port) }
65
68
 
66
69
  include_context "session behavior"
67
70
  end
@@ -89,24 +92,13 @@ module Neovim
89
92
  Process.waitpid(nvim_pid)
90
93
  end
91
94
 
92
- let(:session) do
93
- event_loop = EventLoop.unix(socket_path)
94
- stream = MsgpackStream.new(event_loop)
95
- async = AsyncSession.new(stream)
96
- Session.new(async)
97
- end
95
+ let(:session) { Session.unix(socket_path) }
98
96
 
99
97
  include_context "session behavior"
100
98
  end
101
99
 
102
100
  context "child" do
103
- let(:session) do
104
- event_loop = EventLoop.child(["-n", "-u", "NONE"])
105
- stream = MsgpackStream.new(event_loop)
106
- async = AsyncSession.new(stream)
107
- Session.new(async)
108
- end
109
-
101
+ let(:session) { Session.child(["-n", "-u", "NONE"]) }
110
102
  include_context "session behavior"
111
103
  end
112
104
  end
@@ -1,4 +1,3 @@
1
- require "neovim/plugin"
2
1
  require "helper"
3
2
  require "fileutils"
4
3
 
@@ -22,6 +21,7 @@ RSpec.describe Neovim do
22
21
  expect(Neovim.attach_tcp("0.0.0.0", port).strwidth("hi")).to eq(2)
23
22
  ensure
24
23
  Process.kill(:TERM, pid)
24
+ Process.waitpid(pid)
25
25
  end
26
26
  end
27
27
  end
@@ -49,8 +49,7 @@ RSpec.describe Neovim do
49
49
 
50
50
  describe ".attach_child" do
51
51
  it "spawns and attaches to a child process" do
52
- nvim = Neovim.attach_child(nvim_argv)
53
- expect(nvim.strwidth("hi")).to eq(2)
52
+ expect(Neovim.attach_child(nvim_argv).strwidth("hi")).to eq(2)
54
53
  end
55
54
  end
56
55
 
@@ -18,12 +18,12 @@ module Support
18
18
  File.join(workspace, name)
19
19
  end
20
20
 
21
- def self.remove_workspace
22
- FileUtils.rm_rf(workspace)
21
+ def self.setup_workspace
22
+ teardown_workspace
23
+ FileUtils.mkdir_p(workspace)
23
24
  end
24
25
 
25
- def self.clean_workspace
26
- remove_workspace
27
- FileUtils.mkdir_p(workspace)
26
+ def self.teardown_workspace
27
+ FileUtils.rm_rf(workspace)
28
28
  end
29
29
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: neovim
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alex Genco
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-03-03 00:00:00.000000000 Z
11
+ date: 2016-03-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: msgpack
@@ -111,9 +111,11 @@ files:
111
111
  - LICENSE.txt
112
112
  - README.md
113
113
  - Rakefile
114
+ - bin/j2mp
115
+ - bin/mp2j
114
116
  - bin/neovim-ruby-host
115
117
  - lib/neovim.rb
116
- - lib/neovim/api_info.rb
118
+ - lib/neovim/api.rb
117
119
  - lib/neovim/async_session.rb
118
120
  - lib/neovim/buffer.rb
119
121
  - lib/neovim/client.rb
@@ -125,8 +127,10 @@ files:
125
127
  - lib/neovim/manifest.rb
126
128
  - lib/neovim/msgpack_stream.rb
127
129
  - lib/neovim/notification.rb
128
- - lib/neovim/object.rb
129
130
  - lib/neovim/plugin.rb
131
+ - lib/neovim/plugin/dsl.rb
132
+ - lib/neovim/plugin/handler.rb
133
+ - lib/neovim/remote_object.rb
130
134
  - lib/neovim/request.rb
131
135
  - lib/neovim/session.rb
132
136
  - lib/neovim/tabpage.rb
@@ -135,6 +139,7 @@ files:
135
139
  - neovim.gemspec
136
140
  - spec/acceptance/neovim-ruby-host_spec.rb
137
141
  - spec/helper.rb
142
+ - spec/neovim/api_spec.rb
138
143
  - spec/neovim/async_session_spec.rb
139
144
  - spec/neovim/buffer_spec.rb
140
145
  - spec/neovim/client_spec.rb
@@ -144,8 +149,8 @@ files:
144
149
  - spec/neovim/line_range_spec.rb
145
150
  - spec/neovim/manifest_spec.rb
146
151
  - spec/neovim/msgpack_stream_spec.rb
147
- - spec/neovim/object_spec.rb
148
152
  - spec/neovim/plugin_spec.rb
153
+ - spec/neovim/remote_object_spec.rb
149
154
  - spec/neovim/session_spec.rb
150
155
  - spec/neovim/window_spec.rb
151
156
  - spec/neovim_spec.rb
@@ -177,6 +182,7 @@ summary: A Ruby client for Neovim
177
182
  test_files:
178
183
  - spec/acceptance/neovim-ruby-host_spec.rb
179
184
  - spec/helper.rb
185
+ - spec/neovim/api_spec.rb
180
186
  - spec/neovim/async_session_spec.rb
181
187
  - spec/neovim/buffer_spec.rb
182
188
  - spec/neovim/client_spec.rb
@@ -186,9 +192,10 @@ test_files:
186
192
  - spec/neovim/line_range_spec.rb
187
193
  - spec/neovim/manifest_spec.rb
188
194
  - spec/neovim/msgpack_stream_spec.rb
189
- - spec/neovim/object_spec.rb
190
195
  - spec/neovim/plugin_spec.rb
196
+ - spec/neovim/remote_object_spec.rb
191
197
  - spec/neovim/session_spec.rb
192
198
  - spec/neovim/window_spec.rb
193
199
  - spec/neovim_spec.rb
194
200
  - spec/support.rb
201
+ has_rdoc:
@@ -1,27 +0,0 @@
1
- require "delegate"
2
-
3
- module Neovim
4
- class APIInfo < SimpleDelegator
5
- def functions
6
- @functions ||= fetch(1).fetch("functions")
7
- end
8
-
9
- def types
10
- @types ||= fetch(1).fetch("types")
11
- end
12
-
13
- def channel_id
14
- @channel_id ||= fetch(0)
15
- end
16
-
17
- def defined?(function)
18
- functions.any? do |func|
19
- func["name"] == function.to_s
20
- end
21
- end
22
-
23
- def inspect
24
- "#<#{self.class}:0x%x @types={...} @functions={...}>" % (object_id << 1)
25
- end
26
- end
27
- end
@@ -1,40 +0,0 @@
1
- module Neovim
2
- class Object
3
- attr_reader :index
4
-
5
- def initialize(index, session)
6
- @index = index
7
- @session = session
8
- end
9
-
10
- def respond_to?(method_name)
11
- super || methods.include?(method_name.to_sym)
12
- end
13
-
14
- def method_missing(method_name, *args)
15
- if methods.include?(method_name)
16
- @session.request(qualify(method_name), @index, *args)
17
- else
18
- super
19
- end
20
- end
21
-
22
- def to_msgpack(packer)
23
- packer.pack(@index)
24
- end
25
-
26
- def methods
27
- super | @session.api_methods_for_prefix(function_prefix)
28
- end
29
-
30
- private
31
-
32
- def function_prefix
33
- "#{self.class.to_s.split("::").last.downcase}_"
34
- end
35
-
36
- def qualify(method_name)
37
- :"#{function_prefix}#{method_name}"
38
- end
39
- end
40
- end