neovim 0.7.1 → 0.8.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.
Files changed (45) hide show
  1. checksums.yaml +5 -5
  2. data/.gitignore +1 -0
  3. data/.rubocop.yml +8 -0
  4. data/.travis.yml +4 -3
  5. data/CHANGELOG.md +11 -0
  6. data/README.md +10 -13
  7. data/Rakefile +18 -3
  8. data/appveyor.yml +4 -1
  9. data/{bin → exe}/neovim-ruby-host +0 -0
  10. data/lib/neovim/buffer.rb +34 -36
  11. data/lib/neovim/client.rb +121 -36
  12. data/lib/neovim/connection.rb +7 -1
  13. data/lib/neovim/event_loop.rb +3 -2
  14. data/lib/neovim/message.rb +1 -1
  15. data/lib/neovim/remote_object.rb +5 -2
  16. data/lib/neovim/ruby_provider.rb +2 -2
  17. data/lib/neovim/ruby_provider/vim.rb +6 -5
  18. data/lib/neovim/session.rb +11 -1
  19. data/lib/neovim/tabpage.rb +8 -15
  20. data/lib/neovim/version.rb +1 -1
  21. data/lib/neovim/window.rb +17 -33
  22. data/neovim.gemspec +4 -4
  23. data/script/dump_api.rb +1 -1
  24. data/script/generate_docs.rb +6 -7
  25. data/script/run_acceptance.rb +1 -1
  26. data/script/validate_docs.rb +1 -1
  27. data/spec/acceptance/ruby_spec.vim +13 -11
  28. data/spec/acceptance/rubydo_spec.vim +9 -0
  29. data/spec/acceptance/rubyfile/curbuf_ivar_get.rb +1 -1
  30. data/spec/acceptance/rubyfile/curbuf_ivar_set.rb +1 -1
  31. data/spec/acceptance/rubyfile/define_foo.rb +1 -1
  32. data/spec/acceptance/rubyfile/nested_inner.rb +1 -1
  33. data/spec/acceptance/rubyfile/set_pwd_after.rb +1 -1
  34. data/spec/acceptance/rubyfile/set_pwd_before.rb +1 -1
  35. data/spec/acceptance/rubyfile_spec.vim +15 -13
  36. data/spec/acceptance/runtime/init.vim +2 -2
  37. data/spec/helper.rb +1 -6
  38. data/spec/neovim/buffer_spec.rb +6 -0
  39. data/spec/neovim/client_spec.rb +7 -0
  40. data/spec/neovim/connection_spec.rb +30 -4
  41. data/spec/neovim/event_loop_spec.rb +6 -0
  42. data/spec/neovim/session_spec.rb +6 -0
  43. data/spec/support.rb +1 -1
  44. metadata +8 -23
  45. data/.coveralls.yml +0 -1
@@ -42,6 +42,15 @@ function! s:suite.updates_all_lines() abort
42
42
  call s:expect(getline(1, 4)).to_equal(["ONE", "TWO", "THREE", "FOUR"])
43
43
  endfunction
44
44
 
45
+ function! s:suite.ignores_line_deletion() abort
46
+ " Just ensure `Index out of bounds` exception isn't raised.
47
+ "
48
+ " Deleting or adding lines inside `:rubydo` is documented as not supported.
49
+ " Therefore this will remain inconsistent with Vim, which deletes all but
50
+ " the first line (?)
51
+ %rubydo Vim.command("%d")
52
+ endfunction
53
+
45
54
  function! s:suite.handles_standard_error() abort
46
55
  try
47
56
  1rubydo raise "BOOM"
@@ -1 +1 @@
1
- Vim.command("let g:foo = #{$curbuf.instance_variable_get(:@foo)}")
1
+ Vim.command("let s:var = #{$curbuf.instance_variable_get(:@var)}")
@@ -1 +1 @@
1
- $curbuf.instance_variable_set(:@foo, 123)
1
+ $curbuf.instance_variable_set(:@var, 123)
@@ -1,3 +1,3 @@
1
1
  def foo
2
- Vim.command("let g:called = 1")
2
+ Vim.command("let s:var = 1")
3
3
  end
