nvim 1.13.4 → 1.14.1

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: 86b2b03d1aaf9ccb0a8f8c9cfcc356da5c0166bffc973ac2aaea7faf7a360b83
4
- data.tar.gz: 4af7414f996231c2070b00b157eeb3e097aa852da302f9bb512412d394919975
3
+ metadata.gz: 4df34be40dc780445a8534b01d98c59ad0bc0ab05da727e2f40d8a95c74f765c
4
+ data.tar.gz: 665cf4edbaee51945bf2940dcb2a1123bf79009bef29b8335d4e965206cb2c70
5
5
  SHA512:
6
- metadata.gz: ee684cf65ee6c9e80b38e9a58023c3832fdd1824fe29d919da54c63e723527aae2a234e3204452fb8ee3fa883db6a1a3cf577e88f7d51ffc9acdc894f184d841
7
- data.tar.gz: 261486d13c57469eae397f4af2cce20e680356e03511257f8ab7cc95e3d914b7cdb3a46084ce0aabe80abe4d6e6e86557901ec18c8ca18d172d75a3b0c62b904
6
+ metadata.gz: 62589684b7ea686899543001bd5f9e27566c1464e7ffda212ac2d4ad1f383bf4386fecaa3e3626844c9cb025bdc9eab1ed3276cf889eb82bfab85c7d2efef8c3
7
+ data.tar.gz: 636cc302ddefadd6e9c4daa7b807da7b0254eec09804ca0b3efd9c5b32228db0901a10a7d25683c3b046f81408cf6685c2c3f4c00a78086756b3e04c7fc10272
data/INFO.yaml CHANGED
@@ -3,7 +3,7 @@
3
3
  #
4
4
 
5
5
  nvim:
6
- version: "1.13.4"
6
+ version: "1.14.1"
7
7
  license: LicenseRef-BSD-2-Clause-and-DECENT_LANGUAGE
8
8
  authors:
9
9
  - Bertram Scharpf
data/README.md CHANGED
@@ -310,7 +310,7 @@ values will be converted by `#to_s`.
310
310
  ### Requiring Ruby files
311
311
 
312
312
  In addition to the `:rubyfile` command as documented, that command can also be
313
- used to just require a Ruby file. Set the name into angle brackets, and the
313
+ used to just require a Ruby file. Put the name into angle brackets, and the
314
314
  file will be searched in `$:`. Sorry, file name completion will not work.
315
315
 
