neovim 0.4.0 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (70) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -1
  3. data/.gitmodules +1 -1
  4. data/.rspec +1 -0
  5. data/.travis.yml +1 -1
  6. data/CHANGELOG.md +8 -0
  7. data/README.md +5 -3
  8. data/Rakefile +14 -8
  9. data/lib/neovim/buffer.rb +86 -114
  10. data/lib/neovim/client.rb +105 -103
  11. data/lib/neovim/current.rb +8 -18
  12. data/lib/neovim/executable.rb +2 -2
  13. data/lib/neovim/line_range.rb +48 -59
  14. data/lib/neovim/plugin/dsl.rb +11 -3
  15. data/lib/neovim/remote_object.rb +3 -13
  16. data/lib/neovim/ruby_provider.rb +3 -3
  17. data/lib/neovim/ruby_provider/buffer_ext.rb +3 -3
  18. data/lib/neovim/ruby_provider/vim.rb +2 -2
  19. data/lib/neovim/ruby_provider/window_ext.rb +3 -3
  20. data/lib/neovim/session.rb +4 -4
  21. data/lib/neovim/session/api.rb +50 -22
  22. data/lib/neovim/tabpage.rb +29 -19
  23. data/lib/neovim/version.rb +1 -1
  24. data/lib/neovim/window.rb +60 -40
  25. data/script/dump_api +1 -1
  26. data/script/generate_docs +35 -22
  27. data/spec/helper.rb +3 -1
  28. data/spec/integration/rplugin_autocmd_spec.vim +18 -0
  29. data/spec/integration/rplugin_command_spec.vim +97 -0
  30. data/spec/integration/rplugin_function_spec.vim +26 -0
  31. data/spec/integration/ruby_buffer_spec.rb +151 -0
  32. data/spec/{acceptance → integration}/ruby_spec.vim +2 -22
  33. data/spec/integration/ruby_vim_spec.rb +27 -0
  34. data/spec/integration/ruby_window_spec.rb +56 -0
  35. data/spec/{acceptance → integration}/rubydo_spec.vim +27 -18
  36. data/spec/{acceptance → integration}/rubyfile/call_foo.rb +0 -0
  37. data/spec/{acceptance → integration}/rubyfile/curbuf_ivar_get.rb +0 -0
  38. data/spec/{acceptance → integration}/rubyfile/curbuf_ivar_set.rb +0 -0
  39. data/spec/{acceptance → integration}/rubyfile/define_foo.rb +0 -0
  40. data/spec/{acceptance → integration}/rubyfile/raise_standard_error.rb +0 -0
  41. data/spec/{acceptance → integration}/rubyfile/raise_syntax_error.rb +0 -0
  42. data/spec/{acceptance → integration}/rubyfile/set_pwd_after.rb +0 -0
  43. data/spec/{acceptance → integration}/rubyfile/set_pwd_before.rb +0 -0
  44. data/spec/{acceptance → integration}/rubyfile_spec.vim +12 -30
  45. data/spec/integration/runtime/init.vim +9 -0
  46. data/spec/integration/runtime/rplugin/ruby/autocmds.rb +9 -0
  47. data/spec/integration/runtime/rplugin/ruby/commands.rb +59 -0
  48. data/spec/integration/runtime/rplugin/ruby/functions.rb +17 -0
  49. data/spec/integration_spec.rb +119 -0
  50. data/spec/neovim/buffer_spec.rb +0 -167
  51. data/spec/neovim/client_spec.rb +1 -44
  52. data/spec/neovim/current_spec.rb +0 -8
  53. data/spec/neovim/line_range_spec.rb +92 -97
  54. data/spec/neovim/plugin_spec.rb +14 -2
  55. data/spec/neovim/remote_object_spec.rb +4 -4
  56. data/spec/neovim/ruby_provider/buffer_ext_spec.rb +3 -3
  57. data/spec/neovim/ruby_provider/window_ext_spec.rb +1 -1
  58. data/spec/neovim/session/api_spec.rb +40 -35
  59. data/spec/neovim/session/event_loop_spec.rb +1 -1
  60. data/spec/neovim/session_spec.rb +15 -15
  61. metadata +49 -41
  62. data/script/acceptance_tests +0 -46
  63. data/spec/acceptance/rplugin_spec.vim +0 -19
  64. data/spec/acceptance/rubyfile/curbuf.rb +0 -1
  65. data/spec/acceptance/rubyfile/curwin.rb +0 -1
  66. data/spec/acceptance/rubyfile/vim_constants.rb +0 -2
  67. data/spec/acceptance/runtime/init.vim +0 -1
  68. data/spec/acceptance/runtime/rplugin/ruby/plugin.rb +0 -13
  69. data/spec/documentation_spec.rb +0 -24
  70. data/spec/neovim/window_spec.rb +0 -91
