neovim 0.4.0 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -1
- data/.gitmodules +1 -1
- data/.rspec +1 -0
- data/.travis.yml +1 -1
- data/CHANGELOG.md +8 -0
- data/README.md +5 -3
- data/Rakefile +14 -8
- data/lib/neovim/buffer.rb +86 -114
- data/lib/neovim/client.rb +105 -103
- data/lib/neovim/current.rb +8 -18
- data/lib/neovim/executable.rb +2 -2
- data/lib/neovim/line_range.rb +48 -59
- data/lib/neovim/plugin/dsl.rb +11 -3
- data/lib/neovim/remote_object.rb +3 -13
- data/lib/neovim/ruby_provider.rb +3 -3
- data/lib/neovim/ruby_provider/buffer_ext.rb +3 -3
- data/lib/neovim/ruby_provider/vim.rb +2 -2
- data/lib/neovim/ruby_provider/window_ext.rb +3 -3
- data/lib/neovim/session.rb +4 -4
- data/lib/neovim/session/api.rb +50 -22
- data/lib/neovim/tabpage.rb +29 -19
- data/lib/neovim/version.rb +1 -1
- data/lib/neovim/window.rb +60 -40
- data/script/dump_api +1 -1
- data/script/generate_docs +35 -22
- data/spec/helper.rb +3 -1
- data/spec/integration/rplugin_autocmd_spec.vim +18 -0
- data/spec/integration/rplugin_command_spec.vim +97 -0
- data/spec/integration/rplugin_function_spec.vim +26 -0
- data/spec/integration/ruby_buffer_spec.rb +151 -0
- data/spec/{acceptance → integration}/ruby_spec.vim +2 -22
- data/spec/integration/ruby_vim_spec.rb +27 -0
- data/spec/integration/ruby_window_spec.rb +56 -0
- data/spec/{acceptance → integration}/rubydo_spec.vim +27 -18
- data/spec/{acceptance → integration}/rubyfile/call_foo.rb +0 -0
- data/spec/{acceptance → integration}/rubyfile/curbuf_ivar_get.rb +0 -0
- data/spec/{acceptance → integration}/rubyfile/curbuf_ivar_set.rb +0 -0
- data/spec/{acceptance → integration}/rubyfile/define_foo.rb +0 -0
- data/spec/{acceptance → integration}/rubyfile/raise_standard_error.rb +0 -0
- data/spec/{acceptance → integration}/rubyfile/raise_syntax_error.rb +0 -0
- data/spec/{acceptance → integration}/rubyfile/set_pwd_after.rb +0 -0
- data/spec/{acceptance → integration}/rubyfile/set_pwd_before.rb +0 -0
- data/spec/{acceptance → integration}/rubyfile_spec.vim +12 -30
- data/spec/integration/runtime/init.vim +9 -0
- data/spec/integration/runtime/rplugin/ruby/autocmds.rb +9 -0
- data/spec/integration/runtime/rplugin/ruby/commands.rb +59 -0
- data/spec/integration/runtime/rplugin/ruby/functions.rb +17 -0
- data/spec/integration_spec.rb +119 -0
- data/spec/neovim/buffer_spec.rb +0 -167
- data/spec/neovim/client_spec.rb +1 -44
- data/spec/neovim/current_spec.rb +0 -8
- data/spec/neovim/line_range_spec.rb +92 -97
- data/spec/neovim/plugin_spec.rb +14 -2
- data/spec/neovim/remote_object_spec.rb +4 -4
- data/spec/neovim/ruby_provider/buffer_ext_spec.rb +3 -3
- data/spec/neovim/ruby_provider/window_ext_spec.rb +1 -1
- data/spec/neovim/session/api_spec.rb +40 -35
- data/spec/neovim/session/event_loop_spec.rb +1 -1
- data/spec/neovim/session_spec.rb +15 -15
- metadata +49 -41
- data/script/acceptance_tests +0 -46
- data/spec/acceptance/rplugin_spec.vim +0 -19
- data/spec/acceptance/rubyfile/curbuf.rb +0 -1
- data/spec/acceptance/rubyfile/curwin.rb +0 -1
- data/spec/acceptance/rubyfile/vim_constants.rb +0 -2
- data/spec/acceptance/runtime/init.vim +0 -1
- data/spec/acceptance/runtime/rplugin/ruby/plugin.rb +0 -13
- data/spec/documentation_spec.rb +0 -24
- data/spec/neovim/window_spec.rb +0 -91
data/spec/neovim/current_spec.rb
CHANGED
@@ -135,13 +135,5 @@ module Neovim
|
|
135
135
|
expect(current.tabpage = tp0).to eq(tp0)
|
136
136
|
end
|
137
137
|
end
|
138
|
-
|
139
|
-
describe "#range=" do
|
140
|
-
it "sets the line range of the current buffer" do
|
141
|
-
current.buffer.lines = ["one", "two", "three", "four"]
|
142
|
-
current.range = (1..2)
|
143
|
-
expect(current.buffer.range.to_a).to eq(["two", "three"])
|
144
|
-
end
|
145
|
-
end
|
146
138
|
end
|
147
139
|
end
|
@@ -4,21 +4,31 @@ module Neovim
|
|
4
4
|
RSpec.describe LineRange do
|
5
5
|
let(:client) { Neovim.attach_child(Support.child_argv) }
|
6
6
|
let(:buffer) { client.current.buffer }
|
7
|
-
let(:line_range) { LineRange.new(buffer
|
8
|
-
let(:sub_range) { LineRange.new(buffer, 1, 2) }
|
7
|
+
let(:line_range) { LineRange.new(buffer) }
|
9
8
|
|
10
9
|
before do
|
11
|
-
|
12
|
-
client.command("normal o2")
|
13
|
-
client.command("normal o3")
|
14
|
-
client.command("normal o4")
|
10
|
+
buffer.set_lines(0, -1, true, ["1", "2", "3", "4"])
|
15
11
|
end
|
16
12
|
|
17
13
|
after { client.shutdown }
|
18
14
|
|
19
|
-
|
20
|
-
|
21
|
-
|
15
|
+
describe "#each" do
|
16
|
+
it "yields each line" do
|
17
|
+
yielded = []
|
18
|
+
line_range.each { |line| yielded << line }
|
19
|
+
|
20
|
+
expect(yielded).to eq(["1", "2", "3", "4"])
|
21
|
+
end
|
22
|
+
|
23
|
+
it "yields a large number of lines" do
|
24
|
+
lines = Array.new(6000, "x")
|
25
|
+
buffer.set_lines(0, -1, true, lines)
|
26
|
+
|
27
|
+
yielded = []
|
28
|
+
line_range.each { |line| yielded << line }
|
29
|
+
|
30
|
+
expect(yielded).to eq(lines)
|
31
|
+
end
|
22
32
|
end
|
23
33
|
|
24
34
|
describe "#to_a" do
|
@@ -26,82 +36,99 @@ module Neovim
|
|
26
36
|
expect(line_range.to_a).to eq(["1", "2", "3", "4"])
|
27
37
|
end
|
28
38
|
|
29
|
-
it "returns a
|
30
|
-
|
39
|
+
it "returns a large number of lines as an array" do
|
40
|
+
lines = Array.new(6000, "x")
|
41
|
+
buffer.set_lines(0, -1, true, lines)
|
42
|
+
expect(line_range.to_a).to eq(lines)
|
31
43
|
end
|
32
44
|
end
|
33
45
|
|
34
|
-
describe "
|
35
|
-
it "
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
it "returns lines at an offset from the index" do
|
40
|
-
expect(sub_range[0]).to eq("2")
|
41
|
-
end
|
46
|
+
describe "#==" do
|
47
|
+
it "compares line contents" do
|
48
|
+
client.command("new")
|
49
|
+
buffer2 = client.current.buffer
|
42
50
|
|
43
|
-
|
44
|
-
|
51
|
+
expect(buffer2.lines == buffer.lines).to eq(false)
|
52
|
+
buffer2.set_lines(0, -1, true, ["1", "2", "3", "4"])
|
53
|
+
expect(buffer2.lines == buffer.lines).to eq(true)
|
45
54
|
end
|
55
|
+
end
|
46
56
|
|
47
|
-
|
48
|
-
|
57
|
+
describe "#[]" do
|
58
|
+
it "accepts a single index" do
|
59
|
+
expect(line_range[1]).to eq("2")
|
60
|
+
expect(line_range[-1]).to eq("4")
|
61
|
+
expect(line_range[-2]).to eq("3")
|
49
62
|
end
|
50
63
|
|
51
64
|
it "accepts an index and length" do
|
52
|
-
expect(line_range[0, 2]
|
53
|
-
|
65
|
+
expect(line_range[0, 2]).to eq(["1", "2"])
|
66
|
+
expect(line_range[-2, 2]).to eq(["3", "4"])
|
67
|
+
expect(line_range[-2, 3]).to eq(["3", "4"])
|
54
68
|
|
55
|
-
|
56
|
-
|
69
|
+
expect {
|
70
|
+
line_range[2, 3]
|
71
|
+
}.to raise_error(/out of bounds/)
|
57
72
|
end
|
58
73
|
|
59
74
|
it "accepts a range" do
|
60
|
-
expect(line_range[0..1]
|
61
|
-
expect(line_range[0...1]
|
62
|
-
end
|
75
|
+
expect(line_range[0..1]).to eq(["1", "2"])
|
76
|
+
expect(line_range[0...1]).to eq(["1"])
|
63
77
|
|
64
|
-
|
65
|
-
expect(line_range[0..-
|
66
|
-
|
78
|
+
expect(line_range[0..-1]).to eq(["1", "2", "3", "4"])
|
79
|
+
expect(line_range[0..-2]).to eq(["1", "2", "3"])
|
80
|
+
expect(line_range[-3..-2]).to eq(["2", "3"])
|
81
|
+
|
82
|
+
expect(line_range[0..-5]).to eq([])
|
83
|
+
expect(line_range[0...-4]).to eq([])
|
84
|
+
expect(line_range[-2..-3]).to eq([])
|
67
85
|
|
68
|
-
|
69
|
-
|
86
|
+
expect {
|
87
|
+
line_range[2..4]
|
88
|
+
}.to raise_error(/out of bounds/)
|
70
89
|
end
|
71
90
|
end
|
72
91
|
|
73
92
|
describe "#[]=" do
|
74
93
|
it "accepts a single index" do
|
75
|
-
line_range[0] = "foo"
|
94
|
+
expect(line_range[0] = "foo").to eq("foo")
|
76
95
|
expect(line_range.to_a).to eq(["foo", "2", "3", "4"])
|
77
|
-
end
|
78
96
|
|
79
|
-
|
80
|
-
|
81
|
-
|
97
|
+
expect(line_range[-1] = "bar").to eq("bar")
|
98
|
+
expect(line_range.to_a).to eq(["foo", "2", "3", "bar"])
|
99
|
+
|
100
|
+
expect {
|
101
|
+
line_range[-5] = "foo"
|
102
|
+
}.to raise_error(/out of bounds/)
|
82
103
|
end
|
83
104
|
|
84
105
|
it "accepts an index and length" do
|
85
|
-
line_range[0, 2] = ["foo"]
|
106
|
+
expect(line_range[0, 2] = ["foo"]).to eq(["foo"])
|
86
107
|
expect(line_range.to_a).to eq(["foo", "3", "4"])
|
87
|
-
end
|
88
108
|
|
89
|
-
|
90
|
-
|
91
|
-
|
109
|
+
expect(line_range[-2, 2] = ["bar"]).to eq(["bar"])
|
110
|
+
expect(line_range.to_a).to eq(["foo", "bar"])
|
111
|
+
|
112
|
+
expect(line_range[0, 2] = "baz").to eq("baz")
|
113
|
+
expect(line_range.to_a).to eq(["baz"])
|
114
|
+
|
115
|
+
expect {
|
116
|
+
line_range[0, 5] = "foo"
|
117
|
+
}.to raise_error(/out of bounds/)
|
92
118
|
end
|
93
119
|
|
94
120
|
it "accepts a range" do
|
95
|
-
line_range[0..1] = ["foo"]
|
121
|
+
expect(line_range[0..1] = ["foo"]).to eq(["foo"])
|
96
122
|
expect(line_range.to_a).to eq(["foo", "3", "4"])
|
97
123
|
|
98
|
-
line_range[0...1] = ["bar"]
|
124
|
+
expect(line_range[0...1] = ["bar"]).to eq(["bar"])
|
99
125
|
expect(line_range.to_a).to eq(["bar", "3", "4"])
|
100
|
-
end
|
101
126
|
|
102
|
-
|
103
|
-
|
104
|
-
|
127
|
+
expect(line_range[0..-2] = ["baz"]).to eq(["baz"])
|
128
|
+
expect(line_range.to_a).to eq(["baz", "4"])
|
129
|
+
|
130
|
+
expect(line_range[0...2] = "qux").to eq("qux")
|
131
|
+
expect(line_range.to_a).to eq(["qux"])
|
105
132
|
end
|
106
133
|
end
|
107
134
|
|
@@ -110,64 +137,32 @@ module Neovim
|
|
110
137
|
line_range.replace(["4", "5"])
|
111
138
|
expect(line_range.to_a).to eq(["4", "5"])
|
112
139
|
end
|
113
|
-
|
114
|
-
it "replaces a subset of lines" do
|
115
|
-
sub_range.replace(["5", "6"])
|
116
|
-
expect(buffer.lines.to_a).to eq(["1", "5", "6", "4"])
|
117
|
-
end
|
118
140
|
end
|
119
141
|
|
120
|
-
describe "#
|
121
|
-
|
122
|
-
|
123
|
-
it "inserts lines at the beginning" do
|
124
|
-
expect {
|
125
|
-
line_range.insert(0, "z")
|
126
|
-
}.to change { line_range.to_a }.to(["z", "1", "2"])
|
127
|
-
|
128
|
-
expect {
|
129
|
-
line_range.insert(0, ["x", "y"])
|
130
|
-
}.to change { line_range.to_a }.to(["x", "y", "z", "1", "2"])
|
131
|
-
end
|
132
|
-
|
133
|
-
it "inserts lines in the middle" do
|
134
|
-
expect {
|
135
|
-
line_range.insert(1, "z")
|
136
|
-
}.to change { line_range.to_a }.to(["1", "z", "2"])
|
137
|
-
|
138
|
-
expect {
|
139
|
-
line_range.insert(1, ["x", "y"])
|
140
|
-
}.to change { line_range.to_a }.to(["1", "x", "y", "z", "2"])
|
141
|
-
end
|
142
|
-
|
143
|
-
it "inserts lines at the end" do
|
142
|
+
describe "#delete" do
|
143
|
+
it "deletes the line at the given index" do
|
144
144
|
expect {
|
145
|
-
line_range.
|
146
|
-
}.to change { line_range.to_a }.to(["
|
145
|
+
line_range.delete(0)
|
146
|
+
}.to change { line_range.to_a }.to(["2", "3", "4"])
|
147
147
|
|
148
148
|
expect {
|
149
|
-
line_range.
|
150
|
-
}.to change { line_range.to_a }.to(["
|
151
|
-
end
|
149
|
+
line_range.delete(-1)
|
150
|
+
}.to change { line_range.to_a }.to(["2", "3"])
|
152
151
|
|
153
|
-
it "raises on out of bounds indexes" do
|
154
152
|
expect {
|
155
|
-
line_range.
|
156
|
-
}.to
|
153
|
+
line_range.delete(-2)
|
154
|
+
}.to change { line_range.to_a }.to(["3"])
|
157
155
|
end
|
158
|
-
end
|
159
156
|
|
160
|
-
|
161
|
-
|
162
|
-
expect
|
163
|
-
line_range.delete(0)
|
164
|
-
}.to change { line_range.to_a }.to(["2", "3", "4"])
|
157
|
+
it "returns the line deleted" do
|
158
|
+
expect(line_range.delete(0)).to eq("1")
|
159
|
+
expect(line_range.delete(-1)).to eq("4")
|
165
160
|
end
|
166
161
|
|
167
|
-
it "
|
162
|
+
it "returns nil if provided a non-integer" do
|
168
163
|
expect {
|
169
|
-
|
170
|
-
}.
|
164
|
+
expect(line_range.delete(:foo)).to eq(nil)
|
165
|
+
}.not_to change { line_range.to_a }
|
171
166
|
end
|
172
167
|
end
|
173
168
|
end
|
data/spec/neovim/plugin_spec.rb
CHANGED
@@ -8,7 +8,14 @@ module Neovim
|
|
8
8
|
cmd_block = Proc.new {}
|
9
9
|
|
10
10
|
plugin = Plugin.from_config_block("source") do |plug|
|
11
|
-
plug.command(
|
11
|
+
plug.command(
|
12
|
+
"Foo",
|
13
|
+
:nargs => 1,
|
14
|
+
:range => true,
|
15
|
+
:bang => true,
|
16
|
+
:register => true,
|
17
|
+
&cmd_block
|
18
|
+
)
|
12
19
|
end
|
13
20
|
|
14
21
|
expect(plugin.handlers.size).to be(1)
|
@@ -22,7 +29,12 @@ module Neovim
|
|
22
29
|
:type => :command,
|
23
30
|
:name => "Foo",
|
24
31
|
:sync => false,
|
25
|
-
:opts => {
|
32
|
+
:opts => {
|
33
|
+
:nargs => 1,
|
34
|
+
:range => "",
|
35
|
+
:bang => "",
|
36
|
+
:register => "",
|
37
|
+
},
|
26
38
|
)
|
27
39
|
end
|
28
40
|
|
@@ -23,7 +23,7 @@ module Neovim
|
|
23
23
|
end
|
24
24
|
|
25
25
|
describe "#method_missing" do
|
26
|
-
it "enables
|
26
|
+
it "enables nvim_win_* function calls" do
|
27
27
|
expect(window.get_cursor).to eq([1, 0])
|
28
28
|
end
|
29
29
|
|
@@ -61,7 +61,7 @@ module Neovim
|
|
61
61
|
end
|
62
62
|
|
63
63
|
describe "#method_missing" do
|
64
|
-
it "enables
|
64
|
+
it "enables nvim_tabpage_* function calls" do
|
65
65
|
expect(tabpage.is_valid).to be(true)
|
66
66
|
end
|
67
67
|
end
|
@@ -72,7 +72,7 @@ module Neovim
|
|
72
72
|
end
|
73
73
|
|
74
74
|
it "returns api methods" do
|
75
|
-
expect(tabpage.methods).to include(:
|
75
|
+
expect(tabpage.methods).to include(:list_wins)
|
76
76
|
end
|
77
77
|
end
|
78
78
|
end
|
@@ -95,7 +95,7 @@ module Neovim
|
|
95
95
|
end
|
96
96
|
|
97
97
|
describe "#method_missing" do
|
98
|
-
it "enables
|
98
|
+
it "enables nvim_buf_* function calls" do
|
99
99
|
expect(buffer.line_count).to be(1)
|
100
100
|
end
|
101
101
|
end
|
@@ -13,7 +13,7 @@ module Neovim
|
|
13
13
|
|
14
14
|
describe ".current" do
|
15
15
|
it "returns the current buffer from the global Vim client" do
|
16
|
-
expect(Buffer.current).to eq(nvim.
|
16
|
+
expect(Buffer.current).to eq(nvim.get_current_buf)
|
17
17
|
end
|
18
18
|
end
|
19
19
|
|
@@ -27,9 +27,9 @@ module Neovim
|
|
27
27
|
|
28
28
|
describe ".[]" do
|
29
29
|
it "returns the buffer from the global Vim client at the given index" do
|
30
|
-
expect(Buffer[0]).to eq(nvim.
|
30
|
+
expect(Buffer[0]).to eq(nvim.get_current_buf)
|
31
31
|
nvim.command("new")
|
32
|
-
expect(Buffer[1]).to eq(nvim.
|
32
|
+
expect(Buffer[1]).to eq(nvim.get_current_buf)
|
33
33
|
end
|
34
34
|
end
|
35
35
|
end
|
@@ -12,52 +12,57 @@ module Neovim
|
|
12
12
|
end
|
13
13
|
end
|
14
14
|
|
15
|
-
|
16
|
-
it "returns a sync function object" do
|
17
|
-
api = API.new(
|
18
|
-
[nil, {"functions" => [
|
19
|
-
{"name" => "vim_sync", "async" => false}
|
20
|
-
]}]
|
21
|
-
)
|
15
|
+
let(:client) { Neovim.attach_child(Support.child_argv) }
|
22
16
|
|
23
|
-
|
24
|
-
|
25
|
-
|
17
|
+
let(:api) do
|
18
|
+
API.new(
|
19
|
+
[
|
20
|
+
nil,
|
21
|
+
{
|
22
|
+
"functions" => [
|
23
|
+
{"name" => "nvim_func"},
|
24
|
+
{"name" => "nvim_buf_func"},
|
25
|
+
{"name" => "nvim_win_func"},
|
26
|
+
{"name" => "nvim_tabpage_func"},
|
27
|
+
]
|
28
|
+
}
|
29
|
+
]
|
30
|
+
)
|
31
|
+
end
|
26
32
|
|
27
|
-
|
28
|
-
|
29
|
-
function.
|
30
|
-
|
33
|
+
describe "#functions_for_object_method" do
|
34
|
+
it "returns relevant functions" do
|
35
|
+
function = api.function_for_object_method(client, :func)
|
36
|
+
expect(function.name).to eq("nvim_func")
|
31
37
|
|
32
|
-
|
33
|
-
|
34
|
-
[nil, {"functions" => [
|
35
|
-
{"name" => "vim_async", "async" => true}
|
36
|
-
]}]
|
37
|
-
)
|
38
|
+
function = api.function_for_object_method(client.get_current_buf, :func)
|
39
|
+
expect(function.name).to eq("nvim_buf_func")
|
38
40
|
|
39
|
-
function = api.
|
40
|
-
expect(function.name).to eq("
|
41
|
-
expect(function.async).to be(true)
|
41
|
+
function = api.function_for_object_method(client.get_current_win, :func)
|
42
|
+
expect(function.name).to eq("nvim_win_func")
|
42
43
|
|
43
|
-
|
44
|
-
expect(
|
45
|
-
function.call(session, "msg")
|
44
|
+
function = api.function_for_object_method(client.get_current_tabpage, :func)
|
45
|
+
expect(function.name).to eq("nvim_tabpage_func")
|
46
46
|
end
|
47
47
|
end
|
48
48
|
|
49
|
-
describe "#
|
49
|
+
describe "#functions_for_object" do
|
50
50
|
it "returns relevant functions" do
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
)
|
51
|
+
functions = api.functions_for_object(client)
|
52
|
+
expect(functions.size).to be(1)
|
53
|
+
expect(functions.first.name).to eq("nvim_func")
|
54
|
+
|
55
|
+
functions = api.functions_for_object(client.get_current_buf)
|
56
|
+
expect(functions.size).to be(1)
|
57
|
+
expect(functions.first.name).to eq("nvim_buf_func")
|
58
|
+
|
59
|
+
functions = api.functions_for_object(client.get_current_win)
|
60
|
+
expect(functions.size).to be(1)
|
61
|
+
expect(functions.first.name).to eq("nvim_win_func")
|
57
62
|
|
58
|
-
functions = api.
|
63
|
+
functions = api.functions_for_object(client.get_current_tabpage)
|
59
64
|
expect(functions.size).to be(1)
|
60
|
-
expect(functions.first.name).to eq("
|
65
|
+
expect(functions.first.name).to eq("nvim_tabpage_func")
|
61
66
|
end
|
62
67
|
end
|
63
68
|
end
|