@@ -1 +1 @@
1
- Vim.command("let g:ruby_nested = 123")
1
+ Vim.command("let s:var = 123")
@@ -1 +1 @@
1
- Vim.command("let g:pwd_after = '#{Dir.pwd}'")
1
+ Vim.command("call add(s:var, '#{Dir.pwd}')")
@@ -1 +1 @@
1
- Vim.command("let g:pwd_before = '#{Dir.pwd.sub(/^C:/, '')}'")
1
+ Vim.command("let s:var = ['#{Dir.pwd.sub(/^C:/, '')}']")
@@ -2,12 +2,13 @@ let s:suite = themis#suite(":rubyfile")
2
2
  let s:expect = themis#helper("expect")
3
3
 
4
4
  function! s:suite.before() abort
5
- let g:return_pwd = getcwd()
5
+ let s:pwd = getcwd()
6
6
  cd spec/acceptance/rubyfile
7
+ unlet! s:var
7
8
  endfunction
8
9
 
9
10
  function! s:suite.after() abort
10
- execute("cd " . g:return_pwd)
11
+ execute("cd " . s:pwd)
11
12
  endfunction
12
13
 
13
14
  function! s:suite.before_each() abort
@@ -23,42 +24,43 @@ function! s:suite.defines_a_ruby_method() abort
23
24
  rubyfile ./define_foo.rb
24
25
  rubyfile ./call_foo.rb
25
26
 
26
- call s:expect(g:called).to_equal(1)
27
+ call s:expect(s:var).to_equal(1)
27
28
  endfunction
28
29
 
29
30
  function! s:suite.persists_curbuf_state() abort
30
31
  rubyfile ./curbuf_ivar_set.rb
31
32
  rubyfile ./curbuf_ivar_get.rb
32
33
 
33
- call s:expect(g:foo).to_equal(123)
34
+ call s:expect(s:var).to_equal(123)
34
35
  endfunction
35
36
 
36
37
  function! s:suite.updates_working_directory() abort
37
- let g:rubyfile = getcwd() . "/set_pwd_before.rb"
38
+ let s:rubyfile = getcwd() . "/set_pwd_before.rb"
38
39
  cd /
39
- exec "rubyfile " . g:rubyfile
40
+ exec "rubyfile " . s:rubyfile
40
41
  cd -
41
42
 
42
- call s:expect(g:pwd_before).to_equal("/")
43
+ call s:expect(s:var).to_equal(["/"])
43
44
  endfunction
44
45
 
45
46
  function! s:suite.updates_working_directory_implicitly() abort
46
- let g:before_file = getcwd() . "/set_pwd_before.rb"
47
- let g:after_file = getcwd() . "/set_pwd_after.rb"
47
+ let s:before_file = getcwd() . "/set_pwd_before.rb"
48
+ let s:after_file = getcwd() . "/set_pwd_after.rb"
48
49
 
49
50
  split | lcd /
50
- exec "rubyfile " . g:before_file
51
+ exec "rubyfile " . s:before_file
51
52
  wincmd p
52
- exec "rubyfile " . g:after_file
53
+ exec "rubyfile " . s:after_file
53
54
  wincmd p | lcd -
54
55
 
55
- call s:expect(g:pwd_before).not.to_equal(g:pwd_after)
56
+ call s:expect(len(s:var)).to_equal(2)
57
+ call s:expect(s:var[0]).not.to_equal(s:var[1])
56
58
  endfunction
57
59
 
58
60
  function! s:suite.supports_nesting() abort
59
61
  rubyfile ./nested.rb
60
62
 
61
- call s:expect(g:ruby_nested).to_equal(123)
63
+ call s:expect(s:var).to_equal(123)
62
64
  endfunction
63
65
 
64
66
  function! s:suite.handles_standard_error() abort
@@ -1,7 +1,7 @@
1
1
  let s:lib_path = getcwd() . "/lib"
2
- let s:bin_path = getcwd() . "/bin/neovim-ruby-host"
2
+ let s:exe_path = getcwd() . "/exe/neovim-ruby-host"
3
3
  let g:acceptance_rtp = getcwd() . "/spec/acceptance/runtime"
4
- let g:ruby_host_prog = printf("ruby -I %s %s", s:lib_path, s:bin_path)
4
+ let g:ruby_host_prog = printf("ruby -I %s %s", s:lib_path, s:exe_path)
5
5
 
6
6
  ruby require "rspec/expectations"
7
7
  ruby include ::RSpec::Matchers.dup
@@ -1,10 +1,5 @@
1
1
  require "bundler/setup"
2
2
 
