nvim 1.15 → 1.16
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/INFO.yaml +1 -1
- data/README.md +28 -4
- data/lib/neovim/info.rb +2 -2
- data/lib/neovim/output.rb +19 -4
- data/lib/neovim/ruby_provider.rb +8 -2
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: c2ef6709f2a97b05cbb0ec81e5bf83f2b6f244ac8114467df74774a960d45b3c
|
|
4
|
+
data.tar.gz: dfe3a8d2d7b4b45fd0159e3f841d800f3c993cb48538170f54099bbc5cc82b8f
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: a28b8b48fa88f08814ef08119418128d7c0dc061c94f75325d8d9d08081faf6a01ef3fdc5bbe77f174ad067c23dcb07344b3e8dd9b36be1416a76d81d1b69cf4
|
|
7
|
+
data.tar.gz: 893fdd1253149baa2df396faf16ba9552eff9694a9ff10d4826429d7f6eeacdab82f65010d8f47803ca257a56ec2a7548d8ca9efe301c87899508173c088429b
|
data/INFO.yaml
CHANGED
data/README.md
CHANGED
|
@@ -206,6 +206,28 @@ Yet, I suggest not to use `fork` and `exec`, except when
|
|
|
206
206
|
you're absolutely sure what you're doing.
|
|
207
207
|
|
|
208
208
|
|
|
209
|
+
#### Output to a specific buffer
|
|
210
|
+
|
|
211
|
+
You may specify an output buffer by its number.
|
|
212
|
+
|
|
213
|
+
```
|
|
214
|
+
1 a = 0
|
|
215
|
+
2 begin
|
|
216
|
+
3 puts a
|
|
217
|
+
4 a = (a * 61 + 637) % 1000
|
|
218
|
+
5 end while a.nonzero?
|
|
219
|
+
~
|
|
220
|
+
~
|
|
221
|
+
:%ruby @3
|
|
222
|
+
```
|
|
223
|
+
|
|
224
|
+
Use `:execute` if you determine the buffer number by a function.
|
|
225
|
+
|
|
226
|
+
```
|
|
227
|
+
:exe "%ruby @".bufnr("#")
|
|
228
|
+
```
|
|
229
|
+
|
|
230
|
+
|
|
209
231
|
#### Exception handling
|
|
210
232
|
|
|
211
233
|
If you prefer, you may return an error as a value, too.
|
|
@@ -225,8 +247,9 @@ Then:
|
|
|
225
247
|
1 $rescue = true
|
|
226
248
|
2 z = 0
|
|
227
249
|
3 q = 1 / z
|
|
228
|
-
4
|
|
229
|
-
5
|
|
250
|
+
4 #!= ZeroDivisionError
|
|
251
|
+
5 #! divided by 0
|
|
252
|
+
6 puts "=begin", _.backtrace, "=end"
|
|
230
253
|
~
|
|
231
254
|
~
|
|
232
255
|
:5ruby |
|
|
@@ -237,8 +260,8 @@ If `$result` is `false`, `$rescue` will be ignored.
|
|
|
237
260
|
Even non-standard errors wil be caught.
|
|
238
261
|
|
|
239
262
|
```
|
|
240
|
-
1 def
|
|
241
|
-
2
|
|
263
|
+
1 def fn ; fn ; end
|
|
264
|
+
2 fn
|
|
242
265
|
~
|
|
243
266
|
~
|
|
244
267
|
:1,2ruby |
|
|
@@ -252,6 +275,7 @@ Even non-standard errors wil be caught.
|
|
|
252
275
|
~
|
|
253
276
|
:3ruby |
|
|
254
277
|
```
|
|
278
|
+
|
|
255
279
|
Then say 'kill 49042' somewhere else.
|
|
256
280
|
|
|
257
281
|
|
data/lib/neovim/info.rb
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
require "neovim/meta.rb"
|
|
2
2
|
Neovim::INFO = Neovim::Meta.new "nvim",
|
|
3
|
-
version: "1.
|
|
3
|
+
version: "1.16",
|
|
4
4
|
license: "LicenseRef-BSD-2-Clause-and-DECENT_LANGUAGE",
|
|
5
5
|
authors: ["Bertram Scharpf"],
|
|
6
6
|
email: "software@bertram-scharpf.de",
|
|
7
7
|
summary: "Yet another Ruby client for Neovim",
|
|
8
8
|
description: "A simple Ruby client for Neovim.\nClean code, minimal dependecies, no frills, no wokeness.",
|
|
9
9
|
homepage: "https://github.com/BertramScharpf/ruby-nvim",
|
|
10
|
-
commit: "
|
|
10
|
+
commit: "edb2391"
|
data/lib/neovim/output.rb
CHANGED
|
@@ -45,7 +45,7 @@ module Neovim
|
|
|
45
45
|
i.finish
|
|
46
46
|
end
|
|
47
47
|
end
|
|
48
|
-
def initialize client, *rest
|
|
48
|
+
def initialize client, *rest, **kwargs
|
|
49
49
|
@client = client
|
|
50
50
|
end
|
|
51
51
|
def << arg
|
|
@@ -90,7 +90,7 @@ module Neovim
|
|
|
90
90
|
end
|
|
91
91
|
end
|
|
92
92
|
end
|
|
93
|
-
def initialize *args
|
|
93
|
+
def initialize *args, **kwargs
|
|
94
94
|
super
|
|
95
95
|
@str = ""
|
|
96
96
|
end
|
|
@@ -137,19 +137,34 @@ module Neovim
|
|
|
137
137
|
end
|
|
138
138
|
|
|
139
139
|
class WriteBuf < WriteStd
|
|
140
|
-
def initialize *args, follow:
|
|
140
|
+
def initialize *args, buffer: nil, follow: true
|
|
141
141
|
super
|
|
142
142
|
@lines = []
|
|
143
|
+
@buffer = buffer
|
|
144
|
+
if Integer === @buffer then
|
|
145
|
+
@buffer = Buffer.new @buffer, @client
|
|
146
|
+
end
|
|
143
147
|
@follow = follow.to_bool
|
|
144
148
|
end
|
|
145
149
|
def finish
|
|
146
150
|
super
|
|
147
|
-
|
|
151
|
+
if @buffer then
|
|
152
|
+
r = buffer_is_empty? ? 0..1 : (@follow ? -1..-1 : 0..0)
|
|
153
|
+
@buffer.set_lines r.begin, r.end, true, @lines
|
|
154
|
+
else
|
|
155
|
+
@client.put @lines, "l", @follow, @follow
|
|
156
|
+
end
|
|
148
157
|
end
|
|
149
158
|
private
|
|
150
159
|
def write_line l
|
|
151
160
|
@lines.push l
|
|
152
161
|
end
|
|
162
|
+
def buffer_is_empty?
|
|
163
|
+
if @buffer.line_count <= 1 then
|
|
164
|
+
e, = @buffer.get_lines 0, 1, true
|
|
165
|
+
e.empty?
|
|
166
|
+
end
|
|
167
|
+
end
|
|
153
168
|
end
|
|
154
169
|
|
|
155
170
|
end
|
data/lib/neovim/ruby_provider.rb
CHANGED
|
@@ -23,14 +23,14 @@ module Vim
|
|
|
23
23
|
class <<Buffer
|
|
24
24
|
def current ; $vim.get_current_buf ; end
|
|
25
25
|
def count ; $vim.list_bufs.size ; end
|
|
26
|
-
def [] i ; $vim.list_bufs
|
|
26
|
+
def [] i ; $vim.list_bufs.find { |b| b.index == i } ; end
|
|
27
27
|
end
|
|
28
28
|
|
|
29
29
|
Window = ::Neovim::Window
|
|
30
30
|
class <<Window
|
|
31
31
|
def current ; $vim.get_current_win ; end
|
|
32
32
|
def count ; $vim.get_current_tabpage.list_wins.size ; end
|
|
33
|
-
def [] i ; $vim.get_current_tabpage.list_wins
|
|
33
|
+
def [] i ; $vim.get_current_tabpage.list_wins.find { |w| w.index == i } ; end
|
|
34
34
|
self
|
|
35
35
|
end
|
|
36
36
|
|
|
@@ -167,6 +167,12 @@ module Neovim
|
|
|
167
167
|
script_binding.local_variable_set :_, $!
|
|
168
168
|
end
|
|
169
169
|
end
|
|
170
|
+
elsif code =~ /\A@(\d+)\z/ then
|
|
171
|
+
set_globals client, fst..lst do |lines|
|
|
172
|
+
WriteBuf.redirect client, buffer: $1.to_i, follow: true do
|
|
173
|
+
script_binding.eval lines.to_s, "ruby_run"
|
|
174
|
+
end
|
|
175
|
+
end
|
|
170
176
|
elsif code == "+" then
|
|
171
177
|
client.command "#{lst}"
|
|
172
178
|
set_globals client, fst..lst do |lines|
|