@@ -0,0 +1,26 @@
1
+ Before (Generate rplugin manifest):
2
+ silent UpdateRemotePlugins
3
+
4
+ Execute (Call rplugin functions with arguments):
5
+ call RPluginFunctionArgs(1, 2)
6
+ sleep 50m
7
+ AssertEqual [1, 2], g:rplugin_function_args
8
+
9
+ Given:
10
+ one
11
+ two
12
+ three
13
+
14
+ Execute (Call rplugin functions with a range):
15
+ 1,2call RPluginFunctionRange()
16
+ sleep 50m
17
+ AssertEqual [1, 2], g:rplugin_function_range
18
+
19
+ Execute (Call rplugin functions with eval):
20
+ let g:to_eval = {'n': 42}
21
+ call RPluginFunctionEval()
22
+ sleep 50m
23
+ AssertEqual {'n': 42}, g:rplugin_function_eval
24
+
25
+ Execute (Call synchronous rplugin functions):
26
+ AssertEqual v:true, RPluginFunctionSync()
@@ -0,0 +1,151 @@
1
+ begin
2
+ require "helper"
3
+ rescue LoadError
4
+ end
5
+
6
+ RSpec.describe "Vim::Buffer", :embedded do
7
+ before do
8
+ $curbuf.set_lines(0, -1, true, ["one", "two", "three"])
9
+ $curwin.set_cursor([1, 0])
10
+ end
11
+
12
+ specify "$curbuf" do
13
+ expect($curbuf).to be_a(Vim::Buffer)
14
+ end
15
+
16
+ specify ".current" do
17
+ expect(Vim::Buffer.current).to eq($curbuf)
18
+ end
19
+
20
+ specify ".[]" do
21
+ expect(Vim::Buffer[0]).to eq($curbuf)
22
+ end
23
+
24
+ specify ".count" do
25
+ expect(Vim::Buffer.count).to be > 0
26
+ end
27
+
28
+ specify "#name" do
29
+ $curbuf.set_name("test_buf")
30
+ expect($curbuf.name).to include("test_buf")
31
+ end
32
+
33
+ specify "#number" do
34
+ expect($curbuf.number).to eq(1)
35
+ end
36
+
37
+ specify "#count" do
38
+ expect($curbuf.count).to eq(3)
39
+ end
40
+
41
+ specify "#length" do
42
+ expect($curbuf.length).to eq(3)
43
+ end
44
+
45
+ specify "#[]" do
46
+ expect($curbuf[1]).to eq("one")
47
+
48
+ expect do
49
+ $curbuf[-1]
50
+ end.to raise_error(/out of bounds/)
51
+
52
+ expect do
53
+ $curbuf[4]
54
+ end.to raise_error(/out of bounds/)
55
+ end
56
+
57
+ specify "#[]=" do
58
+ expect($curbuf[1] = "first").to eq("first")
59
+ expect($curbuf[1]).to eq("first")
60
+
61
+ expect do
62
+ $curbuf[4] = "line"
63
+ end.to raise_error(/out of bounds/)
64
+
65
+ expect do
66
+ $curbuf[-1] = "line"
67
+ end.to raise_error(/out of bounds/)
68
+ end
69
+
70
+ specify "#delete" do
71
+ expect($curbuf.delete(3)).to eq(nil)
72
+ expect($curbuf.count).to eq(2)
73
+
74
+ expect do
75
+ $curbuf.delete(-1)
76
+ end.to raise_error(/out of bounds/)
77
+
78
+ expect do
79
+ $curbuf.delete(4)
80
+ end.to raise_error(/out of bounds/)
81
+ end
82
+
83
+ specify "#append" do
84
+ expect($curbuf.append(2, "last")).to eq("last")
85
+ expect($curbuf[3]).to eq("last")
86
+
87
+ $curbuf.set_lines(0, -1, true, [])
88
+ $curbuf.append(0, "one")
89
+
90
+ expect($curbuf.lines.to_a).to eq(["one", ""])
91
+
92
+ expect do
93
+ $curbuf.append(0, "two")
94
+ end.not_to change { $curwin.cursor }
95
+
96
+ expect do
97
+ $curbuf.append(-1, "line")
98
+ end.to raise_error(/out of bounds/)
99
+
100
+ expect do
101
+ $curbuf.append(4, "line")
102
+ end.to raise_error(/out of bounds/)
103
+ end
104
+
105
+ specify "#line_number" do
106
+ expect do
107
+ Vim.command("normal j")
108
+ end.to change { $curbuf.line_number }.from(1).to(2)
109
+
110
+ original = $curbuf
111
+
112
+ begin
113
+ Vim.command("new")
114
+ expect(original.line_number).to eq(nil)
115
+ ensure
116
+ Vim.set_current_buf(original)
117
+ end
118
+ end
119
+
120
+ specify "#line" do
121
+ expect do
122
+ Vim.command("normal j")
123
+ end.to change { $curbuf.line }.from("one").to("two")
124
+
125
+ original = $curbuf
126
+
127
+ begin
128
+ Vim.command("new")
129
+ expect(original.line).to eq(nil)
130
+ ensure
131
+ Vim.set_current_buf(original)
132
+ end
133
+ end
134
+
135
+ specify "#line=" do
136
+ $curbuf.line = "first"
137
+ expect($curbuf[1]).to eq("first")
138
+
139
+ original = $curbuf
140
+
141
+ begin
142
+ Vim.command("new")
143
+
144
+ expect do
145
+ original.line = "line"
146
+ end.not_to change { original.lines.to_a }
147
+ ensure
148
+ Vim.set_current_buf(original)
149
+ end
150
+ end
151
+ end
@@ -9,28 +9,6 @@ Given:
9
9
  one