3
- if ENV["REPORT_COVERAGE"]
4
- require "coveralls"
5
- Coveralls.wear!
6
- end
7
-
8
3
  require "fileutils"
9
4
  require "msgpack"
10
5
  require "neovim"
@@ -14,7 +9,7 @@ require "securerandom"
14
9
  require "stringio"
15
10
  require "timeout"
16
11
 
17
- require File.expand_path("../support.rb", __FILE__)
12
+ require File.expand_path("support.rb", __dir__)
18
13
 
19
14
  RSpec.configure do |config|
20
15
  config.expect_with :rspec do |exp|
@@ -124,6 +124,12 @@ module Neovim
124
124
  end.to change { buffer.lines.to_a }.to(["first", "one", "two"])
125
125
  end
126
126
 
127
+ it "allows newlines" do
128
+ expect do
129
+ buffer.append(0, "first\nsecond")
130
+ end.to change { buffer.lines.to_a }.to(["first", "second", "one", "two"])
131
+ end
132
+
127
133
  it "doesn't move the cursor" do
128
134
  expect do
129
135
  buffer.append(0, "first")
@@ -25,6 +25,13 @@ module Neovim
25
25
  end
26
26
  end
27
27
 
28
+ describe "#shutdown" do
29
+ it "causes nvim to exit" do
30
+ client.shutdown
31
+ expect { client.strwidth("hi") }.to raise_error(Neovim::Session::Exited)
32
+ end
33
+ end
34
+
28
35
  describe "#respond_to?" do
29
36
  it "returns true for vim functions" do
30
37
  expect(client).to respond_to(:strwidth)
@@ -7,11 +7,29 @@ module Neovim
7
7
  describe "#write" do
8
8
  it "writes msgpack to the underlying file descriptor" do
9
9
  rd, wr = IO.pipe
10
- connection = Connection.new(nil_io, wr)
11
- connection.write("some data")
10
+ Connection.new(nil_io, wr).write("some data").flush
11
+ data = rd.readpartial(1024)
12
+
13
+ expect(MessagePack.unpack(data)).to eq("some data")
14
+ end
15
+ end
16
+
17
+ describe "#flush" do
18
+ it "flushes writes to the underlying file descriptor" do
19
+ rd, wr = IO.pipe
20
+ connection = Connection.new(nil_io, wr).write("some data")
21
+
22
+ expect { connection.flush }
23
+ .to change { IO.select([rd], nil, nil, 0.01) }
24
+ .from(nil).to([[rd], [], []])
25
+ end
26
+
27
+ it "throws an exception when the file is closed" do
28
+ _, wr = IO.pipe
29
+ connection = Connection.new(nil_io, wr).write("some data")
12
30
  wr.close
13
31
 
14
- expect(MessagePack.unpack(rd.read)).to eq("some data")
32
+ expect { connection.flush }.to raise_error(IOError)
15
33
  end
16
34
  end
17
35
 
@@ -19,11 +37,19 @@ module Neovim
19
37
  it "reads msgpack from the underlying file descriptor" do
20
38
  rd, wr = IO.pipe
21
39
  wr.write(MessagePack.pack("some data"))
22
- wr.close
40
+ wr.flush
23
41
 
24
42
  connection = Connection.new(rd, nil_io)
25
43
  expect(connection.read).to eq("some data")
26
44
  end
45
+
46
+ it "throws an exception when the file is closed" do
47
+ rd, wr = IO.pipe
48
+ wr.close
49
+
50
+ connection = Connection.new(rd, nil_io)
51
+ expect { connection.read }.to raise_error(EOFError)
52
+ end
27
53
  end
28
54
 
29
55
  describe "#register_type" do
@@ -16,7 +16,9 @@ module Neovim
16
16
  describe "#request" do
17
17
  it "writes a msgpack request" do
18
18
  event_loop.request(1, :method, 1, 2)
19
+ connection.flush
19
20
  message = server_rd.readpartial(1024)
21
+
20
22
  expect(message).to eq(MessagePack.pack([0, 1, "method", [1, 2]]))
21
23
  end
22
24
  end
@@ -24,7 +26,9 @@ module Neovim
24
26
  describe "#respond" do
25
27
  it "writes a msgpack response" do
26
28
  event_loop.respond(2, "value", "error")
29
+ connection.flush
27
30
  message = server_rd.readpartial(1024)
31
+
28
32
  expect(message).to eq(MessagePack.pack([1, 2, "error", "value"]))
29
33
  end
