nvim 1.0.0 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/INFO.yaml +2 -2
- data/README.md +28 -0
- data/bin/neovim-ruby-host +24 -21
- data/lib/neovim/connection.rb +2 -2
- data/lib/neovim/foreign/supplement.rb +9 -0
- data/lib/neovim/foreign/xxd.rb +195 -0
- data/lib/neovim/handler.rb +33 -20
- data/lib/neovim/host.rb +27 -47
- data/lib/neovim/info.rb +3 -3
- data/lib/neovim/logging.rb +16 -7
- data/lib/neovim/output.rb +142 -0
- data/lib/neovim/remote.rb +241 -18
- data/lib/neovim/remote_object.rb +7 -7
- data/lib/neovim/ruby_provider.rb +25 -110
- data/lib/neovim/tools/copy.rb +78 -0
- data/lib/neovim/vimscript_provider.rb +1 -1
- data/lib/neovim.rb +14 -4
- metadata +7 -6
- data/lib/neovim/messager.rb +0 -185
- data/lib/neovim/session.rb +0 -60
data/lib/neovim.rb
CHANGED
@@ -7,13 +7,23 @@ require "neovim/host"
|
|
7
7
|
|
8
8
|
module Neovim
|
9
9
|
|
10
|
+
class Job < Provider
|
11
|
+
|
12
|
+
def initialize plugins, conn
|
13
|
+
super plugins, conn
|
14
|
+
start
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
18
|
+
|
10
19
|
class <<self
|
11
20
|
|
12
21
|
def start_remote &block
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
22
|
+
Job.run mk_plugins &block
|
23
|
+
end
|
24
|
+
|
25
|
+
def mk_plugins &block
|
26
|
+
{ remote: (DslRemote.open &block) }
|
17
27
|
end
|
18
28
|
|
19
29
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nvim
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bertram Scharpf
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-08-28 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description:
|
14
14
|
email: software@bertram-scharpf.de
|
@@ -29,18 +29,19 @@ files:
|
|
29
29
|
- lib/neovim/foreign/mplight/bufferio.rb
|
30
30
|
- lib/neovim/foreign/supplement.rb
|
31
31
|
- lib/neovim/foreign/supplement/socket.rb
|
32
|
+
- lib/neovim/foreign/xxd.rb
|
32
33
|
- lib/neovim/handler.rb
|
33
34
|
- lib/neovim/host.rb
|
34
35
|
- lib/neovim/info.rb
|
35
36
|
- lib/neovim/logging.rb
|
36
|
-
- lib/neovim/messager.rb
|
37
37
|
- lib/neovim/meta.rb
|
38
|
+
- lib/neovim/output.rb
|
38
39
|
- lib/neovim/remote.rb
|
39
40
|
- lib/neovim/remote_object.rb
|
40
41
|
- lib/neovim/ruby_provider.rb
|
41
|
-
- lib/neovim/
|
42
|
+
- lib/neovim/tools/copy.rb
|
42
43
|
- lib/neovim/vimscript_provider.rb
|
43
|
-
homepage:
|
44
|
+
homepage: https://github.com/BertramScharpf/ruby-nvim
|
44
45
|
licenses:
|
45
46
|
- BSD-2-Clause+
|
46
47
|
metadata: {}
|
@@ -59,7 +60,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
59
60
|
- !ruby/object:Gem::Version
|
60
61
|
version: '0'
|
61
62
|
requirements: []
|
62
|
-
rubygems_version: 3.5.
|
63
|
+
rubygems_version: 3.5.14
|
63
64
|
signing_key:
|
64
65
|
specification_version: 4
|
65
66
|
summary: Yet another Ruby client for Neovim
|
data/lib/neovim/messager.rb
DELETED
@@ -1,185 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# neovim/messager.rb -- Send and Receive Messages
|
3
|
-
#
|
4
|
-
|
5
|
-
require "neovim/foreign/supplement"
|
6
|
-
|
7
|
-
require "neovim/logging"
|
8
|
-
|
9
|
-
|
10
|
-
module Neovim
|
11
|
-
|
12
|
-
class Messager
|
13
|
-
|
14
|
-
class Message
|
15
|
-
|
16
|
-
@subs, @subh = [], {}
|
17
|
-
|
18
|
-
class <<self
|
19
|
-
|
20
|
-
def from_array ary
|
21
|
-
kind, *payload = *ary
|
22
|
-
klass = find kind
|
23
|
-
klass[ *payload]
|
24
|
-
end
|
25
|
-
|
26
|
-
def inherited cls ; @subs.push cls ; end
|
27
|
-
def find id
|
28
|
-
@subh[ id] ||= @subs.find { |c| c::ID == id }
|
29
|
-
end
|
30
|
-
|
31
|
-
alias [] new
|
32
|
-
|
33
|
-
end
|
34
|
-
|
35
|
-
def initialize *args
|
36
|
-
z = self.class::KEYS.zip args
|
37
|
-
@cont = z.inject Hash.new do |c,(h,k)| c[h] = k ; c end
|
38
|
-
end
|
39
|
-
|
40
|
-
def inspect
|
41
|
-
c = self.class.name.sub /.*::/, ""
|
42
|
-
"#<#{c} #@cont>"
|
43
|
-
end
|
44
|
-
|
45
|
-
def to_s
|
46
|
-
c = self.class.name.sub /.*::/, ""
|
47
|
-
j = @cont.map { |k,v| "#{k}:#{v}" if v }.compact.join ","
|
48
|
-
"#{c}(#{j})"
|
49
|
-
end
|
50
|
-
|
51
|
-
def method_missing sym, *args
|
52
|
-
if @cont.key? sym then @cont[ sym] else super end
|
53
|
-
end
|
54
|
-
|
55
|
-
def respond_to_missing? sym, priv = nil
|
56
|
-
@cont.key? sym.to_sym
|
57
|
-
end
|
58
|
-
|
59
|
-
def methods *args
|
60
|
-
super.concat @cont.keys
|
61
|
-
end
|
62
|
-
|
63
|
-
def to_h ; @cont ; end
|
64
|
-
|
65
|
-
def fields ; @cont.fetch_values *self.class::KEYS ; end
|
66
|
-
|
67
|
-
def to_a
|
68
|
-
[self.class::ID, *fields]
|
69
|
-
end
|
70
|
-
|
71
|
-
class Request < Message
|
72
|
-
ID = 0
|
73
|
-
KEYS = %i(request_id method_name arguments)
|
74
|
-
end
|
75
|
-
|
76
|
-
class Response < Message
|
77
|
-
ID = 1
|
78
|
-
KEYS = %i(request_id error value)
|
79
|
-
def initialize *args
|
80
|
-
super
|
81
|
-
e = @cont[ :error]
|
82
|
-
if e and not Array === e then
|
83
|
-
@cont[ :error] = [0, e]
|
84
|
-
end
|
85
|
-
end
|
86
|
-
|
87
|
-
end
|
88
|
-
|
89
|
-
class Notification < Message
|
90
|
-
ID = 2
|
91
|
-
KEYS = %i(method_name arguments)
|
92
|
-
end
|
93
|
-
|
94
|
-
end
|
95
|
-
|
96
|
-
class ResponseError < StandardError ; end
|
97
|
-
|
98
|
-
class Disconnected < RuntimeError
|
99
|
-
def initialize
|
100
|
-
super "Lost connection to nvim process"
|
101
|
-
end
|
102
|
-
end
|
103
|
-
|
104
|
-
|
105
|
-
include Logging
|
106
|
-
|
107
|
-
def initialize conn, session
|
108
|
-
@conn, @session = conn, session
|
109
|
-
@request_id = 0
|
110
|
-
@responses = {}
|
111
|
-
end
|
112
|
-
|
113
|
-
def run until_id = nil
|
114
|
-
loop do
|
115
|
-
message = get
|
116
|
-
case message
|
117
|
-
when Message::Response then
|
118
|
-
if @responses.key? message.request_id then
|
119
|
-
@responses[ message.request_id] = message
|
120
|
-
else
|
121
|
-
log :warning, "Dropped response", message.request_id
|
122
|
-
end
|
123
|
-
when Message::Request then
|
124
|
-
begin
|
125
|
-
r = @session.execute_handler message.method_name, message.arguments
|
126
|
-
log :debug1, "Request result", result: r
|
127
|
-
rescue
|
128
|
-
e = [ 0, $!.to_s]
|
129
|
-
log_exception :error
|
130
|
-
end
|
131
|
-
rsp = Message::Response.new message.request_id, e, r
|
132
|
-
put rsp
|
133
|
-
when Message::Notification then
|
134
|
-
begin
|
135
|
-
@session.execute_handler message.method_name, message.arguments
|
136
|
-
rescue
|
137
|
-
log_exception :error
|
138
|
-
end
|
139
|
-
end
|
140
|
-
break if until_id and @responses[ until_id]
|
141
|
-
end
|
142
|
-
end
|
143
|
-
|
144
|
-
def request method, *args
|
145
|
-
@request_id += 1
|
146
|
-
put Message::Request[ @request_id, method, args]
|
147
|
-
@responses[ @request_id] = nil
|
148
|
-
run @request_id
|
149
|
-
r = @responses.delete @request_id
|
150
|
-
if r.error then
|
151
|
-
t, e = *r.error
|
152
|
-
t = @conn.error t
|
153
|
-
raise ResponseError, "#{t}: #{e}"
|
154
|
-
end
|
155
|
-
r.value
|
156
|
-
end
|
157
|
-
|
158
|
-
def notify method, *args
|
159
|
-
put Message::Notification[ method, args]
|
160
|
-
end
|
161
|
-
|
162
|
-
private
|
163
|
-
|
164
|
-
def put msg
|
165
|
-
log :debug1, "Sending Message", data: msg
|
166
|
-
@conn.put msg.to_a
|
167
|
-
self
|
168
|
-
rescue Errno::EPIPE
|
169
|
-
raise Disconnected
|
170
|
-
end
|
171
|
-
|
172
|
-
def get
|
173
|
-
IO.select [@conn.input], nil, nil
|
174
|
-
raise Disconnected if @conn.eof?
|
175
|
-
msg = Message.from_array @conn.get
|
176
|
-
log :debug1, "Received Message", data: msg
|
177
|
-
msg
|
178
|
-
rescue EOFError
|
179
|
-
raise Disconnected
|
180
|
-
end
|
181
|
-
|
182
|
-
end
|
183
|
-
|
184
|
-
end
|
185
|
-
|
data/lib/neovim/session.rb
DELETED
@@ -1,60 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# neovim/session.rb -- Sessions
|
3
|
-
#
|
4
|
-
|
5
|
-
require "neovim/foreign/supplement"
|
6
|
-
|
7
|
-
require "neovim/logging"
|
8
|
-
require "neovim/connection"
|
9
|
-
require "neovim/messager"
|
10
|
-
|
11
|
-
|
12
|
-
module Neovim
|
13
|
-
|
14
|
-
class Session
|
15
|
-
|
16
|
-
include Logging
|
17
|
-
|
18
|
-
class <<self
|
19
|
-
|
20
|
-
private :new
|
21
|
-
|
22
|
-
def open conntype, *args, **kwargs
|
23
|
-
conntype.open_files *args, **kwargs do |conn|
|
24
|
-
yield (new conn)
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
include Logging
|
29
|
-
|
30
|
-
def start *args
|
31
|
-
open_logfile do
|
32
|
-
log :info, "Starting", args: $*
|
33
|
-
open *args do |i|
|
34
|
-
yield i
|
35
|
-
end
|
36
|
-
ensure
|
37
|
-
log :info, "Leaving"
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
end
|
42
|
-
|
43
|
-
def initialize conn
|
44
|
-
@conn = conn
|
45
|
-
@comm = Messager.new @conn, self
|
46
|
-
end
|
47
|
-
|
48
|
-
def execute_handler name, args
|
49
|
-
raise "No handler found for #{name.inspect}."
|
50
|
-
end
|
51
|
-
|
52
|
-
|
53
|
-
def run ; @comm.run ; end
|
54
|
-
def request method, *args ; @comm.request method, *args ; end
|
55
|
-
def notify method, *args ; @comm.notify method, *args ; end
|
56
|
-
|
57
|
-
end
|
58
|
-
|
59
|
-
end
|
60
|
-
|