neovim 0.8.0 → 0.8.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3c5af6d8f53a3684d8f7fe623c4d8f21ec8aaad9358984e963d956f31a2cb13b
4
- data.tar.gz: b4dfd461df1568f5b7068ea4a874061af968b85b25f2fee5e12a0f58f6531e2c
3
+ metadata.gz: fedda91f1ab06609df060e17b598655776a94fb60a7037fbdbeec1eebc24585d
4
+ data.tar.gz: 2e5a7ae9846c9b1375912cf129153f89ecadf2617b618267f6a44aed2c768843
5
5
  SHA512:
6
- metadata.gz: 31bccc282bc735d1595c4d7d63d31359d81e69fbae197593f14ef9bb6828cb33b0f767ab102f2ce3e3cb87cf693140f775c9e977de32b4f553e499c326725f03
7
- data.tar.gz: f81473f7655cb6a3398fc5e91775220e116d38957c0172c29898aa7e1bf743de24708e0b1757e10c2a0227a80ae93b5ad9e3f8c3f43eae77ed1f0d00790dc8bd
6
+ metadata.gz: 9c1238b3fb5ccb9595e81f872f1080114c63a01505f8f12a3d230cc3c3f039e8d89f3a69fb38df237e8420f732bb1627554c8b87b26a4e0eb98f59e1c3b17c5c
7
+ data.tar.gz: 7cf59362e19aa0ffbf44a1dd91fe62b7e822bf5c3dee5039adce141499139024fe7dbf0d6adaddb60cbe45144584662f1f23626d32bf16e9326d889ea402c39d
data/.gitignore CHANGED
@@ -22,3 +22,4 @@ spec/acceptance/runtime/flavors
22
22
  spec/acceptance/runtime/rplugin_manifest.vim
23
23
  vendor/bundle
24
24
  bin
25
+ .vim-flavor
@@ -10,6 +10,9 @@ AllCops:
10
10
  Layout/EndOfLine:
11
11
  EnforcedStyle: lf
12
12
 
13
+ Layout/MultilineMethodCallIndentation:
14
+ EnforcedStyle: indented
15
+
13
16
  Layout/SpaceAroundEqualsInParameterDefault:
14
17
  EnforcedStyle: no_space
15
18
 
@@ -100,6 +103,9 @@ Style/GlobalVars:
100
103
  - lib/neovim/ruby_provider/vim.rb
101
104
  - spec/neovim/ruby_provider/vim_spec.rb
102
105
 
106
+ Style/MultilineTernaryOperator:
107
+ Enabled: false
108
+
103
109
  Style/ParallelAssignment:
104
110
  Enabled: false
105
111
 
@@ -11,12 +11,14 @@ rvm:
11
11
  - 2.3
12
12
  - 2.4
13
13
  - 2.5
14
+ - 2.6
14
15
  - ruby-head
15
16
 
16
17
  before_install:
17
18
  - eval "$(curl --connect-timeout 30 --retry 3 -Ss https://raw.githubusercontent.com/neovim/bot-ci/master/scripts/travis-setup.sh) nightly-x64"
18
19
  - gem update --system --conservative || (gem install "rubygems-update:~>2.7" --no-document && update_rubygems)
19
- - gem install --remote bundler
20
+ - gem install --remote bundler || gem install --remote bundler -v "1.17.3"
21
+ - gem install --user-install executable-hooks
20
22
  - bundle --version
21
23
 
22
24
  env: NVIM_RUBY_LOG_LEVEL=DEBUG NVIM_RUBY_LOG_FILE=ci.log
@@ -1,3 +1,8 @@
1
+ # 0.8.1
2
+
3
+ - Set client info on host and client startup
4
+ - Add `Client#channel_id`
5
+
1
6
  # 0.8.0
2
7
 
3
8
  - Allow `Buffer#append` to take a string with newlines
data/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  # Neovim Ruby
2
2
 