316
316
  ```
data/lib/neovim/client.rb CHANGED
@@ -129,11 +129,11 @@ module Neovim
129
129
  when Buffer then @client, @buffer = client.client, client.index
130
130
  else @client, @buffer = client, 0
131
131
  end
132
- @i, @last = range.begin, range.end
132
+ @first, @last = range.begin, range.end
133
133
  end
134
134
 
135
135
  def to_s
136
- (@client.buf_get_lines @buffer, @i-1, @last, true).join $/
136
+ (@client.buf_get_lines @buffer, @first-1, @last, true).join $/
137
137
  end
138
138
 
139
139
  def method_missing sym, *args, **kwargs, &block
@@ -141,46 +141,65 @@ module Neovim
141
141
  end
142
142
 
143
143
  def each
144
- while @i <= @last do
145
- @inc = 1
146
- l, = @client.buf_get_lines @buffer, @i-1, @i, true
147
- yield l
148
- @i += @inc
144
+ if block_given? then
145
+ begin
146
+ @i = @first
147
+ while @i <= @last do
148
+ l, = @client.buf_get_lines @buffer, @i-1, @i, true
149
+ yield l, @i
150
+ @i += 1
151
+ end
152
+ ensure
153
+ @i = nil
154
+ end
155
+ else
156
+ Enumerator.new { |y| each { |l,i| y.yield l, i } }
149
157
  end
150
- ensure
151
- @i = nil
152
158
  end
153
159
  alias each_line each
154
160
 
155
- def each_with_no
156
- each do |l|
157
- yield l, @i
161
+ def map!
162
+ if block_given? then
163
+ each do |l|
164
+ h = l.hash
165
+ m = yield l, @i
166
+ if m.hash != h or m != l then
167
+ r = Neovim.result_lines m
168
+ @client.buf_set_lines @buffer, @i-1, @i, true, r
169
+ inc = r.length - 1
170
+ @i += inc
171
+ @last += inc
172
+ end
173
+ end
174
+ else
175
+ Enumerator.new { |y| map! { |l,i| y.yield l, i } }
158
176
  end
159
177
  end
178
+ alias collect! map!
160
179
 
161
- def map!
162
- each do |l|
163
- h = l.hash
164
- m = yield l, @i
165
- if not String === m or m.hash != h then
166
- r = result_strings m
167
- r.flatten!
168
- @client.buf_set_lines @buffer, @i-1, @i, true, r
169
- @inc = r.length
170
- @last += @inc-1
180
+ def reject!
181
+ if block_given? then
182
+ each do |l|
183
+ if yield l, @i then
184
+ @client.buf_set_lines @buffer, @i-1, @i, true, []
185
+ @i -= 1
186
+ @last -= 1
187
+ end
171
188
  end
189
+ else
190
+ Enumerator.new { |y| reject! { |l,i| y.yield l, i } }
172
191
  end
173
192
  end
193
+ alias delete_if reject!
174
194
 
175
- private
176
-
177
- def result_strings obj
178
- case obj
179
- when Enumerable then obj.map { |l| result_strings l }
180
- when nil then []
181
- else obj.to_s.scan /^.*$/
195
+ def select!
196
+ if block_given? then
197
+ reject! { |l,i| not (yield l, i) }
198
+ else
199
+ Enumerator.new { |y| select! { |l,i| y.yield l, i } }
182
200
  end
183
201
  end
202
+ alias filter! select!
184
203
 
185
204
  end
186
205
 
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.13.4",
3
+ version: "1.14.1",
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: "d1a9799"
10
+ commit: "5b9a1c2"
@@ -147,7 +147,7 @@ module Neovim
147
147
 
148
148
  def []= pos = nil, len = nil, str
149
149
  line_indices pos, len do |fst,lst|
150
- set_lines fst, lst, false, (str_lines str)
150
+ set_lines fst, lst, false, (Neovim.result_lines str)
151
151
  end
152
152
  self
153
153
  end
@@ -193,36 +193,61 @@ module Neovim
193
193
  include Enumerable
194
194
 
195
195
  def each pos = nil, len = nil, &block
196
- iter_chunks pos, len do |fst,nxt|
197
- (get_lines fst, nxt, true).each &block
196
+ if block_given? then
197
+ iter_chunks pos, len do |l|
198
+ l.each &block
199
+ end
200
+ else
201
+ Enumerator.new { |y| each { |x,i| y.yield x, i } }
198
202
  end
199
203
  end
200
204
 
201
205
  def map! pos = nil, len = nil, &block
202
- iter_chunks pos, len do |fst,nxt|
203
- l = (get_lines fst, nxt, true).map &block
204
- set_lines fst, nxt, true, l
206
+ if block_given? then
207
+ iter_chunks pos, len do |l|
208
+ n = l.length
209
+ h = l.hash
210
+ m = l.map &block
211
+ if m.hash != h or m != l then
212
+ r = Neovim.result_lines m
213
+ set_lines @fst, @fst+n, true, r
214
+ inc = r.length - n
215
+ @fst += inc
216
+ @lst += inc
217
+ end
218
+ end
219
+ else
220
+ Enumerator.new { |y| map! { |x,i| y.yield x, i } }
205
221
  end
206
222
  end
223
+ alias collect! map!
207
224
 
208
- def select! pos = nil, len = nil, &block
209
- line_indices_positive pos, len do |fst,lst|
210
- while fst < lst do
211
- l, = get_lines fst, fst+1, true
212
- if yield l then
213
- fst += 1
214
- else
215
- set_lines fst, fst+1, true, []
216
- lst -= 1
225
+ def reject! pos = nil, len = nil, &block
226
+ if block_given? then
227
+ iter_chunks pos, len do |l|
228
+ n = l.length
229
+ l.reject! &block
230
+ if l.length < n then
231
+ set_lines @fst, @fst+n, true, l
232
+ inc = l.length - n
233
+ @fst += inc
234
+ @lst += inc
217
235
  end
218
236
  end
237
+ else
238
+ Enumerator.new { |y| map! { |x,i| y.yield x, i } }
219
239
  end
220
240
  end
241
+ alias delete_if reject!
221
242
 
222
- def reject! pos = nil, len = nil, &block
223
- select! pos, len do |l| !yield l end
243
+ def select!
244
+ if block_given? then
245
+ reject! { |l| not (yield l) }
246
+ else
247
+ Enumerator.new { |y| select! { |l| y.yield l } }
248
+ end
224
249
  end
225
-
250
+ alias filter! select!
226
251
 
227
252
  # Don't run into `method_missing`.
228
253
  def get_lines fst, lst, strict ; call_obj :get_lines, fst, lst, strict ; end
@@ -262,32 +287,22 @@ module Neovim
262
287
  end
263
288
  end
264
289
 
265
- @chunk = 1024 # Attention! Each chunk is its own undo level.
290
+ @chunk_length = 1024
266
291
  class <<self
267
- attr_accessor :chunk
292
+ attr_accessor :chunk_length
268
293
  end
269
294
 
270
295
  def iter_chunks pos, len
271
296
  line_indices_positive pos, len do |fst,lst|
272
- while lst do
273
- nxt = fst + self.class.chunk
274
- if nxt > lst then
275
- nxt, lst = lst, nil
276
- end
277
- yield fst, nxt
278
- fst = nxt
297
+ @fst, @lst = fst, lst
298
+ while @fst < @lst do
299
+ l = get_lines @fst, @fst+self.class.chunk_length, false
300
+ yield l
301
+ @fst += self.class.chunk_length
279
302
  end
280
303
  end
281
- end
282
-
283
- def str_lines str
284
- if Array === str then
285
- str
286
- elsif str.nil? then
287
- []
288
- else
289
- str.lines.each { |l| l.chomp! }
290
- end
304
+ ensure
305
+ @fst = @lst = nil
291
306
  end
292
307
 
293
308
  end
@@ -330,5 +345,18 @@ module Neovim
330
345
 
331
346
  end
332
347
 
348
+
349
+ class <<self
350
+
351
+ def result_lines obj
352
+ case obj
353
+ when Enumerable then obj.inject [] do |s,l| s.push *(result_lines l) end
354
+ when nil then []
355
+ else obj.to_s.scan /^.*$/
356
+ end
357
+ end
358
+
359
+ end
360
+
333
361
  end
334
362
 
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.13.4
4
+ version: 1.14.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bertram Scharpf