10
10
  two
11
11
 
12
- Execute (Access `Vim` and `VIM` constants):
13
- ruby Vim.command('1normal! Sfirst')
14
- ruby VIM.command('2normal! Ssecond')
15
-
16
- Expect:
17
- first
18
- second
19
-
20
- Execute (Access `$curbuf` global variable):
21
- ruby $curbuf[1] = "first"
22
-
23
- Expect:
24
- first
25
- two
26
-
27
- Execute (Access `$curwin` global variable):
28
- ruby $curwin.buffer[1] = "first"
29
-
30
- Expect:
31
- first
32
- two
33
-
34
12
  Execute (Define a Ruby method):
35
13
  ruby def foo; Vim.command("let g:called = 1"); end
36
14
 
@@ -72,6 +50,7 @@ Then:
72
50
  Execute (Raise a Ruby standard error):
73
51
  try
74
52
  ruby raise "BOOM"
53
+ throw "Nothing raised"
75
54
  catch /BOOM/
76
55
  endtry
77
56
 
@@ -84,6 +63,7 @@ Expect:
84
63
  Execute (Raise a Ruby syntax error):
85
64
  try
86
65
  ruby puts[
66
+ throw "Nothing raised"
87
67
  catch /SyntaxError/
88
68
  endtry
89
69
 
@@ -0,0 +1,27 @@
1
+ begin
2
+ require "helper"
3
+ rescue LoadError
4
+ end
5
+
6
+ RSpec.describe "Vim", :embedded do
7
+ before do
8
+ $curbuf.set_lines(0, -1, true, ["one", "two", "three"])
9
+ end
10
+
11
+ specify { expect(Vim).to be(VIM) }
12
+
13
+ specify "class methods" do
14
+ Vim.message(".")
15
+
16
+ expect {
17
+ Vim.set_option("makeprg", "rake")
18
+ }.to change { Vim.evaluate("&makeprg") }.to("rake")
19
+
20
+ expect {
21
+ Vim.set_option("timeoutlen=0")
22
+ }.to change { Vim.evaluate("&timeoutlen") }.to(0)
23
+
24
+ Vim.command("let g:foo = 'bar'")
25
+ expect(Vim.evaluate("g:foo")).to eq("bar")
26
+ end
27
+ end
@@ -0,0 +1,56 @@
1
+ begin
2
+ require "helper"
3
+ rescue LoadError
4
+ end
5
+
6
+ RSpec.describe "Vim::Window", :embedded do
7
+ before do
8
+ $curbuf.set_lines(0, -1, true, ["one", "two", "three"])
9
+ Vim.command("vsplit")
10
+ end
11
+
12
+ specify "$curwin" do
13
+ expect($curwin).to be_a(Vim::Window)
14
+ end
15
+
16
+ specify ".current" do
17
+ expect(Vim::Window.current).to eq($curwin)
18
+ end
19
+
20
+ specify ".[]" do
21
+ expect(Vim::Window[0]).to eq($curwin)
22
+ end
23
+
24
+ specify ".count" do
25
+ expect do
26
+ Vim.command("split")
27
+ end.to change { Vim::Window.count }.by(1)
28
+
29
+ expect do
30
+ Vim.command("tabnew")
31
+ end.to change { Vim::Window.count }.to(1)
32
+ .and change { Vim::Window[1] }.to(nil)
33
+ end
34
+
35
+ specify "#buffer" do
36
+ expect($curwin.buffer).to eq($curbuf)
37
+ end
38
+
39
+ specify "#height", "#height=" do
40
+ expect do
41
+ $curwin.height -= 1
42
+ end.to change { $curwin.height }.by(-1)
43
+ end
44
+
45
+ specify "#width", "#width=" do
46
+ expect do
47
+ $curwin.width -= 1
48
+ end.to change { $curwin.width }.by(-1)
49
+ end
50
+
51
+ specify "#cursor", "#cursor=" do
52
+ expect($curwin.cursor = [2, 0]).to eq([2, 0])
53
+ expect($curwin.cursor).to eq([2, 0])
54
+ expect($curwin.buffer.line).to eq("two")
55
+ end
56
+ end
@@ -1,33 +1,40 @@
1
1
  Given:
2
- a
3
- b
4
- c
5
- d
2
+ one
3
+ two
4
+ three
5
+ four
6
6
 
7
7
  Execute (Update one line using `$_`):
8
8
  2rubydo $_.upcase!
9
9
 
10
10
  Expect:
11
- a
12
- B
13
- c
14
- d
11
+ one
12
+ TWO
13
+ three
14
+ four
15
15
 
16
16
  Execute (Update a range of lines using `$_`):
17
17
  2,3rubydo $_.upcase!
18
18
 
19
19
  Expect:
20
- a
21
- B
22
- C
23
- d
20
+ one
21
+ TWO
22
+ THREE
23
+ four
24
24
 
25
25
  Execute (Update all lines using `$_`):
26
26
  %rubydo $_.upcase!
27
27
 
28
+ Expect:
29
+ ONE
30
+ TWO
31
+ THREE
32
+ FOUR
33
+
28
34
  Execute (Raise a Ruby standard error):
29
35
  try
30
36
  1rubydo raise "BOOM"
37
+ throw "Nothing raised"
31
38
  catch /BOOM/
32
39
  endtry
33
40
 
@@ -35,13 +42,14 @@ Execute (Raise a Ruby standard error):
35
42
 
36
43
  Expect:
37
44
  still works
38
- b
39
- c
40
- d
45
+ two
46
+ three
47
+ four
41
48
 
42
49
  Execute (Raise a Ruby syntax error):
43
50
  try
44
51
  1rubydo puts[
52
+ throw "Nothing raised"
45
53
  catch /SyntaxError/
46
54
  endtry
47
55
 
@@ -49,9 +57,9 @@ Execute (Raise a Ruby syntax error):
49
57
 
50
58
  Expect:
51
59
  still works
52
- b
53
- c
54
- d
60
+ two
61
+ three
62
+ four
55
63
 
56
64
  Given:
57
65
  x
@@ -61,6 +69,7 @@ Execute (Add a large number of lines):
61
69
  silent normal 6000p
62
70
  %rubydo $_.succ!
63
71
 
72
+ Then:
64
73
  AssertEqual "y", getline(1)
65
74
  AssertEqual "y", getline(6001)
66
75
  AssertEqual "", getline(6002)
@@ -9,47 +9,26 @@ Given:
9
9
  one
10
10
  two
11
11
 
12
- Execute (Access `Vim` and `VIM` constants):
13
- rubyfile ./spec/acceptance/rubyfile/vim_constants.rb
14
-
15
- Expect:
16
- first
17
- second
18
-
19
- Execute (Access `$curbuf` global variable):
20
- rubyfile ./spec/acceptance/rubyfile/curbuf.rb
21
-
22
- Expect:
23
- first
24
- two
25
-
26
- Execute (Access `$curwin` global variable):
27
- rubyfile ./spec/acceptance/rubyfile/curwin.rb
28
-
29
- Expect:
30
- first
31
- two
32
-
33
12
  Execute (Define a Ruby method):
34
- rubyfile ./spec/acceptance/rubyfile/define_foo.rb
13
+ rubyfile ./rubyfile/define_foo.rb
35
14
 
36
15
  Execute (Call a Ruby method):
37
- rubyfile ./spec/acceptance/rubyfile/call_foo.rb
16
+ rubyfile ./rubyfile/call_foo.rb
38
17
 
39
18
  Then:
40
19
  AssertEqual 1, g:called
41
20
 
42
21
  Execute (Update instance state on $curbuf):
43
- rubyfile ./spec/acceptance/rubyfile/curbuf_ivar_set.rb
22
+ rubyfile ./rubyfile/curbuf_ivar_set.rb
44
23
 
45
24
  Execute (Access instance state on $curbuf):
46
- rubyfile ./spec/acceptance/rubyfile/curbuf_ivar_get.rb
25
+ rubyfile ./rubyfile/curbuf_ivar_get.rb
47
26
 
48
27
  Then:
49
28
  AssertEqual 123, g:foo
50
29
 
51
30
  Execute (Change the working directory explicitly):
52
- let g:rubyfile = getcwd() . "/spec/acceptance/rubyfile/set_pwd_before.rb"
31
+ let g:rubyfile = getcwd() . "/rubyfile/set_pwd_before.rb"
53
32
  cd /
54
33
  exec "rubyfile " . g:rubyfile
55
34
  cd -
@@ -60,8 +39,8 @@ Then:
60
39
  endif
61
40
 
62
41
  Execute (Change the working directory implicitly):
63
- let g:before_file = getcwd() . "/spec/acceptance/rubyfile/set_pwd_before.rb"
64
- let g:after_file = getcwd() . "/spec/acceptance/rubyfile/set_pwd_after.rb"
42
+ let g:before_file = getcwd() . "/rubyfile/set_pwd_before.rb"
43
+ let g:after_file = getcwd() . "/rubyfile/set_pwd_after.rb"
65
44
 
66
45
  split | lcd /
67
46
  exec "rubyfile " . g:before_file
@@ -77,6 +56,7 @@ Then:
77
56
  Execute (Raise a Ruby load error):
78
57
  try
79
58
  rubyfile /foo/bar/baz
59
+ throw "Nothing raised"
80
60
  catch /LoadError/
81
61
  endtry
82
62
 
@@ -88,7 +68,8 @@ Expect:
88
68
 
89
69
  Execute (Raise a Ruby standard error):
90
70
  try
91
- rubyfile ./spec/acceptance/rubyfile/raise_standard_error.rb
71
+ rubyfile ./rubyfile/raise_standard_error.rb
72
+ throw "Nothing raised"
92
73
  catch /BOOM/
93
74
  endtry
94
75
 
@@ -100,7 +81,8 @@ Expect:
100
81
 
101
82
  Execute (Raise a Ruby syntax error):
102
83
  try
103
- rubyfile ./spec/acceptance/rubyfile/raise_syntax_error.rb
84
+ rubyfile ./rubyfile/raise_syntax_error.rb
85
+ throw "Nothing raised"
104
86
  catch /SyntaxError/
105
87
  endtry
106
88