3
3
  [![Travis](https://travis-ci.org/neovim/neovim-ruby.svg?branch=master)](https://travis-ci.org/neovim/neovim-ruby)
4
- [![Build status](https://ci.appveyor.com/api/projects/status/wp7agvgcxxcguj6h/branch/master?svg=true)](https://ci.appveyor.com/project/neovim/neovim-ruby/branch/master)
4
+ [![Build status](https://ci.appveyor.com/api/projects/status/y44k25tcdvvuq0ee?svg=true)](https://ci.appveyor.com/project/alexgenco/neovim-ruby)
5
5
  [![Gem Version](https://badge.fury.io/rb/neovim.svg)](https://badge.fury.io/rb/neovim)
6
6
  [![Inline docs](http://inch-ci.org/github/neovim/neovim-ruby.svg?branch=master)](http://inch-ci.org/github/neovim/neovim-ruby)
7
7
 
@@ -2,6 +2,7 @@ version: '{build}'
2
2
 
3
3
  environment:
4
4
  matrix:
5
+ - RUBY_VERSION: 26
5
6
  - RUBY_VERSION: 25
6
7
  - RUBY_VERSION: 24
7
8
  - RUBY_VERSION: 23
@@ -15,7 +16,7 @@ install:
15
16
  - set PATH=C:\Ruby%RUBY_VERSION%\bin;C:\tools\neovim\Neovim\bin;%PATH%
16
17
  - set NVIM_RUBY_LOG_LEVEL=DEBUG
17
18
  - set NVIM_RUBY_LOG_FILE=%cd%\ci.log
18
- - choco install neovim --pre -fy --ignore-dependencies
19
+ - choco install neovim --pre -fy --ignore-dependencies --ignore-checksums
19
20
  - bundle install --path vendor/bundle
20
21
 
21
22
  build: off
@@ -31,4 +32,4 @@ before_test:
31
32
  - nvim -v
32
33
 
33
34
  test_script:
34
- - bundle exec rake
35
+ - bundle exec rake spec:functional spec:acceptance
@@ -1,4 +1,5 @@
1
1
  require "neovim/client"
2
+ require "neovim/client_info"
2
3
  require "neovim/session"
3
4
  require "neovim/event_loop"
4
5
  require "neovim/executable"
@@ -62,7 +63,7 @@ module Neovim
62
63
  # @return [Client]
63
64
  # @see EventLoop.tcp
64
65
  def self.attach_tcp(host, port)
65
- Client.from_event_loop EventLoop.tcp(host, port)
66
+ attach(EventLoop.tcp(host, port))
66
67
  end
67
68
 
68
69
  # Connect to a running +nvim+ instance over a UNIX domain socket.
@@ -71,7 +72,7 @@ module Neovim
71
72
  # @return [Client]
72
73
  # @see EventLoop.unix
73
74
  def self.attach_unix(socket_path)
74
- Client.from_event_loop EventLoop.unix(socket_path)
75
+ attach(EventLoop.unix(socket_path))
75
76
  end
76
77
 
77
78
  # Spawn and connect to a child +nvim+ process.
@@ -80,7 +81,7 @@ module Neovim
80
81
  # @return [Client]
81
82
  # @see EventLoop.child
82
83
  def self.attach_child(argv=[executable.path])
83
- Client.from_event_loop EventLoop.child(argv)
84
+ attach(EventLoop.child(argv))
84
85
  end
85
86
 
86
87
  # Placeholder method for exposing the remote plugin DSL. This gets
@@ -116,4 +117,12 @@ module Neovim
116
117
  def self.logger
117
118
  Logging.logger
118
119
  end
120
+
121
+ # @api private
122
+ def self.attach(event_loop)
123
+ Client.from_event_loop(event_loop).tap do |client|
124
+ client.session.notify(:nvim_set_client_info, *ClientInfo.for_client.to_args)
125
+ end
126
+ end
127
+ private_class_method :attach
119
128
  end
@@ -4,7 +4,7 @@ require "neovim/line_range"
4
4
  module Neovim
5
5
  # Class representing an +nvim+ buffer.
6
6
  #
7
- # The methods documented here were generated using NVIM v0.3.1
7
+ # The methods documented here were generated using NVIM v0.3.7
8
8
  class Buffer < RemoteObject
9
9
  attr_reader :lines
10
10
 
@@ -164,6 +164,11 @@ module Neovim
164
164
  @param [Array<String>] replacement
165
165
  @return [void]
166
166
 
167
+ @method get_offset(index)
168
+ See +:h nvim_buf_get_offset()+
169
+ @param [Integer] index
170
+ @return [Integer]
171
+
167
172
  @method get_var(name)
168
173
  See +:h nvim_buf_get_var()+
169
174
  @param [String] name
@@ -218,6 +223,10 @@ module Neovim
218
223
  @param [String] name
219
224
  @return [void]
220
225
 
226
+ @method is_loaded
227
+ See +:h nvim_buf_is_loaded()+
228
+ @return [Boolean]
229
+
221
230
  @method is_valid
222
231
  See +:h nvim_buf_is_valid()+
223
232
  @return [Boolean]
@@ -227,22 +236,37 @@ module Neovim
227
236
  @param [String] name
228
237
  @return [Array<Integer>]
229
238
 
230
- @method add_highlight(src_id, hl_group, line, col_start, col_end)
239
+ @method add_highlight(ns_id, hl_group, line, col_start, col_end)
231
240
  See +:h nvim_buf_add_highlight()+
232
- @param [Integer] src_id
241
+ @param [Integer] ns_id
233
242
  @param [String] hl_group
234
243
  @param [Integer] line
235
244
  @param [Integer] col_start
236
245
  @param [Integer] col_end
237
246
  @return [Integer]
238
247
 
239
- @method clear_highlight(src_id, line_start, line_end)
248
+ @method clear_namespace(ns_id, line_start, line_end)
249
+ See +:h nvim_buf_clear_namespace()+
250
+ @param [Integer] ns_id
251
+ @param [Integer] line_start
252
+ @param [Integer] line_end
253
+ @return [void]
254
+
255
+ @method clear_highlight(ns_id, line_start, line_end)
240
256
  See +:h nvim_buf_clear_highlight()+
241
- @param [Integer] src_id
257
+ @param [Integer] ns_id
242
258
  @param [Integer] line_start
243
259
  @param [Integer] line_end
244
260
  @return [void]
245
261
 
262
+ @method set_virtual_text(ns_id, line, chunks, opts)
263
+ See +:h nvim_buf_set_virtual_text()+
264
+ @param [Integer] ns_id
265
+ @param [Integer] line
266
+ @param [Array] chunks
267
+ @param [Hash] opts
268
+ @return [Integer]
269
+
246
270
  =end
247
271
  end
248
272
  end
@@ -9,7 +9,7 @@ module Neovim
9
9
  # +RemoteObject+ subclasses (i.e. +Buffer+, +Window+, or +Tabpage+),
10
10
  # which similarly have dynamically generated interfaces.
11
11
  #
12
- # The methods documented here were generated using NVIM v0.3.1
12
+ # The methods documented here were generated using NVIM v0.3.7
13
13
  #
14
14
  # @see Buffer
15
15
  # @see Window
@@ -29,6 +29,10 @@ module Neovim
29
29
  @api = api
30
30
  end
31
31
 
32
+ def channel_id
33
+ @api.channel_id
34
+ end
35
+
32
36
  # Intercept method calls and delegate to appropriate RPC methods.
33
37
  def method_missing(method_name, *args)
34
38
  if (func = @api.function_for_object_method(self, method_name))
@@ -309,6 +313,15 @@ module Neovim
309
313
  @param [Tabpage] tabpage
310
314
  @return [void]
311
315
 
316
+ @method create_namespace(name)
317
+ See +:h nvim_create_namespace()+
318
+ @param [String] name
319
+ @return [Integer]
320
+
321
+ @method get_namespaces
322
+ See +:h nvim_get_namespaces()+
323
+ @return [Hash]
324
+
312
325
  @method subscribe(event)
313
326
  See +:h nvim_subscribe()+
314
327
  @param [String] event
@@ -0,0 +1,46 @@
1
+ require "neovim/version"
2
+
3
+ module Neovim
4
+ # @api private
5
+ class ClientInfo
6
+ HOST_METHOD_SPEC = {poll: {}, specs: {nargs: 1}}.freeze
7
+
8
+ ATTRIBUTES = {
9
+ website: "https://github.com/neovim/neovim-ruby",
10
+ license: "MIT"
11
+ }.freeze
12
+
13
+ def self.for_host(host)
14
+ name = host.plugins.map(&:script_host?) == [true] ?
15
+ "ruby-script-host" :
16
+ "ruby-rplugin-host"
17
+
18
+ new(name, :host, HOST_METHOD_SPEC, ATTRIBUTES)
19
+ end
20
+
21
+ def self.for_client
22
+ new("ruby-client", :remote, {}, ATTRIBUTES)
23
+ end
24
+
25
+ def initialize(name, type, method_spec, attributes)
26
+ @name = name
27
+ @type = type
28
+ @method_spec = method_spec
29
+ @attributes = attributes
30
+
31
+ @version = ["major", "minor", "patch"]
32
+ .zip(Neovim::VERSION.segments)
33
+ .to_h
34
+ end
35
+
36
+ def to_args
37
+ [
38
+ @name,
39
+ @version,
40
+ @type,
41
+ @method_spec,
42
+ @attributes
43
+ ]
44
+ end
45
+ end
46
+ end
@@ -1,5 +1,6 @@
1
1
  require "neovim"
2
2
  require "neovim/client"
3
+ require "neovim/client_info"
3
4
  require "neovim/event_loop"
4
5
  require "neovim/host/loader"
5
6
 
@@ -78,6 +79,8 @@ module Neovim
78
79
 
79
80
  def initialize_client(request_id)
80
81
  @session.request_id = request_id
82
+ @session.notify(:nvim_set_client_info, *ClientInfo.for_host(self).to_args)
83
+
81
84
  @client = Client.from_event_loop(@event_loop, @session)
82
85
  end
83
86
 
@@ -3,7 +3,7 @@ require "neovim/plugin/dsl"
3
3
  module Neovim
4
4
  # @api private
5
5
  class Plugin
6
- attr_accessor :handlers, :setup_blocks
6
+ attr_accessor :handlers, :setup_blocks, :script_host
7
7
  attr_reader :source
8
8
 
9
9
  def self.from_config_block(source)
@@ -13,9 +13,10 @@ module Neovim
13
13
  end
14
14
 
15
15
  def initialize(source)
16
- @handlers = []
17
16
  @source = source
17
+ @handlers = []
18
18
  @setup_blocks = []
19
+ @script_host = false
19
20
  end
20
21
 
21
22
  def specs
@@ -27,5 +28,9 @@ module Neovim
27
28
  def setup(client)
28
29
  @setup_blocks.each { |bl| bl.call(client) }
29
30
  end
31
+
32
+ def script_host?
33
+ !!@script_host
34
+ end
30
35
  end
31
36
  end
@@ -68,6 +68,12 @@ module Neovim
68
68
 
69
69
  private
70
70
 
71
+ # Mark this plugin as the Ruby script host started by nvim. Should only
72
+ # be used in +Neovim::RubyProvider+.
73
+ def script_host!
74
+ @plugin.script_host = true
75
+ end
76
+
71
77
  # Register a setup block to run once before the host starts. The block
72
78
  # should expect to receive a single argument, a +Neovim::Client+.
73
79
  #
@@ -14,6 +14,8 @@ module Neovim
14
14
  Thread.abort_on_exception = true
15
15
 
16
16
  Neovim.plugin do |plug|
17
+ plug.__send__(:script_host!)
18
+
17
19
  __define_setup(plug)
18
20
  __define_ruby_execute(plug)
19
21
  __define_ruby_execute_file(plug)
@@ -3,7 +3,7 @@ require "neovim/remote_object"
3
3
  module Neovim
4
4
  # Class representing an +nvim+ tabpage.
5
5
  #
6
- # The methods documented here were generated using NVIM v0.3.1
6
+ # The methods documented here were generated using NVIM v0.3.7
7
7
  class Tabpage < RemoteObject
8
8
  # The following methods are dynamically generated.
9
9
  =begin
@@ -1,3 +1,3 @@
1
1
  module Neovim
2
- VERSION = Gem::Version.new("0.8.0")
2
+ VERSION = Gem::Version.new("0.8.1")
3
3
  end
@@ -3,7 +3,7 @@ require "neovim/remote_object"
3
3
  module Neovim
4
4
  # Class representing an +nvim+ window.
5
5
  #
6
- # The methods documented here were generated using NVIM v0.3.1
6
+ # The methods documented here were generated using NVIM v0.3.7
7
7
  class Window < RemoteObject
8
8
  # Get the buffer displayed in the window
9
9
  #
@@ -68,6 +68,11 @@ module Neovim
68
68
  See +:h nvim_win_get_buf()+
69
69
  @return [Buffer]
70
70
 
71
+ @method set_buf(buffer)
72
+ See +:h nvim_win_set_buf()+
73
+ @param [Buffer] buffer
74
+ @return [void]
75
+
71
76
  @method get_cursor
72
77
  See +:h nvim_win_get_cursor()+
73
78
  @return [Array<Integer>]
@@ -0,0 +1,42 @@
1
+ let s:suite = themis#suite("Client info")
2
+ let s:expect = themis#helper("expect")
3
+
4
+ function! s:suite.before_each() abort
5
+ call RPluginFunctionArgs(1, 2)
6
+
7
+ let s:client_chans = map(
8
+ \ filter(nvim_list_chans(), "has_key(v:val, 'client')"),
9
+ \ "v:val.client")
10
+ endfunction
11
+
12
+ function! s:suite.get_script_host_client_info() abort
13
+ let client_info = s:client_chans[1]
14
+
15
+ call s:expect(sort(keys(client_info))).to_equal(
16
+ \ ["attributes", "methods", "name", "type", "version"])
17
+
18
+ call s:expect(client_info.attributes).to_be_dict()
19
+ call s:expect(client_info.methods).to_equal({"specs": {"nargs": 1}, "poll": {}})
20
+ call s:expect(client_info.name).to_equal("ruby-script-host")
21
+ call s:expect(client_info.type).to_equal("host")
22
+
23
+ call s:expect(client_info.version.major).to_be_number()
24
+ call s:expect(client_info.version.minor).to_be_number()
25
+ call s:expect(client_info.version.patch).to_be_number()
26
+ endfunction
27
+
28
+ function! s:suite.get_rplugin_client_info() abort
29
+ let client_info = s:client_chans[0]
30
+
31
+ call s:expect(sort(keys(client_info))).to_equal(
32
+ \ ["attributes", "methods", "name", "type", "version"])
33
+
34
+ call s:expect(client_info.attributes).to_be_dict()
35
+ call s:expect(client_info.methods).to_equal({"specs": {"nargs": 1}, "poll": {}})
36
+ call s:expect(client_info.name).to_equal("ruby-rplugin-host")
37
+ call s:expect(client_info.type).to_equal("host")
38
+
39
+ call s:expect(client_info.version.major).to_be_number()
40
+ call s:expect(client_info.version.minor).to_be_number()
41
+ call s:expect(client_info.version.patch).to_be_number()
42
+ endfunction
@@ -0,0 +1,77 @@
1
+ require "neovim/client_info"
2
+ require "neovim/host"
3
+ require "neovim/plugin"
4
+
5
+ module Neovim
6
+ RSpec.describe ClientInfo do
7
+ describe "#to_args" do
8
+ context ".for_host" do
9
+ it "returns script-host info" do
10
+ plugin = double(Plugin, script_host?: true)
11
+ host = double(Host, plugins: [plugin])
12
+ info = ClientInfo.for_host(host)
13
+
14
+ expect(info.to_args).to match(
15
+ [
16
+ "ruby-script-host",
17
+ {
18
+ "major" => duck_type(:to_int),
19
+ "minor" => duck_type(:to_int),
20
+ "patch" => duck_type(:to_int)
21
+ },
22
+ :host,
23
+ {
24
+ poll: {},
25
+ specs: {nargs: 1}
26
+ },
27
+ duck_type(:to_hash)
28
+ ]
29
+ )
30
+ end
31
+
32
+ it "returns rplugin info" do
33
+ plugin = double(Plugin, script_host?: false)
34
+ host = double(Host, plugins: [plugin])
35
+ info = ClientInfo.for_host(host)
36
+
37
+ expect(info.to_args).to match(
38
+ [
39
+ "ruby-rplugin-host",
40
+ {
41
+ "major" => duck_type(:to_int),
42
+ "minor" => duck_type(:to_int),
43
+ "patch" => duck_type(:to_int)
44
+ },
45
+ :host,
46
+ {
47
+ poll: {},
48
+ specs: {nargs: 1}
49
+ },
50
+ duck_type(:to_hash)
51
+ ]
52
+ )
53
+ end
54
+ end
55
+
56
+ context ".for_client" do
57
+ it "returns remote client info" do
58
+ info = ClientInfo.for_client
59
+
60
+ expect(info.to_args).to match(
61
+ [
62
+ "ruby-client",
63
+ {
64
+ "major" => duck_type(:to_int),
65
+ "minor" => duck_type(:to_int),
66
+ "patch" => duck_type(:to_int)
67
+ },
68
+ :remote,
69
+ {},
70
+ duck_type(:to_hash)
71
+ ]
72
+ )
73
+ end
74
+ end
75
+ end
76
+ end
77
+ end
@@ -19,9 +19,11 @@ module Neovim
19
19
  rd, wr = IO.pipe
20
20
  connection = Connection.new(nil_io, wr).write("some data")
21
21
 
22
- expect { connection.flush }
23
- .to change { IO.select([rd], nil, nil, 0.01) }
24
- .from(nil).to([[rd], [], []])
22
+ expect { rd.read_nonblock(16) }.to raise_error(IO::WaitReadable)
23
+
24
+ connection.flush
25
+
26
+ expect(rd.read_nonblock(16)).to eq(MessagePack.pack("some data"))
25
27
  end
26
28
 
27
29
  it "throws an exception when the file is closed" do
@@ -47,16 +47,17 @@ module Neovim
47
47
  end
48
48
 
49
49
  context "poll" do
50
- it "initializes a client and responds 'ok'" do
50
+ it "initializes a client, sets client info, and responds 'ok'" do
51
51
  nvim_wr.write([0, 1, :poll, []]).flush
52
- type, reqid, method = nvim_rd.read
53
52
 
54
- expect(type).to eq(0)
55
- expect(reqid).to eq(2)
56
- expect(method).to eq("nvim_get_api_info")
53
+ expect(nvim_rd.read).to match([2, "nvim_set_client_info", duck_type(:to_ary)])
54
+
55
+ type, reqid, method = nvim_rd.read
56
+ expect([type, reqid, method]).to match([0, duck_type(:to_int), "nvim_get_api_info"])
57
57
 
58
58
  api_info = [0, {"types" => {}, "functions" => {}}]
59
59
  nvim_wr.write([1, reqid, nil, api_info]).flush
60
+
60
61
  expect(nvim_rd.read).to eq([1, 1, nil, "ok"])
61
62
  end
62
63
  end
@@ -64,14 +65,20 @@ module Neovim
64
65
  context "after poll" do
65
66
  before do
66
67
  nvim_wr.write([0, 1, :poll, []]).flush
67
- _, reqid, = nvim_rd.read
68
+
69
+ expect(nvim_rd.read[1]).to eq("nvim_set_client_info")
70
+
71
+ _, reqid, method = nvim_rd.read
72
+
73
+ expect(method).to eq("nvim_get_api_info")
68
74
 
69
75
  session = Session.new(EventLoop.child(Support.child_argv))
70
76
  api_info = session.request(:nvim_get_api_info)
71
77
  session.shutdown
72
78
 
73
79
  nvim_wr.write([1, reqid, nil, api_info]).flush
74
- nvim_rd.read
80
+
81
+ expect(nvim_rd.read[3]).to eq("ok")
75
82
  end
76
83
 
77
84
  it "responds with specs to the 'specs' request" do
@@ -1,24 +1,52 @@
1
1
  require "helper"
2
2
 
3
3
  RSpec.describe Neovim do
4
+ shared_context "attached client" do
5
+ it "establishes an RPC connection" do
6
+ expect(client.strwidth("hi")).to eq(2)
7
+ end
8
+
9
+ it "sets appropriate client info" do
10
+ chan_info = client.evaluate("nvim_get_chan_info(#{client.channel_id})")
11
+
12
+ expect(chan_info).to match(
13
+ "client" => {
14
+ "name" => "ruby-client",
15
+ "version" => {
16
+ "major" => duck_type(:to_int),
17
+ "minor" => duck_type(:to_int),
18
+ "patch" => duck_type(:to_int)
19
+ },
20
+ "type" => "remote",
21
+ "methods" => {},
22
+ "attributes" => duck_type(:to_hash)
23
+ },
24
+ "id" => duck_type(:to_int),
25
+ "mode" => "rpc",
26
+ "stream" => stream
27
+ )
28
+ end
29
+ end
30
+
4
31
  describe ".attach_tcp" do
5
- it "attaches to a TCP socket" do
6
- port = Support.tcp_port
7
- env = {"NVIM_LISTEN_ADDRESS" => "127.0.0.1:#{port}"}
8
- pid = Process.spawn(env, *Support.child_argv, [:out, :err] => File::NULL)
9
-
10
- begin
11
- client = Neovim.attach_tcp("127.0.0.1", port)
12
- rescue Errno::ECONNREFUSED
13
- retry
32
+ include_context "attached client" do
33
+ let(:port) { Support.tcp_port }
34
+ let(:stream) { "socket" }
35
+
36
+ let!(:nvim_pid) do
37
+ env = {"NVIM_LISTEN_ADDRESS" => "127.0.0.1:#{port}"}
38
+ Process.spawn(env, *Support.child_argv, [:out, :err] => File::NULL)
14
39
  end
15
40
 
16
- begin
17
- expect(client.strwidth("hi")).to eq(2)
18
- ensure
19
- Support.kill(pid)
20
- Process.waitpid(pid)
41
+ let(:client) do
42
+ begin
43
+ Neovim.attach_tcp("127.0.0.1", port)
44
+ rescue Errno::ECONNREFUSED
45
+ retry
46
+ end
21
47
  end
48
+
49
+ after { Support.kill(nvim_pid) }
22
50
  end
23
51
  end
24
52
 
@@ -27,35 +55,37 @@ RSpec.describe Neovim do
27
55
  skip("Not supported on this platform") if Support.windows?
28
56
  end
29
57
 
30
- it "attaches to a UNIX socket" do
31
- socket_path = Support.socket_path
32
- env = {"NVIM_LISTEN_ADDRESS" => socket_path}
33
- pid = Process.spawn(env, *Support.child_argv, [:out, :err] => File::NULL)
58
+ include_context "attached client" do
59
+ let(:socket_path) { Support.socket_path }
60
+ let(:stream) { "socket" }
34
61
 
35
- begin
36
- client = Neovim.attach_unix(socket_path)
37
- rescue Errno::ENOENT, Errno::ECONNREFUSED
38
- retry
62
+ let!(:nvim_pid) do
63
+ env = {"NVIM_LISTEN_ADDRESS" => socket_path}
64
+ Process.spawn(env, *Support.child_argv, [:out, :err] => File::NULL)
39
65
  end
40
66
 
41
- begin
42
- expect(client.strwidth("hi")).to eq(2)
43
- ensure
44
- Support.kill(pid)
45
- Process.waitpid(pid)
67
+ let(:client) do
68
+ begin
69
+ Neovim.attach_unix(socket_path)
70
+ rescue Errno::ENOENT, Errno::ECONNREFUSED
71
+ retry
72
+ end
46
73
  end
74
+
75
+ after { Support.kill(nvim_pid) }
47
76
  end
48
77
  end
49
78
 
50
79
  describe ".attach_child" do
51
- it "spawns and attaches to a child process" do
52
- begin
53
- client = Neovim.attach_child(Support.child_argv)
54
- expect(client.strwidth("hi")).to eq(2)
55
- ensure
56
- client.shutdown
80
+ include_context "attached client" do
81
+ let(:stream) { "stdio" }
82
+
83
+ let(:client) do
84
+ Neovim.attach_child(Support.child_argv)
57
85
  end
58
86
  end
87
+
88
+ after { client.shutdown }
59
89
  end
60
90
 
61
91
  describe ".executable" do
@@ -43,6 +43,7 @@ module Support
43
43
 
44
44
  def self.kill(pid)
45
45
  windows? ? Process.kill(:KILL, pid) : Process.kill(:TERM, pid)
46
+ Process.waitpid(pid)
46
47
  end
47
48
 
48
49
  begin
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.8.0
4
+ version: 0.8.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alex Genco
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-12-27 00:00:00.000000000 Z
11
+ date: 2019-06-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: msgpack
@@ -160,6 +160,7 @@ files:
160
160
  - lib/neovim/api.rb
161
161
  - lib/neovim/buffer.rb
162
162
  - lib/neovim/client.rb
163
+ - lib/neovim/client_info.rb
163
164
  - lib/neovim/connection.rb
164
165
  - lib/neovim/current.rb
165
166
  - lib/neovim/event_loop.rb
@@ -188,6 +189,7 @@ files:
188
189
  - script/mp2j.rb
189
190
  - script/run_acceptance.rb
190
191
  - script/validate_docs.rb
192
+ - spec/acceptance/client_info_spec.vim
191
193
  - spec/acceptance/rplugin_autocmd_spec.vim
192
194
  - spec/acceptance/rplugin_command_spec.vim
193
195
  - spec/acceptance/rplugin_function_spec.vim
@@ -212,6 +214,7 @@ files:
212
214
  - spec/helper.rb
213
215
  - spec/neovim/api_spec.rb
214
216
  - spec/neovim/buffer_spec.rb
217
+ - spec/neovim/client_info_spec.rb
215
218
  - spec/neovim/client_spec.rb
216
219
  - spec/neovim/connection_spec.rb
217
220
  - spec/neovim/current_spec.rb
@@ -250,12 +253,12 @@ required_rubygems_version: !ruby/object:Gem::Requirement
250
253
  - !ruby/object:Gem::Version
251
254
  version: '0'
252
255
  requirements: []
253
- rubyforge_project:
254
- rubygems_version: 2.7.8
256
+ rubygems_version: 3.0.3
255
257
  signing_key:
256
258
  specification_version: 4
257
259
  summary: A Ruby client for Neovim
258
260
  test_files:
261
+ - spec/acceptance/client_info_spec.vim
259
262
  - spec/acceptance/rplugin_autocmd_spec.vim
260
263
  - spec/acceptance/rplugin_command_spec.vim
261
264
  - spec/acceptance/rplugin_function_spec.vim
@@ -280,6 +283,7 @@ test_files:
280
283
  - spec/helper.rb
281
284
  - spec/neovim/api_spec.rb
282
285
  - spec/neovim/buffer_spec.rb
286
+ - spec/neovim/client_info_spec.rb
283
287
  - spec/neovim/client_spec.rb
284
288
  - spec/neovim/connection_spec.rb
285
289
  - spec/neovim/current_spec.rb