neovim 0.4.0 → 0.5.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 +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
@@ -0,0 +1,9 @@
|
|
1
|
+
set rtp=./runtime,./runtime/vader.vim,$VIMRUNTIME
|
2
|
+
|
3
|
+
ruby require "rspec"
|
4
|
+
|
5
|
+
function! RunSuite() abort
|
6
|
+
ruby $output = ENV["RSPEC_OUTPUT_FILE"]
|
7
|
+
ruby $result = RSpec::Core::Runner.run([], $output, $output)
|
8
|
+
ruby Vim.command($result == 0 ? "qa!" : "cq!")
|
9
|
+
endfunction
|
@@ -0,0 +1,9 @@
|
|
1
|
+
Neovim.plugin do |plug|
|
2
|
+
plug.autocmd(:BufEnter, :pattern => "*.rb") do |nvim|
|
3
|
+
nvim.get_current_buf.set_var("rplugin_autocmd_BufEnter", true)
|
4
|
+
end
|
5
|
+
|
6
|
+
plug.autocmd(:BufEnter, :pattern => "*.c", :eval => "g:to_eval") do |nvim, to_eval|
|
7
|
+
nvim.set_var("rplugin_autocmd_BufEnter_eval", to_eval)
|
8
|
+
end
|
9
|
+
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
Neovim.plugin do |plug|
|
2
|
+
plug.command(:RPluginCommandNargs0) do |nvim|
|
3
|
+
nvim.set_var("rplugin_command_nargs_0", true)
|
4
|
+
end
|
5
|
+
|
6
|
+
plug.command(:RPluginCommandNargs1, :nargs => 1) do |nvim, arg|
|
7
|
+
nvim.set_var("rplugin_command_nargs_1", arg)
|
8
|
+
end
|
9
|
+
|
10
|
+
plug.command(:RPluginCommandNargsN, :nargs => "*") do |nvim, *args|
|
11
|
+
nvim.set_var("rplugin_command_nargs_n", args)
|
12
|
+
end
|
13
|
+
|
14
|
+
plug.command(:RPluginCommandNargsQ, :nargs => "?") do |nvim, arg|
|
15
|
+
nvim.set_var("rplugin_command_nargs_q", arg)
|
16
|
+
end
|
17
|
+
|
18
|
+
plug.command(:RPluginCommandNargsP, :nargs => "+") do |nvim, *args|
|
19
|
+
nvim.set_var("rplugin_command_nargs_p", args)
|
20
|
+
end
|
21
|
+
|
22
|
+
plug.command(:RPluginCommandRange, :range => true) do |nvim, *range|
|
23
|
+
nvim.set_var("rplugin_command_range", range)
|
24
|
+
end
|
25
|
+
|
26
|
+
plug.command(:RPluginCommandRangeP, :range => "%") do |nvim, *range|
|
27
|
+
nvim.set_var("rplugin_command_range_p", range)
|
28
|
+
end
|
29
|
+
|
30
|
+
plug.command(:RPluginCommandRangeN, :range => 1) do |nvim, *range|
|
31
|
+
nvim.set_var("rplugin_command_range_n", range)
|
32
|
+
end
|
33
|
+
|
34
|
+
plug.command(:RPluginCommandCountN, :count => 1) do |nvim, *count|
|
35
|
+
nvim.set_var("rplugin_command_count_n", count)
|
36
|
+
end
|
37
|
+
|
38
|
+
plug.command(:RPluginCommandBang, :bang => true) do |nvim, bang|
|
39
|
+
nvim.set_var("rplugin_command_bang", bang)
|
40
|
+
end
|
41
|
+
|
42
|
+
plug.command(:RPluginCommandRegister, :register => true) do |nvim, reg|
|
43
|
+
nvim.set_var("rplugin_command_register", reg)
|
44
|
+
end
|
45
|
+
|
46
|
+
plug.command(:RPluginCommandCompletion, :complete => "buffer") do |nvim|
|
47
|
+
attrs = nvim.command_output("silent command RPluginCommandCompletion")
|
48
|
+
compl = attrs.split("\n").last.split[2]
|
49
|
+
nvim.set_var("rplugin_command_completion", compl)
|
50
|
+
end
|
51
|
+
|
52
|
+
plug.command(:RPluginCommandEval, :eval => "g:to_eval") do |nvim, to_eval|
|
53
|
+
nvim.set_var("rplugin_command_eval", to_eval)
|
54
|
+
end
|
55
|
+
|
56
|
+
plug.command(:RPluginCommandSync, :sync => true) do |nvim|
|
57
|
+
nvim.set_var("rplugin_command_sync", true)
|
58
|
+
end
|
59
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
Neovim.plugin do |plug|
|
2
|
+
plug.function(:RPluginFunctionArgs) do |nvim, *args|
|
3
|
+
nvim.set_var("rplugin_function_args", args)
|
4
|
+
end
|
5
|
+
|
6
|
+
plug.function(:RPluginFunctionRange, :range => true) do |nvim, *range|
|
7
|
+
nvim.set_var("rplugin_function_range", range)
|
8
|
+
end
|
9
|
+
|
10
|
+
plug.function(:RPluginFunctionEval, :eval => "g:to_eval") do |nvim, to_eval|
|
11
|
+
nvim.set_var("rplugin_function_eval", to_eval)
|
12
|
+
end
|
13
|
+
|
14
|
+
plug.function(:RPluginFunctionSync, :sync => true) do |nvim|
|
15
|
+
true
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,119 @@
|
|
1
|
+
ENV.delete("VIM")
|
2
|
+
ENV.delete("VIMRUNTIME")
|
3
|
+
|
4
|
+
require "helper"
|
5
|
+
require "json"
|
6
|
+
require "net/http"
|
7
|
+
require "open-uri"
|
8
|
+
|
9
|
+
RSpec.describe "integration tests", :timeout => 30 do
|
10
|
+
let(:root) { File.expand_path("../integration", __FILE__) }
|
11
|
+
let(:init) { File.join(root, "runtime/init.vim") }
|
12
|
+
let(:manifest) { File.join(root, "runtime/rplugin.vim") }
|
13
|
+
|
14
|
+
around do |spec|
|
15
|
+
Dir.chdir(root) { spec.run }
|
16
|
+
end
|
17
|
+
|
18
|
+
describe ":ruby" do
|
19
|
+
specify "vader specs" do
|
20
|
+
run_vader("ruby_spec.vim") do |status, output|
|
21
|
+
expect(status).to be_success, lambda { output.read }
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
["vim", "buffer", "window"].each do |object|
|
26
|
+
specify "ruby-#{object}" do
|
27
|
+
run_rspec("+ruby load('ruby_#{object}_spec.rb')") do |status, output|
|
28
|
+
expect(status).to be_success, lambda { output.read }
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
describe ":rubyfile" do
|
35
|
+
specify "vader specs" do
|
36
|
+
run_vader("rubyfile_spec.vim") do |status, output|
|
37
|
+
expect(status).to be_success, lambda { output.read }
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
["vim", "buffer", "window"].each do |object|
|
42
|
+
specify "ruby-#{object}" do
|
43
|
+
run_rspec("+rubyfile ruby_#{object}_spec.rb") do |status, output|
|
44
|
+
expect(status).to be_success, lambda { output.read }
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
describe ":rubydo" do
|
51
|
+
specify "vader specs" do
|
52
|
+
run_vader("rubydo_spec.vim") do |status, output|
|
53
|
+
expect(status).to be_success, lambda { output.read }
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
describe "remote plugin DSL" do
|
59
|
+
before do
|
60
|
+
run_nvim(
|
61
|
+
{"NVIM_RPLUGIN_MANIFEST" => manifest},
|
62
|
+
"-c", "silent UpdateRemotePlugins", "-c", "qa!"
|
63
|
+
)
|
64
|
+
end
|
65
|
+
|
66
|
+
["command", "function", "autocmd"].each do |feature|
|
67
|
+
specify "##{feature}" do
|
68
|
+
run_vader("rplugin_#{feature}_spec.vim") do |status, output|
|
69
|
+
expect(status).to be_success, lambda { output.read }
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
specify "neovim-ruby has up-to-date generated method docs" do
|
76
|
+
begin
|
77
|
+
url = "https://api.github.com/repos/neovim/neovim/releases/latest"
|
78
|
+
response = open(url) { |json| JSON.load(json) }
|
79
|
+
|
80
|
+
client_file = File.read(
|
81
|
+
File.expand_path("../../lib/neovim/client.rb", __FILE__)
|
82
|
+
)
|
83
|
+
docs_version = client_file[
|
84
|
+
/The methods documented here were generated using (.+)$/,
|
85
|
+
1
|
86
|
+
]
|
87
|
+
|
88
|
+
expect(docs_version).to eq(response["name"])
|
89
|
+
rescue SocketError, OpenURI::HTTPError => e
|
90
|
+
skip "Skipping: #{e}"
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
def run_nvim(env, *opts)
|
95
|
+
system(env, Neovim.executable.path, "--headless", "-n", "-u", init, *opts)
|
96
|
+
end
|
97
|
+
|
98
|
+
def run_rspec(*args)
|
99
|
+
Tempfile.open("rspec.out") do |out|
|
100
|
+
run_nvim(
|
101
|
+
{"NVIM_RPLUGIN_MANIFEST" => manifest, "RSPEC_OUTPUT_FILE" => out.path},
|
102
|
+
*args, "+call RunSuite()"
|
103
|
+
)
|
104
|
+
|
105
|
+
yield $?, out
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
def run_vader(test_path)
|
110
|
+
Tempfile.open("vader.out") do |out|
|
111
|
+
run_nvim(
|
112
|
+
{"NVIM_RPLUGIN_MANIFEST" => manifest, "VADER_OUTPUT_FILE" => out.path},
|
113
|
+
"-c", "Vader! #{test_path}"
|
114
|
+
)
|
115
|
+
|
116
|
+
yield $?, out
|
117
|
+
end
|
118
|
+
end
|
119
|
+
end
|
data/spec/neovim/buffer_spec.rb
CHANGED
@@ -18,172 +18,5 @@ module Neovim
|
|
18
18
|
expect(buffer.lines.to_a).to eq(["one", "two"])
|
19
19
|
end
|
20
20
|
end
|
21
|
-
|
22
|
-
describe "#range" do
|
23
|
-
it "returns a LineRange" do
|
24
|
-
expect(buffer.range).to be_a(LineRange)
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
describe "#range=" do
|
29
|
-
it "updates the buffer's range" do
|
30
|
-
buffer.lines = ["one", "two", "three"]
|
31
|
-
buffer.range = (0..1)
|
32
|
-
expect(buffer.range.to_a).to eq(["one", "two"])
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
describe "if_ruby compatibility" do
|
37
|
-
describe "#name" do
|
38
|
-
it "returns the buffer path as a string" do
|
39
|
-
buffer.set_name("test_buf")
|
40
|
-
|
41
|
-
expect(File.basename(buffer.name)).
|
42
|
-
to end_with("test_buf")
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
describe "#number" do
|
47
|
-
it "returns the buffer index" do
|
48
|
-
expect(buffer.number).to be(1)
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
52
|
-
describe "#count" do
|
53
|
-
it "returns the number of lines" do
|
54
|
-
buffer.lines = ["one", "two", "three"]
|
55
|
-
expect(buffer.count).to be(3)
|
56
|
-
end
|
57
|
-
end
|
58
|
-
|
59
|
-
describe "#length" do
|
60
|
-
it "returns the number of lines" do
|
61
|
-
buffer.lines = ["one", "two", "three"]
|
62
|
-
expect(buffer.length).to be(3)
|
63
|
-
end
|
64
|
-
end
|
65
|
-
|
66
|
-
describe "#[]" do
|
67
|
-
it "returns the given line" do
|
68
|
-
buffer.lines = ["one", "two", "three"]
|
69
|
-
expect(buffer[2]).to eq("two")
|
70
|
-
end
|
71
|
-
end
|
72
|
-
|
73
|
-
describe "#[]=" do
|
74
|
-
it "sets the given line" do
|
75
|
-
buffer.lines = ["first", "second"]
|
76
|
-
|
77
|
-
expect {
|
78
|
-
buffer[2] = "last"
|
79
|
-
}.to change { buffer.lines.to_a }.to(["first", "last"])
|
80
|
-
end
|
81
|
-
|
82
|
-
it "returns the line" do
|
83
|
-
expect(buffer[0] = "first").to eq("first")
|
84
|
-
end
|
85
|
-
|
86
|
-
it "raises an out of bounds exception" do
|
87
|
-
expect {
|
88
|
-
buffer[10] = "line"
|
89
|
-
}.to raise_error(/out of bounds/)
|
90
|
-
end
|
91
|
-
end
|
92
|
-
|
93
|
-
describe "#delete" do
|
94
|
-
it "deletes the line at the given index" do
|
95
|
-
buffer.lines = ["one", "two"]
|
96
|
-
|
97
|
-
expect {
|
98
|
-
buffer.delete(1)
|
99
|
-
}.to change { buffer.lines }.to(["two"])
|
100
|
-
end
|
101
|
-
end
|
102
|
-
|
103
|
-
describe "#append" do
|
104
|
-
it "adds a line after the given index" do
|
105
|
-
buffer.lines = ["one"]
|
106
|
-
|
107
|
-
expect {
|
108
|
-
buffer.append(1, "two")
|
109
|
-
}.to change { buffer.lines.to_a }.to(["one", "two"])
|
110
|
-
end
|
111
|
-
|
112
|
-
it "unshifts buffer lines using index 0" do
|
113
|
-
buffer.lines = []
|
114
|
-
|
115
|
-
expect {
|
116
|
-
buffer.append(0, "two")
|
117
|
-
buffer.append(0, "one")
|
118
|
-
}.to change { buffer.lines.to_a }.to(["one", "two", ""])
|
119
|
-
end
|
120
|
-
|
121
|
-
it "leaves the cursor unchanged" do
|
122
|
-
expect {
|
123
|
-
buffer.append(0, "one")
|
124
|
-
}.not_to change { client.current.window.cursor }
|
125
|
-
end
|
126
|
-
|
127
|
-
it "raises for out of bounds indexes" do
|
128
|
-
expect {
|
129
|
-
buffer.append(-1, "err")
|
130
|
-
}.to raise_error(/out of bounds/i)
|
131
|
-
|
132
|
-
expect {
|
133
|
-
buffer.append(10, "err")
|
134
|
-
}.to raise_error(/out of bounds/i)
|
135
|
-
end
|
136
|
-
|
137
|
-
it "returns the appended line" do
|
138
|
-
expect(buffer.append(0, "two")).to eq("two")
|
139
|
-
end
|
140
|
-
end
|
141
|
-
|
142
|
-
describe "#line" do
|
143
|
-
it "returns the current line on an active buffer" do
|
144
|
-
buffer.lines = ["one", "two"]
|
145
|
-
expect(buffer.line).to eq("one")
|
146
|
-
client.command("normal j")
|
147
|
-
expect(buffer.line).to eq("two")
|
148
|
-
end
|
149
|
-
|
150
|
-
it "returns nil on an inactive buffer" do
|
151
|
-
original = buffer
|
152
|
-
client.command("vnew")
|
153
|
-
expect(original.line).to be(nil)
|
154
|
-
end
|
155
|
-
end
|
156
|
-
|
157
|
-
describe "#line=" do
|
158
|
-
it "sets the current line on an active buffer" do
|
159
|
-
expect {
|
160
|
-
buffer.line = "line"
|
161
|
-
}.to change { buffer.lines }.to(["line"])
|
162
|
-
end
|
163
|
-
|
164
|
-
it "has no effect when called on an inactive buffer" do
|
165
|
-
original = buffer
|
166
|
-
client.command("vnew")
|
167
|
-
original.line = "line"
|
168
|
-
|
169
|
-
expect(original.lines.to_a).to eq([""])
|
170
|
-
expect(client.current.buffer.lines.to_a).to eq([""])
|
171
|
-
end
|
172
|
-
end
|
173
|
-
|
174
|
-
describe "#line_number" do
|
175
|
-
it "returns the current line number on an active buffer" do
|
176
|
-
client.command("normal oone")
|
177
|
-
expect(buffer.line_number).to be(2)
|
178
|
-
end
|
179
|
-
|
180
|
-
it "returns nil on an inactive buffer" do
|
181
|
-
original = buffer
|
182
|
-
client.command("vnew")
|
183
|
-
|
184
|
-
expect(original.line_number).to be(nil)
|
185
|
-
end
|
186
|
-
end
|
187
|
-
end
|
188
21
|
end
|
189
22
|
end
|
data/spec/neovim/client_spec.rb
CHANGED
@@ -26,7 +26,7 @@ module Neovim
|
|
26
26
|
end
|
27
27
|
|
28
28
|
describe "#method_missing" do
|
29
|
-
it "enables
|
29
|
+
it "enables nvim_* function calls" do
|
30
30
|
expect(client.strwidth("hi")).to eq(2)
|
31
31
|
end
|
32
32
|
|
@@ -60,48 +60,5 @@ module Neovim
|
|
60
60
|
expect(client.current.tabpage).to be_a(Tabpage)
|
61
61
|
end
|
62
62
|
end
|
63
|
-
|
64
|
-
describe "if_ruby compatibility" do
|
65
|
-
describe "#evaluate" do
|
66
|
-
it "evaluates the vim expression" do
|
67
|
-
client.command("let g:foo = [1, 2]")
|
68
|
-
expect(client.evaluate("g:foo")).to eq([1, 2])
|
69
|
-
end
|
70
|
-
end
|
71
|
-
|
72
|
-
describe "#message" do
|
73
|
-
it "writes a message (testing presence of method, not side-effects)" do
|
74
|
-
client.send(:message, "test")
|
75
|
-
end
|
76
|
-
end
|
77
|
-
|
78
|
-
describe "#set_option" do
|
79
|
-
it "sets an option" do
|
80
|
-
expect {
|
81
|
-
client.set_option("makeprg", "rake")
|
82
|
-
}.to change { client.get_option("makeprg") }.to("rake")
|
83
|
-
end
|
84
|
-
|
85
|
-
it "sets an option as a single string" do
|
86
|
-
expect {
|
87
|
-
client.set_option("makeprg=rake")
|
88
|
-
}.to change { client.get_option("makeprg") }.to("rake")
|
89
|
-
end
|
90
|
-
|
91
|
-
it "sets an integer option as a single string" do
|
92
|
-
expect {
|
93
|
-
client.set_option("timeoutlen=0")
|
94
|
-
}.to change { client.get_option("timeoutlen") }.to(0)
|
95
|
-
end
|
96
|
-
end
|
97
|
-
|
98
|
-
describe "#command" do
|
99
|
-
it "runs the provided command" do
|
100
|
-
expect {
|
101
|
-
client.command("normal ix")
|
102
|
-
}.to change { client.current.buffer.lines }.to(["x"])
|
103
|
-
end
|
104
|
-
end
|
105
|
-
end
|
106
63
|
end
|
107
64
|
end
|