neovim 0.1.0 → 0.2.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/CHANGELOG.md +9 -0
- data/Gemfile +8 -4
- data/lib/neovim/async_session.rb +1 -0
- data/lib/neovim/buffer.rb +9 -9
- data/lib/neovim/client.rb +18 -0
- data/lib/neovim/ruby_provider.rb +44 -38
- data/lib/neovim/session.rb +11 -17
- data/lib/neovim/version.rb +1 -1
- data/neovim.gemspec +0 -1
- data/spec/acceptance/ruby_provider_spec.rb +129 -0
- data/spec/helper.rb +1 -2
- data/spec/neovim/buffer_spec.rb +10 -8
- data/spec/neovim/client_spec.rb +31 -0
- metadata +18 -33
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e3a9a7f0da47d7d562b10232fe88d5c4ad4fe0d0
|
4
|
+
data.tar.gz: f12e9d6d73601ca7f5b1650b4c9d35e391f2755d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e3f98a53f364aebc4829e8c11dea30f5930b96686ed3bba9691559ec0947825f42d0ad4a33da4658f2cca2c3e298f07434a25c8b218df6e6c4ab22280933dd04
|
7
|
+
data.tar.gz: d37fd74b9f588da7c09844c7c3c7c6cdd18edba7f15e9115cc5bcb54a06744e70337349841ae81ae8b4f116492529a5fbc86ee5a2b60869cdedc6720fd69ece0
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,12 @@
|
|
1
|
+
# 0.2.0
|
2
|
+
- Backwards incompatible, but we're pre-1.0.0 so going with minor bump instead
|
3
|
+
- Make legacy ruby functions 1-indexed
|
4
|
+
- Add Client#evaluate and Client#message
|
5
|
+
- Make ruby functions affect global scope
|
6
|
+
- Add VIM::{Buffer,Window}.{count,index}
|
7
|
+
- Add minor debug logging to Session and AsyncSession
|
8
|
+
- Remove race condition in Session fiber handling
|
9
|
+
|
1
10
|
# 0.1.0
|
2
11
|
- Add --version, -V to neovim-ruby-host executable
|
3
12
|
- Update object interfaces to be compatible with Vim :ruby API
|
data/Gemfile
CHANGED
@@ -1,8 +1,12 @@
|
|
1
1
|
source "https://rubygems.org"
|
2
2
|
gemspec
|
3
3
|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
4
|
+
group :development do
|
5
|
+
if Gem::Version.new(RUBY_VERSION.dup) >= Gem::Version.new("2.0.0")
|
6
|
+
gem "coveralls"
|
7
|
+
gem "pry-byebug"
|
8
|
+
else
|
9
|
+
gem "coveralls", "0.8.13"
|
10
|
+
gem "pry-debugger"
|
11
|
+
end
|
8
12
|
end
|
data/lib/neovim/async_session.rb
CHANGED
data/lib/neovim/buffer.rb
CHANGED
@@ -56,7 +56,7 @@ module Neovim
|
|
56
56
|
#
|
57
57
|
# @return [Fixnum]
|
58
58
|
def count
|
59
|
-
|
59
|
+
line_count
|
60
60
|
end
|
61
61
|
|
62
62
|
# Get the number of lines.
|
@@ -66,38 +66,38 @@ module Neovim
|
|
66
66
|
count
|
67
67
|
end
|
68
68
|
|
69
|
-
# Get the line
|
69
|
+
# Get the given line (1-indexed).
|
70
70
|
#
|
71
71
|
# @param index [Fixnum]
|
72
72
|
# @return [String]
|
73
73
|
def [](index)
|
74
|
-
lines[index]
|
74
|
+
lines[index-1]
|
75
75
|
end
|
76
76
|
|
77
|
-
# Set the line
|
77
|
+
# Set the given line (1-indexed).
|
78
78
|
#
|
79
79
|
# @param index [Fixnum]
|
80
80
|
# @param str [String]
|
81
81
|
# @return [String]
|
82
82
|
def []=(index, str)
|
83
|
-
lines[index] = str
|
83
|
+
lines[index-1] = str
|
84
84
|
end
|
85
85
|
|
86
|
-
# Delete the line
|
86
|
+
# Delete the given line (1-indexed).
|
87
87
|
#
|
88
88
|
# @param index [Fixnum]
|
89
89
|
# @return [void]
|
90
90
|
def delete(index)
|
91
|
-
lines.delete(index)
|
91
|
+
lines.delete(index-1)
|
92
92
|
end
|
93
93
|
|
94
|
-
# Append a line after the given
|
94
|
+
# Append a line after the given line (1-indexed).
|
95
95
|
#
|
96
96
|
# @param index [Fixnum]
|
97
97
|
# @param str [String]
|
98
98
|
# @return [String]
|
99
99
|
def append(index, str)
|
100
|
-
lines[index, 1] = [lines[index], str]
|
100
|
+
lines[index-1, 1] = [lines[index-1], str]
|
101
101
|
str
|
102
102
|
end
|
103
103
|
|
data/lib/neovim/client.rb
CHANGED
@@ -50,6 +50,24 @@ module Neovim
|
|
50
50
|
@current ||= Current.new(@session)
|
51
51
|
end
|
52
52
|
|
53
|
+
# Evaluate the VimL expression (alias for +vim_eval+).
|
54
|
+
#
|
55
|
+
# @param expr [String] A VimL expression.
|
56
|
+
# @return [Object]
|
57
|
+
# @example Return a list from VimL
|
58
|
+
# client.evaluate('[1, 2]') # => [1, 2]
|
59
|
+
def evaluate(expr)
|
60
|
+
@api.function(:vim_eval).call(@session, expr)
|
61
|
+
end
|
62
|
+
|
63
|
+
# Display a message.
|
64
|
+
#
|
65
|
+
# @param string [String] The message.
|
66
|
+
# @return [void]
|
67
|
+
def message(string)
|
68
|
+
out_write(string)
|
69
|
+
end
|
70
|
+
|
53
71
|
private
|
54
72
|
|
55
73
|
def rpc_methods
|
data/lib/neovim/ruby_provider.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
$__ruby_provider_scope = binding
|
2
|
+
|
1
3
|
class VIM < BasicObject
|
2
4
|
class << self
|
3
5
|
attr_accessor :__client
|
@@ -17,6 +19,14 @@ module Neovim
|
|
17
19
|
def self.current
|
18
20
|
::VIM.current.buffer
|
19
21
|
end
|
22
|
+
|
23
|
+
def self.count
|
24
|
+
::VIM.get_buffers.size
|
25
|
+
end
|
26
|
+
|
27
|
+
def self.[](index)
|
28
|
+
::VIM.get_buffers[index]
|
29
|
+
end
|
20
30
|
end
|
21
31
|
|
22
32
|
# Make +VIM::Window.current+ return the current buffer.
|
@@ -24,6 +34,14 @@ module Neovim
|
|
24
34
|
def self.current
|
25
35
|
::VIM.current.window
|
26
36
|
end
|
37
|
+
|
38
|
+
def self.count
|
39
|
+
::VIM.get_windows.size
|
40
|
+
end
|
41
|
+
|
42
|
+
def self.[](index)
|
43
|
+
::VIM.get_windows[index]
|
44
|
+
end
|
27
45
|
end
|
28
46
|
|
29
47
|
module RubyProvider
|
@@ -38,7 +56,7 @@ module Neovim
|
|
38
56
|
def self.define_ruby_execute(plug)
|
39
57
|
plug.rpc(:ruby_execute, sync: true) do |nvim, ruby|
|
40
58
|
wrap_client(nvim) do
|
41
|
-
eval(ruby,
|
59
|
+
$__ruby_provider_scope.eval(ruby, __FILE__, __LINE__)
|
42
60
|
end
|
43
61
|
end
|
44
62
|
end
|
@@ -47,7 +65,7 @@ module Neovim
|
|
47
65
|
def self.define_ruby_execute_file(plug)
|
48
66
|
plug.rpc(:ruby_execute_file, sync: true) do |nvim, path|
|
49
67
|
wrap_client(nvim) do
|
50
|
-
eval(File.read(path),
|
68
|
+
$__ruby_provider_scope.eval(File.read(path), __FILE__, __LINE__)
|
51
69
|
end
|
52
70
|
end
|
53
71
|
end
|
@@ -55,7 +73,7 @@ module Neovim
|
|
55
73
|
|
56
74
|
def self.define_ruby_do_range(plug)
|
57
75
|
plug.rpc(:ruby_do_range, sync: true) do |nvim, *args|
|
58
|
-
|
76
|
+
wrap_client(nvim) do
|
59
77
|
start, stop, ruby = args
|
60
78
|
buffer = nvim.current.buffer
|
61
79
|
|
@@ -64,72 +82,60 @@ module Neovim
|
|
64
82
|
lines = buffer.get_lines(_start, _stop, true)
|
65
83
|
|
66
84
|
lines.map! do |line|
|
67
|
-
$_ = line
|
68
|
-
eval(ruby,
|
69
|
-
|
85
|
+
$__ruby_provider_scope.eval("$_ = #{line.inspect}")
|
86
|
+
$__ruby_provider_scope.eval(ruby, __FILE__, __LINE__)
|
87
|
+
$__ruby_provider_scope.eval("$_")
|
70
88
|
end
|
71
89
|
|
72
90
|
buffer.set_lines(_start, _stop, true, lines)
|
73
91
|
end
|
74
|
-
ensure
|
75
|
-
$_ = nil
|
76
92
|
end
|
77
93
|
end
|
78
94
|
end
|
79
95
|
private_class_method :define_ruby_do_range
|
80
96
|
|
81
|
-
def self.wrap_client(
|
82
|
-
with_globals(
|
83
|
-
with_vim_constant(
|
84
|
-
with_redirect_streams(
|
97
|
+
def self.wrap_client(__client)
|
98
|
+
with_globals(__client) do
|
99
|
+
with_vim_constant(__client) do
|
100
|
+
with_redirect_streams(__client) do
|
85
101
|
yield
|
86
102
|
end
|
87
103
|
end
|
88
104
|
end
|
105
|
+
nil
|
89
106
|
end
|
90
107
|
private_class_method :wrap_client
|
91
108
|
|
92
109
|
def self.with_globals(client)
|
93
|
-
$curwin = client.current.window
|
94
110
|
$curbuf = client.current.buffer
|
95
|
-
|
96
|
-
|
97
|
-
yield
|
98
|
-
ensure
|
99
|
-
$curwin = $curbuf = nil
|
100
|
-
end
|
111
|
+
$curwin = client.current.window
|
112
|
+
yield
|
101
113
|
end
|
102
114
|
private_class_method :with_globals
|
103
115
|
|
104
116
|
def self.with_vim_constant(client)
|
105
117
|
::VIM.__client = client
|
106
|
-
|
107
|
-
begin
|
108
|
-
yield
|
109
|
-
ensure
|
110
|
-
::VIM.__client = nil
|
111
|
-
end
|
118
|
+
yield
|
112
119
|
end
|
113
120
|
private_class_method :with_vim_constant
|
114
121
|
|
115
122
|
def self.with_redirect_streams(client)
|
116
|
-
|
117
|
-
|
123
|
+
@with_redirect_streams ||= begin
|
124
|
+
old_out_write = $stdout.method(:write)
|
125
|
+
old_err_write = $stderr.method(:write)
|
118
126
|
|
119
|
-
|
120
|
-
|
121
|
-
|
127
|
+
$stdout.define_singleton_method(:write) do |string|
|
128
|
+
client.out_write(string)
|
129
|
+
end
|
122
130
|
|
123
|
-
|
124
|
-
|
125
|
-
|
131
|
+
$stderr.define_singleton_method(:write) do |string|
|
132
|
+
client.err_write(string)
|
133
|
+
end
|
126
134
|
|
127
|
-
|
128
|
-
yield
|
129
|
-
ensure
|
130
|
-
$stdout.define_singleton_method(:write, &old_out_write)
|
131
|
-
$stderr.define_singleton_method(:write, &old_err_write)
|
135
|
+
true
|
132
136
|
end
|
137
|
+
|
138
|
+
yield
|
133
139
|
end
|
134
140
|
private_class_method :with_redirect_streams
|
135
141
|
end
|
data/lib/neovim/session.rb
CHANGED
@@ -1,12 +1,15 @@
|
|
1
1
|
require "neovim/api"
|
2
2
|
require "neovim/async_session"
|
3
3
|
require "neovim/event_loop"
|
4
|
+
require "neovim/logging"
|
4
5
|
require "neovim/msgpack_stream"
|
5
6
|
require "fiber"
|
6
7
|
|
7
8
|
module Neovim
|
8
9
|
# Wraps an +AsyncSession+ in a synchronous API using +Fiber+s.
|
9
10
|
class Session
|
11
|
+
include Logging
|
12
|
+
|
10
13
|
# Connect to a TCP socket.
|
11
14
|
#
|
12
15
|
# @param host [String] The hostname or IP address
|
@@ -54,7 +57,7 @@ module Neovim
|
|
54
57
|
def initialize(async_session)
|
55
58
|
@async_session = async_session
|
56
59
|
@pending_messages = []
|
57
|
-
@
|
60
|
+
@main_fiber = Fiber.current
|
58
61
|
@running = false
|
59
62
|
end
|
60
63
|
|
@@ -86,13 +89,13 @@ module Neovim
|
|
86
89
|
@running = true
|
87
90
|
|
88
91
|
while message = @pending_messages.shift
|
89
|
-
|
92
|
+
Fiber.new { yield message if block_given? }.resume
|
90
93
|
end
|
91
94
|
|
92
95
|
return unless @running
|
93
96
|
|
94
97
|
@async_session.run(self) do |message|
|
95
|
-
|
98
|
+
Fiber.new { yield message if block_given? }.resume
|
96
99
|
end
|
97
100
|
ensure
|
98
101
|
stop
|
@@ -114,10 +117,12 @@ module Neovim
|
|
114
117
|
# @return [Object] The response from the RPC call
|
115
118
|
# @raise [ArgumentError] An error returned from +nvim+
|
116
119
|
def request(method, *args)
|
117
|
-
if @
|
118
|
-
|
119
|
-
else
|
120
|
+
if Fiber.current == @main_fiber
|
121
|
+
debug("handling blocking request")
|
120
122
|
err, res = stopped_request(method, *args)
|
123
|
+
else
|
124
|
+
debug("yielding request to fiber")
|
125
|
+
err, res = running_request(method, *args)
|
121
126
|
end
|
122
127
|
|
123
128
|
err ? raise(ArgumentError, err) : res
|
@@ -160,17 +165,6 @@ module Neovim
|
|
160
165
|
|
161
166
|
private
|
162
167
|
|
163
|
-
def in_handler_fiber(&block)
|
164
|
-
Fiber.new do
|
165
|
-
@in_handler = true
|
166
|
-
begin
|
167
|
-
block.call
|
168
|
-
ensure
|
169
|
-
@in_handler = false
|
170
|
-
end
|
171
|
-
end.resume
|
172
|
-
end
|
173
|
-
|
174
168
|
def running_request(method, *args)
|
175
169
|
fiber = Fiber.current
|
176
170
|
@async_session.request(method, *args) do |err, res|
|
data/lib/neovim/version.rb
CHANGED
data/neovim.gemspec
CHANGED
@@ -22,6 +22,5 @@ Gem::Specification.new do |spec|
|
|
22
22
|
spec.add_development_dependency "bundler"
|
23
23
|
spec.add_development_dependency "rake"
|
24
24
|
spec.add_development_dependency "pry"
|
25
|
-
spec.add_development_dependency "coveralls"
|
26
25
|
spec.add_development_dependency "rspec", "~> 3.0"
|
27
26
|
end
|
@@ -35,6 +35,68 @@ RSpec.describe "ruby_provider" do
|
|
35
35
|
nvim.eval("rpcrequest(host, 'ruby_execute', #{ruby})")
|
36
36
|
}.to change { nvim.current.buffer.lines.to_a }.to(["line"])
|
37
37
|
end
|
38
|
+
|
39
|
+
it "exposes VIM::Buffer.current" do
|
40
|
+
expect {
|
41
|
+
ruby = "VIM::Buffer.current.lines = ['line']".inspect
|
42
|
+
nvim.eval("rpcrequest(host, 'ruby_execute', #{ruby})")
|
43
|
+
}.to change { nvim.current.buffer.lines.to_a }.to(["line"])
|
44
|
+
end
|
45
|
+
|
46
|
+
it "exposes VIM::Buffer.count" do
|
47
|
+
ruby = "VIM.set_var('count', VIM::Buffer.count)".inspect
|
48
|
+
nvim.eval("rpcrequest(host, 'ruby_execute', #{ruby})")
|
49
|
+
expect(nvim.get_var("count")).to eq(1)
|
50
|
+
|
51
|
+
nvim.command("tabe")
|
52
|
+
|
53
|
+
ruby = "VIM.set_var('count', VIM::Buffer.count)".inspect
|
54
|
+
nvim.eval("rpcrequest(host, 'ruby_execute', #{ruby})")
|
55
|
+
expect(nvim.get_var("count")).to eq(2)
|
56
|
+
end
|
57
|
+
|
58
|
+
it "exposes VIM::Buffer[]" do
|
59
|
+
expect {
|
60
|
+
ruby = "VIM::Buffer[0].lines = ['line']".inspect
|
61
|
+
nvim.eval("rpcrequest(host, 'ruby_execute', #{ruby})")
|
62
|
+
}.to change { nvim.current.buffer.lines.to_a }.to(["line"])
|
63
|
+
end
|
64
|
+
|
65
|
+
it "exposes VIM::Window.current" do
|
66
|
+
nvim.command("vsplit")
|
67
|
+
expect {
|
68
|
+
ruby = "VIM::Window.current.width = 12".inspect
|
69
|
+
nvim.eval("rpcrequest(host, 'ruby_execute', #{ruby})")
|
70
|
+
}.to change { nvim.current.window.width }.to(12)
|
71
|
+
end
|
72
|
+
|
73
|
+
it "exposes VIM::Window.count" do
|
74
|
+
ruby = "VIM.set_var('count', VIM::Window.count)".inspect
|
75
|
+
nvim.eval("rpcrequest(host, 'ruby_execute', #{ruby})")
|
76
|
+
expect(nvim.get_var("count")).to eq(1)
|
77
|
+
|
78
|
+
nvim.command("vsplit")
|
79
|
+
|
80
|
+
ruby = "VIM.set_var('count', VIM::Window.count)".inspect
|
81
|
+
nvim.eval("rpcrequest(host, 'ruby_execute', #{ruby})")
|
82
|
+
expect(nvim.get_var("count")).to eq(2)
|
83
|
+
end
|
84
|
+
|
85
|
+
it "exposes VIM::Window[]" do
|
86
|
+
nvim.command("vsplit")
|
87
|
+
expect {
|
88
|
+
ruby = "VIM::Window[0].width = 12".inspect
|
89
|
+
nvim.eval("rpcrequest(host, 'ruby_execute', #{ruby})")
|
90
|
+
}.to change { nvim.current.window.width }.to(12)
|
91
|
+
end
|
92
|
+
|
93
|
+
it "persists state between requests" do
|
94
|
+
nvim.eval("rpcrequest(host, 'ruby_execute', 'def foo; VIM.command(\"let g:called = 1\"); end')")
|
95
|
+
expect { nvim.get_var("called") }.to raise_error(/key not found/i)
|
96
|
+
|
97
|
+
nvim.eval("rpcrequest(host, 'ruby_execute', 'foo')")
|
98
|
+
expect(nvim.get_var("called")).to be(1)
|
99
|
+
end
|
38
100
|
end
|
39
101
|
|
40
102
|
describe "ruby_execute_file" do
|
@@ -62,6 +124,73 @@ RSpec.describe "ruby_provider" do
|
|
62
124
|
nvim.eval("rpcrequest(host, 'ruby_execute_file', '#{script_path}')")
|
63
125
|
}.to change { nvim.current.buffer.lines.to_a }.to(["line"])
|
64
126
|
end
|
127
|
+
|
128
|
+
it "exposes VIM::Buffer.current" do
|
129
|
+
File.write(script_path, "VIM::Buffer.current.lines = ['line']")
|
130
|
+
|
131
|
+
expect {
|
132
|
+
nvim.eval("rpcrequest(host, 'ruby_execute_file', '#{script_path}')")
|
133
|
+
}.to change { nvim.current.buffer.lines.to_a }.to(["line"])
|
134
|
+
end
|
135
|
+
|
136
|
+
it "exposes VIM::Buffer.count" do
|
137
|
+
File.write(script_path, "VIM.set_var('count', VIM::Buffer.count)")
|
138
|
+
nvim.eval("rpcrequest(host, 'ruby_execute_file', '#{script_path}')")
|
139
|
+
expect(nvim.get_var("count")).to eq(1)
|
140
|
+
|
141
|
+
nvim.command("tabe")
|
142
|
+
|
143
|
+
File.write(script_path, "VIM.set_var('count', VIM::Buffer.count)")
|
144
|
+
nvim.eval("rpcrequest(host, 'ruby_execute_file', '#{script_path}')")
|
145
|
+
expect(nvim.get_var("count")).to eq(2)
|
146
|
+
end
|
147
|
+
|
148
|
+
it "exposes VIM::Buffer[]" do
|
149
|
+
File.write(script_path, "VIM::Buffer[0].lines = ['line']")
|
150
|
+
|
151
|
+
expect {
|
152
|
+
nvim.eval("rpcrequest(host, 'ruby_execute_file', '#{script_path}')")
|
153
|
+
}.to change { nvim.current.buffer.lines.to_a }.to(["line"])
|
154
|
+
end
|
155
|
+
|
156
|
+
it "exposes VIM::Window.current" do
|
157
|
+
nvim.command("vsplit")
|
158
|
+
File.write(script_path, "VIM::Window.current.width = 12")
|
159
|
+
|
160
|
+
expect {
|
161
|
+
nvim.eval("rpcrequest(host, 'ruby_execute_file', '#{script_path}')")
|
162
|
+
}.to change { nvim.current.window.width }.to(12)
|
163
|
+
end
|
164
|
+
|
165
|
+
it "exposes VIM::Window.count" do
|
166
|
+
File.write(script_path, "VIM.set_var('count', VIM::Window.count)")
|
167
|
+
nvim.eval("rpcrequest(host, 'ruby_execute_file', '#{script_path}')")
|
168
|
+
expect(nvim.get_var("count")).to eq(1)
|
169
|
+
|
170
|
+
nvim.command("vsplit")
|
171
|
+
|
172
|
+
File.write(script_path, "VIM.set_var('count', VIM::Window.count)")
|
173
|
+
nvim.eval("rpcrequest(host, 'ruby_execute_file', '#{script_path}')")
|
174
|
+
expect(nvim.get_var("count")).to eq(2)
|
175
|
+
end
|
176
|
+
|
177
|
+
it "exposes VIM::Window[]" do
|
178
|
+
nvim.command("vsplit")
|
179
|
+
File.write(script_path, "VIM::Window[0].width = 12")
|
180
|
+
|
181
|
+
expect {
|
182
|
+
nvim.eval("rpcrequest(host, 'ruby_execute_file', '#{script_path}')")
|
183
|
+
}.to change { nvim.current.window.width }.to(12)
|
184
|
+
end
|
185
|
+
|
186
|
+
it "persists state between requests" do
|
187
|
+
File.write(script_path, "def foo; VIM.command(\"let g:called = 1\"); end")
|
188
|
+
nvim.eval("rpcrequest(host, 'ruby_execute_file', '#{script_path}')")
|
189
|
+
expect { nvim.get_var("called") }.to raise_error(/key not found/i)
|
190
|
+
|
191
|
+
nvim.eval("rpcrequest(host, 'ruby_execute', 'foo')")
|
192
|
+
expect(nvim.get_var("called")).to be(1)
|
193
|
+
end
|
65
194
|
end
|
66
195
|
|
67
196
|
describe "ruby_do_range" do
|
data/spec/helper.rb
CHANGED
@@ -1,5 +1,4 @@
|
|
1
1
|
require "bundler/setup"
|
2
|
-
require "mkmf"
|
3
2
|
require "neovim"
|
4
3
|
require "pry"
|
5
4
|
require "timeout"
|
@@ -11,7 +10,7 @@ if ENV["REPORT_COVERAGE"]
|
|
11
10
|
Coveralls.wear!
|
12
11
|
end
|
13
12
|
|
14
|
-
unless
|
13
|
+
unless system("nvim -nu NONE +q")
|
15
14
|
warn("Can't find `nvim` executable. See installation instructions:")
|
16
15
|
warn("https://github.com/neovim/neovim/wiki/Installing-Neovim")
|
17
16
|
exit(1)
|
data/spec/neovim/buffer_spec.rb
CHANGED
@@ -63,19 +63,19 @@ module Neovim
|
|
63
63
|
end
|
64
64
|
|
65
65
|
describe "#[]" do
|
66
|
-
it "returns the
|
66
|
+
it "returns the given line" do
|
67
67
|
buffer.lines = ["one", "two", "three"]
|
68
|
-
expect(buffer[
|
68
|
+
expect(buffer[2]).to eq("two")
|
69
69
|
end
|
70
70
|
end
|
71
71
|
|
72
72
|
describe "#[]=" do
|
73
|
-
it "sets the
|
74
|
-
buffer.lines = ["
|
73
|
+
it "sets the given line" do
|
74
|
+
buffer.lines = ["first", "second"]
|
75
75
|
|
76
76
|
expect {
|
77
|
-
buffer[
|
78
|
-
}.to change { buffer.lines }.to(["first", "
|
77
|
+
buffer[2] = "last"
|
78
|
+
}.to change { buffer.lines.to_a }.to(["first", "last"])
|
79
79
|
end
|
80
80
|
|
81
81
|
it "returns the line" do
|
@@ -94,7 +94,7 @@ module Neovim
|
|
94
94
|
buffer.lines = ["one", "two"]
|
95
95
|
|
96
96
|
expect {
|
97
|
-
buffer.delete(
|
97
|
+
buffer.delete(1)
|
98
98
|
}.to change { buffer.lines }.to(["two"])
|
99
99
|
end
|
100
100
|
end
|
@@ -104,7 +104,7 @@ module Neovim
|
|
104
104
|
buffer.lines = ["one"]
|
105
105
|
|
106
106
|
expect {
|
107
|
-
buffer.append(
|
107
|
+
buffer.append(1, "two")
|
108
108
|
}.to change { buffer.lines.to_a }.to(["one", "two"])
|
109
109
|
end
|
110
110
|
|
@@ -117,6 +117,8 @@ module Neovim
|
|
117
117
|
it "returns the current line on an active buffer" do
|
118
118
|
buffer.lines = ["one", "two"]
|
119
119
|
expect(buffer.line).to eq("one")
|
120
|
+
client.command("normal j")
|
121
|
+
expect(buffer.line).to eq("two")
|
120
122
|
end
|
121
123
|
|
122
124
|
it "returns nil on an inactive buffer" do
|
data/spec/neovim/client_spec.rb
CHANGED
@@ -53,5 +53,36 @@ module Neovim
|
|
53
53
|
expect(client.current.tabpage).to be_a(Tabpage)
|
54
54
|
end
|
55
55
|
end
|
56
|
+
|
57
|
+
describe "if_ruby compatibility" do
|
58
|
+
describe "#evaluate" do
|
59
|
+
it "evaluates the vim expression" do
|
60
|
+
client.command("let g:foo = [1, 2]")
|
61
|
+
expect(client.evaluate("g:foo")).to eq([1, 2])
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
describe "#message" do
|
66
|
+
it "writes a message (testing presence of method, not side-effects)" do
|
67
|
+
client.send(:message, "test")
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
describe "#set_option" do
|
72
|
+
it "sets an option" do
|
73
|
+
expect {
|
74
|
+
client.set_option("makeprg", "rake")
|
75
|
+
}.to change { client.get_option("makeprg") }
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
describe "#command" do
|
80
|
+
it "runs the provided command" do
|
81
|
+
expect {
|
82
|
+
client.command("normal ix")
|
83
|
+
}.to change { client.current.buffer.lines }.to(["x"])
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
56
87
|
end
|
57
88
|
end
|
metadata
CHANGED
@@ -1,97 +1,83 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: neovim
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alex Genco
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-07-
|
11
|
+
date: 2016-07-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: msgpack
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - ~>
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '0.7'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - ~>
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0.7'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: bundler
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - '>='
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '0'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- -
|
38
|
+
- - '>='
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rake
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- -
|
45
|
+
- - '>='
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: '0'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- -
|
52
|
+
- - '>='
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: pry
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- -
|
59
|
+
- - '>='
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: '0'
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- -
|
67
|
-
- !ruby/object:Gem::Version
|
68
|
-
version: '0'
|
69
|
-
- !ruby/object:Gem::Dependency
|
70
|
-
name: coveralls
|
71
|
-
requirement: !ruby/object:Gem::Requirement
|
72
|
-
requirements:
|
73
|
-
- - ">="
|
74
|
-
- !ruby/object:Gem::Version
|
75
|
-
version: '0'
|
76
|
-
type: :development
|
77
|
-
prerelease: false
|
78
|
-
version_requirements: !ruby/object:Gem::Requirement
|
79
|
-
requirements:
|
80
|
-
- - ">="
|
66
|
+
- - '>='
|
81
67
|
- !ruby/object:Gem::Version
|
82
68
|
version: '0'
|
83
69
|
- !ruby/object:Gem::Dependency
|
84
70
|
name: rspec
|
85
71
|
requirement: !ruby/object:Gem::Requirement
|
86
72
|
requirements:
|
87
|
-
- -
|
73
|
+
- - ~>
|
88
74
|
- !ruby/object:Gem::Version
|
89
75
|
version: '3.0'
|
90
76
|
type: :development
|
91
77
|
prerelease: false
|
92
78
|
version_requirements: !ruby/object:Gem::Requirement
|
93
79
|
requirements:
|
94
|
-
- -
|
80
|
+
- - ~>
|
95
81
|
- !ruby/object:Gem::Version
|
96
82
|
version: '3.0'
|
97
83
|
description:
|
@@ -102,9 +88,9 @@ executables:
|
|
102
88
|
extensions: []
|
103
89
|
extra_rdoc_files: []
|
104
90
|
files:
|
105
|
-
-
|
106
|
-
-
|
107
|
-
-
|
91
|
+
- .coveralls.yml
|
92
|
+
- .gitignore
|
93
|
+
- .travis.yml
|
108
94
|
- CHANGELOG.md
|
109
95
|
- Gemfile
|
110
96
|
- LICENSE.txt
|
@@ -166,17 +152,17 @@ require_paths:
|
|
166
152
|
- lib
|
167
153
|
required_ruby_version: !ruby/object:Gem::Requirement
|
168
154
|
requirements:
|
169
|
-
- -
|
155
|
+
- - '>='
|
170
156
|
- !ruby/object:Gem::Version
|
171
157
|
version: '0'
|
172
158
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
173
159
|
requirements:
|
174
|
-
- -
|
160
|
+
- - '>='
|
175
161
|
- !ruby/object:Gem::Version
|
176
162
|
version: '0'
|
177
163
|
requirements: []
|
178
164
|
rubyforge_project:
|
179
|
-
rubygems_version: 2.
|
165
|
+
rubygems_version: 2.0.14.1
|
180
166
|
signing_key:
|
181
167
|
specification_version: 4
|
182
168
|
summary: A Ruby client for Neovim
|
@@ -200,4 +186,3 @@ test_files:
|
|
200
186
|
- spec/neovim/window_spec.rb
|
201
187
|
- spec/neovim_spec.rb
|
202
188
|
- spec/support.rb
|
203
|
-
has_rdoc:
|