nvim 1.14.1 → 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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4df34be40dc780445a8534b01d98c59ad0bc0ab05da727e2f40d8a95c74f765c
4
- data.tar.gz: 665cf4edbaee51945bf2940dcb2a1123bf79009bef29b8335d4e965206cb2c70
3
+ metadata.gz: c2ef6709f2a97b05cbb0ec81e5bf83f2b6f244ac8114467df74774a960d45b3c
4
+ data.tar.gz: dfe3a8d2d7b4b45fd0159e3f841d800f3c993cb48538170f54099bbc5cc82b8f
5
5
  SHA512:
6
- metadata.gz: 62589684b7ea686899543001bd5f9e27566c1464e7ffda212ac2d4ad1f383bf4386fecaa3e3626844c9cb025bdc9eab1ed3276cf889eb82bfab85c7d2efef8c3
7
- data.tar.gz: 636cc302ddefadd6e9c4daa7b807da7b0254eec09804ca0b3efd9c5b32228db0901a10a7d25683c3b046f81408cf6685c2c3f4c00a78086756b3e04c7fc10272
6
+ metadata.gz: a28b8b48fa88f08814ef08119418128d7c0dc061c94f75325d8d9d08081faf6a01ef3fdc5bbe77f174ad067c23dcb07344b3e8dd9b36be1416a76d81d1b69cf4
7
+ data.tar.gz: 893fdd1253149baa2df396faf16ba9552eff9694a9ff10d4826429d7f6eeacdab82f65010d8f47803ca257a56ec2a7548d8ca9efe301c87899508173c088429b
data/INFO.yaml CHANGED
@@ -3,7 +3,7 @@
3
3
  #
4
4
 
5
5
  nvim:
6
- version: "1.14.1"
6
+ version: "1.16"
7
7
  license: LicenseRef-BSD-2-Clause-and-DECENT_LANGUAGE
8
8
  authors:
9
9
  - Bertram Scharpf
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 #=> #<ZeroDivisionError: divided by 0>
229
- 5 puts "=begin", _.backtrace, "=end"
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 f ; f ; end
241
- 2 f
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
 
@@ -7,6 +7,7 @@
7
7
  begin
8
8
  require "supplement"
9
9
  rescue LoadError
10
+ class NilClass ; def nonzero? ; end ; end
10
11
  class NilClass ; def notempty? ; end ; end
11
12
  class String ; def notempty? ; self unless empty? ; end ; end
12
13
  class Array ; def notempty? ; self unless empty? ; end ; end
@@ -27,20 +28,32 @@ rescue LoadError
27
28
  end
28
29
  end
29
30
  class String
30
- def axe n
31
+ ELLIPSE = :"..."
32
+ def axe n = 80
31
33
  if n < length then
32
- e = "..."
33
- l = e.length
34
- if n > l then
34
+ l = ELLIPSE.length
35
+ if n >= l then
35
36
  n -= l
36
37
  else
37
- l = 0
38
+ n, l = 0, n
38
39
  end
39
- (slice 0, n) << "..."[0,l]
40
+ self[ 0, n] << ELLIPSE[0,l]
40
41
  else
41
42
  self
42
43
  end
43
44
  end
45
+ def axe! n = 80
46
+ if n < length then
47
+ l = ELLIPSE.length
48
+ if n >= l then
49
+ n -= l
50
+ else
51
+ n, l = 0, n
52
+ end
53
+ slice! n...nil
54
+ self << ELLIPSE[0,l]
55
+ end
56
+ end
44
57
  def starts_with? oth ; o = oth.to_str ; o.length if start_with? o ; end
45
58
  def ends_with? oth ; o = oth.to_str ; length - o.length if end_with? o ; end
46
59
  alias starts_with starts_with?
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.14.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: "5b9a1c2"
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: nil
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
- @client.put @lines, "l", @follow, @follow
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
@@ -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[ i] ; end
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[ i] ; end
33
+ def [] i ; $vim.get_current_tabpage.list_wins.find { |w| w.index == i } ; end
34
34
  self
35
35
  end
36
36
 
@@ -156,15 +156,21 @@ module Neovim
156
156
  set_globals client, fst..lst do |lines|
157
157
  client.command "#{lst}"
158
158
  WriteBuf.redirect client, follow: true do
159
- r = begin
160
- script_binding.eval lines.to_s, "ruby_run"
161
- rescue Exception
162
- $@.pop until $@.empty? or $@.last =~ /:\d+:in .*\bempty_binding\W*$/
163
- raise unless $rescue and $result != false
164
- $!
165
- end
166
- script_binding.local_variable_set :_, r unless r.nil?
159
+ r = script_binding.eval lines.to_s, "ruby_run"
167
160
  puts "#=> #{r.inspect}" if $result or ($result.nil? and not r.nil?)
161
+ script_binding.local_variable_set :_, r unless r.nil?
162
+ rescue Exception
163
+ $@.pop until $@.empty? or $@.last =~ /:\d+:in .*\bempty_binding\W*$/
164
+ raise unless $rescue and $result != false
165
+ puts "#!= #{$!.class}"
166
+ $!.message.each_line { |l| puts "#! #{l}" }
167
+ script_binding.local_variable_set :_, $!
168
+ end
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"
168
174
  end
169
175
  end
170
176
  elsif code == "+" then
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nvim
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.14.1
4
+ version: '1.16'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bertram Scharpf