neovim 0.6.2 → 0.7.0
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.
- checksums.yaml +5 -5
- data/.gitignore +1 -1
- data/.travis.yml +2 -3
- data/CHANGELOG.md +29 -0
- data/Gemfile +0 -11
- data/README.md +3 -3
- data/Rakefile +1 -1
- data/appveyor.yml +9 -1
- data/lib/neovim.rb +3 -3
- data/lib/neovim/client.rb +2 -3
- data/lib/neovim/connection.rb +69 -0
- data/lib/neovim/event_loop.rb +34 -34
- data/lib/neovim/host.rb +47 -51
- data/lib/neovim/host/loader.rb +1 -4
- data/lib/neovim/logging.rb +8 -8
- data/lib/neovim/message.rb +70 -0
- data/lib/neovim/plugin.rb +0 -3
- data/lib/neovim/plugin/handler.rb +6 -6
- data/lib/neovim/remote_object.rb +1 -1
- data/lib/neovim/ruby_provider.rb +25 -14
- data/lib/neovim/session.rb +36 -43
- data/lib/neovim/version.rb +1 -1
- data/neovim.gemspec +4 -0
- data/spec/acceptance/runtime/rplugin/ruby/autocmds.rb +3 -3
- data/spec/acceptance/runtime/rplugin/ruby/commands.rb +15 -15
- data/spec/acceptance/runtime/rplugin/ruby/functions.rb +5 -5
- data/spec/acceptance_spec.rb +19 -16
- data/spec/helper.rb +15 -0
- data/spec/neovim/connection_spec.rb +79 -0
- data/spec/neovim/event_loop_spec.rb +36 -50
- data/spec/neovim/host/loader_spec.rb +16 -9
- data/spec/neovim/host_spec.rb +82 -92
- data/spec/neovim/logging_spec.rb +6 -6
- data/spec/neovim/message_spec.rb +119 -0
- data/spec/neovim/plugin_spec.rb +31 -31
- data/spec/neovim/session_spec.rb +1 -1
- metadata +38 -15
- data/lib/neovim/event_loop/connection.rb +0 -78
- data/lib/neovim/event_loop/message_builder.rb +0 -127
- data/lib/neovim/event_loop/serializer.rb +0 -37
- data/spec/acceptance/runtime/rplugin.vim +0 -37
- data/spec/neovim/event_loop/connection_spec.rb +0 -89
- data/spec/neovim/event_loop/message_builder_spec.rb +0 -105
- data/spec/neovim/event_loop/serializer_spec.rb +0 -63
@@ -1,105 +0,0 @@
|
|
1
|
-
require "helper"
|
2
|
-
|
3
|
-
module Neovim
|
4
|
-
class EventLoop
|
5
|
-
RSpec.describe MessageBuilder do
|
6
|
-
let(:message_builder) { MessageBuilder.new }
|
7
|
-
|
8
|
-
describe "#write" do
|
9
|
-
context "requests" do
|
10
|
-
it "yields a valid request message" do
|
11
|
-
expect do |y|
|
12
|
-
message_builder.write(:request, :method, [1, 2], Proc.new {}, &y)
|
13
|
-
end.to yield_with_args([0, 1, :method, [1, 2]])
|
14
|
-
end
|
15
|
-
|
16
|
-
it "increments the request id" do
|
17
|
-
expect do |y|
|
18
|
-
message_builder.write(:request, :method, [], Proc.new {}, &y)
|
19
|
-
message_builder.write(:request, :method, [], Proc.new {}, &y)
|
20
|
-
end.to yield_successive_args(
|
21
|
-
[0, 1, :method, []],
|
22
|
-
[0, 2, :method, []]
|
23
|
-
)
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
context "responses" do
|
28
|
-
it "yields a valid response message" do
|
29
|
-
expect do |y|
|
30
|
-
message_builder.write(:response, 2, :value, "error msg", &y)
|
31
|
-
end.to yield_with_args([1, 2, "error msg", :value])
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
context "notifications" do
|
36
|
-
it "yields a valid notification message" do
|
37
|
-
expect do |y|
|
38
|
-
message_builder.write(:notification, :method, [1, 2], &y)
|
39
|
-
end.to yield_with_args([2, :method, [1, 2]])
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
describe "#read" do
|
45
|
-
context "requests" do
|
46
|
-
it "yields a request object" do
|
47
|
-
request = nil
|
48
|
-
message_builder.read([0, 1, :method, [1, 2]]) do |req|
|
49
|
-
request = req
|
50
|
-
end
|
51
|
-
|
52
|
-
expect(request.sync?).to eq(true)
|
53
|
-
expect(request.id).to eq(1)
|
54
|
-
expect(request.method_name).to eq(:method)
|
55
|
-
expect(request.arguments).to eq([1, 2])
|
56
|
-
end
|
57
|
-
end
|
58
|
-
|
59
|
-
context "responses" do
|
60
|
-
it "calls the registered handler with a success response" do
|
61
|
-
response = nil
|
62
|
-
handler = Proc.new { |res| response = res }
|
63
|
-
|
64
|
-
message_builder.write(:request, :method, [1, 2], handler) {}
|
65
|
-
message_builder.read([1, 1, [nil, nil], :result])
|
66
|
-
|
67
|
-
expect(response.request_id).to eq(1)
|
68
|
-
expect(response.value).to eq(:result)
|
69
|
-
expect(response.value!).to eq(:result)
|
70
|
-
expect(response.error).to eq(nil)
|
71
|
-
end
|
72
|
-
|
73
|
-
it "calls the registered handler with an error response" do
|
74
|
-
response = nil
|
75
|
-
|
76
|
-
handler = Proc.new do |res|
|
77
|
-
response = res
|
78
|
-
end
|
79
|
-
|
80
|
-
message_builder.write(:request, :method, [1, 2], handler) {}
|
81
|
-
message_builder.read([1, 1, [:some_err, "BOOM"], nil])
|
82
|
-
|
83
|
-
expect(response.request_id).to eq(1)
|
84
|
-
expect(response.error).to eq("BOOM")
|
85
|
-
expect(response.value).to eq(nil)
|
86
|
-
expect { response.value! }.to raise_error("BOOM")
|
87
|
-
end
|
88
|
-
end
|
89
|
-
|
90
|
-
context "notifications" do
|
91
|
-
it "yields a notification object" do
|
92
|
-
notification = nil
|
93
|
-
message_builder.read([2, :method, [1, 2]]) do |ntf|
|
94
|
-
notification = ntf
|
95
|
-
end
|
96
|
-
|
97
|
-
expect(notification.sync?).to eq(false)
|
98
|
-
expect(notification.method_name).to eq(:method)
|
99
|
-
expect(notification.arguments).to eq([1, 2])
|
100
|
-
end
|
101
|
-
end
|
102
|
-
end
|
103
|
-
end
|
104
|
-
end
|
105
|
-
end
|
@@ -1,63 +0,0 @@
|
|
1
|
-
require "helper"
|
2
|
-
|
3
|
-
module Neovim
|
4
|
-
class EventLoop
|
5
|
-
RSpec.describe Serializer do
|
6
|
-
let(:serializer) { Serializer.new }
|
7
|
-
|
8
|
-
describe "write" do
|
9
|
-
it "yields msgpack" do
|
10
|
-
expect do |y|
|
11
|
-
serializer.write([1, :foo], &y)
|
12
|
-
end.to yield_with_args(MessagePack.pack([1, :foo]))
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
describe "read" do
|
17
|
-
it "yields an unpacked object" do
|
18
|
-
expect do |y|
|
19
|
-
serializer.read(MessagePack.pack([1, :foo]), &y)
|
20
|
-
end.to yield_with_args([1, "foo"])
|
21
|
-
end
|
22
|
-
|
23
|
-
it "accumulates chunks of data and yields a single object" do
|
24
|
-
object = Array.new(16) { SecureRandom.hex(4) }
|
25
|
-
msgpack = MessagePack.pack(object)
|
26
|
-
|
27
|
-
expect do |y|
|
28
|
-
msgpack.chars.each_slice(10) do |chunk|
|
29
|
-
serializer.read(chunk.join, &y)
|
30
|
-
end
|
31
|
-
end.to yield_with_args(object)
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
describe "#register_type" do
|
36
|
-
it "registers a msgpack ext type" do
|
37
|
-
ext_class = Struct.new(:id) do
|
38
|
-
def self.from_msgpack_ext(data)
|
39
|
-
new(data.unpack('N')[0])
|
40
|
-
end
|
41
|
-
|
42
|
-
def to_msgpack_ext
|
43
|
-
[self.id].pack('C')
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
|
-
serializer.register_type(42) do |id|
|
48
|
-
ext_class.new(id)
|
49
|
-
end
|
50
|
-
|
51
|
-
factory = MessagePack::Factory.new
|
52
|
-
factory.register_type(42, ext_class)
|
53
|
-
obj = ext_class.new(1)
|
54
|
-
msgpack = factory.packer.write(obj).flush.to_str
|
55
|
-
|
56
|
-
expect do |y|
|
57
|
-
serializer.read(msgpack, &y)
|
58
|
-
end.to yield_with_args(obj)
|
59
|
-
end
|
60
|
-
end
|
61
|
-
end
|
62
|
-
end
|
63
|
-
end
|