30
34
  end
@@ -32,7 +36,9 @@ module Neovim
32
36
  describe "#notify" do
33
37
  it "writes a msgpack notification" do
34
38
  event_loop.notify(:method, 1, 2)
39
+ connection.flush
35
40
  message = server_rd.readpartial(1024)
41
+
36
42
  expect(message).to eq(MessagePack.pack([2, "method", [1, 2]]))
37
43
  end
38
44
  end
@@ -24,6 +24,12 @@ module Neovim
24
24
  expect(session.request(:nvim_get_current_line)).to eq(large_str)
25
25
  end
26
26
 
27
+ it "raises an exception when a command causes nvim to exit" do
28
+ expect do
29
+ session.request(:nvim_command, "qa!")
30
+ end.to raise_error(Neovim::Session::Exited, /exited/)
31
+ end
32
+
27
33
  it "fails outside of the main thread", :silence_thread_exceptions do
28
34
  expect do
29
35
  Thread.new { session.request(:nvim_strwidth, "foo") }.join
@@ -4,7 +4,7 @@ module Support
4
4
  end
5
5
 
6
6
  def self.workspace
7
- File.expand_path("../workspace", __FILE__)
7
+ File.expand_path("workspace", __dir__)
8
8
  end
9
9
 
10
10
  def self.socket_path
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.7.1
4
+ version: 0.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alex Genco
8
8
  autorequire:
9
- bindir: bin
9
+ bindir: exe
10
10
  cert_chain: []
11
- date: 2018-03-04 00:00:00.000000000 Z
11
+ date: 2018-12-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: msgpack
@@ -52,20 +52,6 @@ dependencies:
52
52
  - - ">="
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
- - !ruby/object:Gem::Dependency
56
- name: coveralls
57
- requirement: !ruby/object:Gem::Requirement
58
- requirements:
59
- - - ">="
60
- - !ruby/object:Gem::Version
61
- version: '0'
62
- type: :development
63
- prerelease: false
64
- version_requirements: !ruby/object:Gem::Requirement
65
- requirements:
66
- - - ">="
67
- - !ruby/object:Gem::Version
68
- version: '0'
69
55
  - !ruby/object:Gem::Dependency
70
56
  name: pry
71
57
  requirement: !ruby/object:Gem::Requirement
@@ -128,14 +114,14 @@ dependencies:
128
114
  requirements:
129
115
  - - '='
130
116
  - !ruby/object:Gem::Version
131
- version: 0.52.1
117
+ version: 0.56.0
132
118
  type: :development
133
119
  prerelease: false
134
120
  version_requirements: !ruby/object:Gem::Requirement
135
121
  requirements:
136
122
  - - '='
137
123
  - !ruby/object:Gem::Version
138
- version: 0.52.1
124
+ version: 0.56.0
139
125
  - !ruby/object:Gem::Dependency
140
126
  name: vim-flavor
141
127
  requirement: !ruby/object:Gem::Requirement
@@ -158,7 +144,6 @@ executables:
158
144
  extensions: []
159
145
  extra_rdoc_files: []
160
146
  files:
161
- - ".coveralls.yml"
162
147
  - ".gitignore"
163
148
  - ".rubocop.yml"
164
149
  - ".travis.yml"
@@ -170,7 +155,7 @@ files:
170
155
  - Rakefile
171
156
  - VimFlavor
172
157
  - appveyor.yml
173
- - bin/neovim-ruby-host
158
+ - exe/neovim-ruby-host
174
159
  - lib/neovim.rb
175
160
  - lib/neovim/api.rb
176
161
  - lib/neovim/buffer.rb
@@ -246,7 +231,7 @@ files:
246
231
  - spec/neovim/window_spec.rb
247
232
  - spec/neovim_spec.rb
248
233
  - spec/support.rb
249
- homepage: https://github.com/alexgenco/neovim-ruby
234
+ homepage: https://github.com/neovim/neovim-ruby
250
235
  licenses:
251
236
  - MIT
252
237
  metadata: {}
@@ -266,7 +251,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
266
251
  version: '0'
267
252
  requirements: []
268
253
  rubyforge_project:
269
- rubygems_version: 2.6.13
254
+ rubygems_version: 2.7.8
270
255
  signing_key:
271
256
  specification_version: 4
272
257
  summary: A Ruby client for Neovim
@@ -1 +0,0 @@
1
- service_name: travis-ci